1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* |
---|
5 | * ABSTRACT: |
---|
6 | */ |
---|
7 | |
---|
8 | #include <string.h> |
---|
9 | #include <unistd.h> |
---|
10 | #include <stdio.h> |
---|
11 | #include <stddef.h> |
---|
12 | #include <stdlib.h> |
---|
13 | #include <time.h> |
---|
14 | |
---|
15 | #include "mod2.h" |
---|
16 | #include <mylimits.h> |
---|
17 | #include "omalloc.h" |
---|
18 | #include "structs.h" |
---|
19 | #include "tok.h" |
---|
20 | #include "febase.h" |
---|
21 | #include "cntrlc.h" |
---|
22 | #include "page.h" |
---|
23 | #include "ipid.h" |
---|
24 | #include "ipshell.h" |
---|
25 | #include "kstd1.h" |
---|
26 | #include "subexpr.h" |
---|
27 | #include "timer.h" |
---|
28 | #include "intvec.h" |
---|
29 | #include "ring.h" |
---|
30 | #include "omSingularConfig.h" |
---|
31 | #include "p_Procs.h" |
---|
32 | /* Needed for debug Version of p_SetRingOfLeftv, Oliver */ |
---|
33 | #ifdef PDEBUG |
---|
34 | #include "p_polys.h" |
---|
35 | #endif |
---|
36 | #include "version.h" |
---|
37 | |
---|
38 | #include "static.h" |
---|
39 | #ifdef HAVE_STATIC |
---|
40 | #undef HAVE_DYN_RL |
---|
41 | #endif |
---|
42 | |
---|
43 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
44 | |
---|
45 | //#ifdef HAVE_LIBPARSER |
---|
46 | //# include "libparse.h" |
---|
47 | //#endif /* HAVE_LIBPARSER */ |
---|
48 | |
---|
49 | #ifdef HAVE_FACTORY |
---|
50 | #include <factory.h> |
---|
51 | // libfac: |
---|
52 | extern const char * libfac_version; |
---|
53 | extern const char * libfac_date; |
---|
54 | #endif |
---|
55 | |
---|
56 | /* version strings */ |
---|
57 | #include <si_gmp.h> |
---|
58 | #ifdef HAVE_MPSR |
---|
59 | #include <MP_Config.h> |
---|
60 | #endif |
---|
61 | |
---|
62 | /*2 |
---|
63 | * initialize components of Singular |
---|
64 | */ |
---|
65 | int inits(void) |
---|
66 | { |
---|
67 | int t; |
---|
68 | /*4 signal handler:*/ |
---|
69 | init_signals(); |
---|
70 | /*4 randomize: */ |
---|
71 | t=initTimer(); |
---|
72 | /*t=(int)time(NULL);*/ |
---|
73 | if (t==0) t=1; |
---|
74 | #ifdef HAVE_RTIMER |
---|
75 | initRTimer(); |
---|
76 | #endif |
---|
77 | #ifdef buildin_rand |
---|
78 | siSeed=t; |
---|
79 | #else |
---|
80 | srand((unsigned int)t); |
---|
81 | #endif |
---|
82 | #ifdef HAVE_FACTORY |
---|
83 | factoryseed(t); |
---|
84 | #endif |
---|
85 | /*4 private data of other modules*/ |
---|
86 | memset(&sLastPrinted,0,sizeof(sleftv)); |
---|
87 | sLastPrinted.rtyp=NONE; |
---|
88 | return t; |
---|
89 | } |
---|
90 | |
---|
91 | /*2 |
---|
92 | * the renice routine for very large jobs |
---|
93 | * works only on unix machines, |
---|
94 | * testet on : linux, HP 9.0 |
---|
95 | * |
---|
96 | *#include <sys/times.h> |
---|
97 | *#include <sys/resource.h> |
---|
98 | *extern "C" int setpriority(int,int,int); |
---|
99 | *void very_nice() |
---|
100 | *{ |
---|
101 | *#ifndef NO_SETPRIORITY |
---|
102 | * setpriority(PRIO_PROCESS,0,19); |
---|
103 | *#endif |
---|
104 | * sleep(10); |
---|
105 | *} |
---|
106 | */ |
---|
107 | |
---|
108 | void singular_example(char *str) |
---|
109 | { |
---|
110 | assume(str!=NULL); |
---|
111 | char *s=str; |
---|
112 | while (*s==' ') s++; |
---|
113 | char *ss=s; |
---|
114 | while (*ss!='\0') ss++; |
---|
115 | while (*ss<=' ') |
---|
116 | { |
---|
117 | *ss='\0'; |
---|
118 | ss--; |
---|
119 | } |
---|
120 | idhdl h=IDROOT->get(s,myynest); |
---|
121 | if ((h!=NULL) && (IDTYP(h)==PROC_CMD)) |
---|
122 | { |
---|
123 | char *lib=iiGetLibName(IDPROC(h)); |
---|
124 | if((lib!=NULL)&&(*lib!='\0')) |
---|
125 | { |
---|
126 | Print("// proc %s from lib %s\n",s,lib); |
---|
127 | s=iiGetLibProcBuffer(IDPROC(h), 2); |
---|
128 | if (s!=NULL) |
---|
129 | { |
---|
130 | if (strlen(s)>5) |
---|
131 | { |
---|
132 | iiEStart(s,IDPROC(h)); |
---|
133 | return; |
---|
134 | } |
---|
135 | else omFree((ADDRESS)s); |
---|
136 | } |
---|
137 | } |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | char sing_file[MAXPATHLEN]; |
---|
142 | FILE *fd=NULL; |
---|
143 | char *res_m=feResource('m', 0); |
---|
144 | if (res_m!=NULL) |
---|
145 | { |
---|
146 | sprintf(sing_file, "%s/%s.sing", res_m, s); |
---|
147 | fd = feFopen(sing_file, "r"); |
---|
148 | } |
---|
149 | if (fd != NULL) |
---|
150 | { |
---|
151 | |
---|
152 | int old_echo = si_echo; |
---|
153 | int length, got; |
---|
154 | char* s; |
---|
155 | |
---|
156 | fseek(fd, 0, SEEK_END); |
---|
157 | length = ftell(fd); |
---|
158 | fseek(fd, 0, SEEK_SET); |
---|
159 | s = (char*) omAlloc((length+20)*sizeof(char)); |
---|
160 | got = fread(s, sizeof(char), length, fd); |
---|
161 | fclose(fd); |
---|
162 | if (got != length) |
---|
163 | { |
---|
164 | Werror("Error while reading file %s", sing_file); |
---|
165 | omFree(s); |
---|
166 | } |
---|
167 | else |
---|
168 | { |
---|
169 | s[length] = '\0'; |
---|
170 | strcat(s, "\n;return();\n\n"); |
---|
171 | si_echo = 2; |
---|
172 | iiEStart(s, NULL); |
---|
173 | si_echo = old_echo; |
---|
174 | } |
---|
175 | } |
---|
176 | else |
---|
177 | { |
---|
178 | Werror("no example for %s", str); |
---|
179 | } |
---|
180 | } |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | struct soptionStruct |
---|
185 | { |
---|
186 | const char * name; |
---|
187 | unsigned setval; |
---|
188 | unsigned resetval; |
---|
189 | }; |
---|
190 | |
---|
191 | struct soptionStruct optionStruct[]= |
---|
192 | { |
---|
193 | {"prot", Sy_bit(OPT_PROT), ~Sy_bit(OPT_PROT) }, |
---|
194 | {"redSB", Sy_bit(OPT_REDSB), ~Sy_bit(OPT_REDSB) }, |
---|
195 | {"notBuckets", Sy_bit(OPT_NOT_BUCKETS), ~Sy_bit(OPT_NOT_BUCKETS) }, |
---|
196 | {"notSugar", Sy_bit(OPT_NOT_SUGAR), ~Sy_bit(OPT_NOT_SUGAR) }, |
---|
197 | {"interrupt", Sy_bit(OPT_INTERRUPT), ~Sy_bit(OPT_INTERRUPT) }, |
---|
198 | {"sugarCrit", Sy_bit(OPT_SUGARCRIT), ~Sy_bit(OPT_SUGARCRIT) }, |
---|
199 | {"teach", Sy_bit(OPT_DEBUG), ~Sy_bit(OPT_DEBUG) }, |
---|
200 | /* 9 return SB in syz, quotient, intersect */ |
---|
201 | {"returnSB", Sy_bit(OPT_RETURN_SB), ~Sy_bit(OPT_RETURN_SB) }, |
---|
202 | {"fastHC", Sy_bit(OPT_FASTHC), ~Sy_bit(OPT_FASTHC) }, |
---|
203 | /* 11-19 sort in L/T */ |
---|
204 | {"keepvars", Sy_bit(OPT_KEEPVARS), ~Sy_bit(OPT_KEEPVARS) }, |
---|
205 | {"staircaseBound",Sy_bit(OPT_STAIRCASEBOUND),~Sy_bit(OPT_STAIRCASEBOUND) }, |
---|
206 | {"multBound", Sy_bit(OPT_MULTBOUND), ~Sy_bit(OPT_MULTBOUND) }, |
---|
207 | {"degBound", Sy_bit(OPT_DEGBOUND), ~Sy_bit(OPT_DEGBOUND) }, |
---|
208 | /* 25 no redTail(p)/redTail(s) */ |
---|
209 | {"redTail", Sy_bit(OPT_REDTAIL), ~Sy_bit(OPT_REDTAIL) }, |
---|
210 | {"redThrough", Sy_bit(OPT_REDTHROUGH), ~Sy_bit(OPT_REDTHROUGH) }, |
---|
211 | {"lazy", Sy_bit(OPT_OLDSTD), ~Sy_bit(OPT_OLDSTD) }, |
---|
212 | {"intStrategy", Sy_bit(OPT_INTSTRATEGY), ~Sy_bit(OPT_INTSTRATEGY) }, |
---|
213 | {"infRedTail", Sy_bit(OPT_INFREDTAIL), ~Sy_bit(OPT_INFREDTAIL) }, |
---|
214 | /* 30: use not regularity for syz */ |
---|
215 | {"notRegularity",Sy_bit(OPT_NOTREGULARITY), ~Sy_bit(OPT_NOTREGULARITY) }, |
---|
216 | {"weightM", Sy_bit(OPT_WEIGHTM), ~Sy_bit(OPT_WEIGHTM) }, |
---|
217 | /*special for "none" and also end marker for showOption:*/ |
---|
218 | {"ne", 0, 0 } |
---|
219 | }; |
---|
220 | |
---|
221 | struct soptionStruct verboseStruct[]= |
---|
222 | { |
---|
223 | {"mem", Sy_bit(V_SHOW_MEM), ~Sy_bit(V_SHOW_MEM) }, |
---|
224 | {"yacc", Sy_bit(V_YACC), ~Sy_bit(V_YACC) }, |
---|
225 | {"redefine", Sy_bit(V_REDEFINE), ~Sy_bit(V_REDEFINE) }, |
---|
226 | {"reading", Sy_bit(V_READING), ~Sy_bit(V_READING) }, |
---|
227 | {"loadLib", Sy_bit(V_LOAD_LIB), ~Sy_bit(V_LOAD_LIB) }, |
---|
228 | {"debugLib", Sy_bit(V_DEBUG_LIB), ~Sy_bit(V_DEBUG_LIB) }, |
---|
229 | {"loadProc", Sy_bit(V_LOAD_PROC), ~Sy_bit(V_LOAD_PROC) }, |
---|
230 | {"defRes", Sy_bit(V_DEF_RES), ~Sy_bit(V_DEF_RES) }, |
---|
231 | {"debugMem", Sy_bit(V_DEBUG_MEM), ~Sy_bit(V_DEBUG_MEM) }, |
---|
232 | {"usage", Sy_bit(V_SHOW_USE), ~Sy_bit(V_SHOW_USE) }, |
---|
233 | {"Imap", Sy_bit(V_IMAP), ~Sy_bit(V_IMAP) }, |
---|
234 | {"prompt", Sy_bit(V_PROMPT), ~Sy_bit(V_PROMPT) }, |
---|
235 | {"length", Sy_bit(V_LENGTH), ~Sy_bit(V_LENGTH) }, |
---|
236 | {"notWarnSB",Sy_bit(V_NSB), ~Sy_bit(V_NSB) }, |
---|
237 | {"contentSB",Sy_bit(V_CONTENTSB), ~Sy_bit(V_CONTENTSB) }, |
---|
238 | {"cancelunit",Sy_bit(V_CANCELUNIT),~Sy_bit(V_CANCELUNIT)}, |
---|
239 | {"modpsolve",Sy_bit(V_MODPSOLVSB),~Sy_bit(V_MODPSOLVSB)}, |
---|
240 | {"geometricSB",Sy_bit(V_UPTORADICAL),~Sy_bit(V_UPTORADICAL)}, |
---|
241 | {"findMonomials",Sy_bit(V_FINDMONOM),~Sy_bit(V_FINDMONOM)}, |
---|
242 | {"coefStrat",Sy_bit(V_COEFSTRAT),~Sy_bit(V_COEFSTRAT)}, |
---|
243 | /*special for "none" and also end marker for showOption:*/ |
---|
244 | {"ne", 0, 0 } |
---|
245 | }; |
---|
246 | |
---|
247 | BOOLEAN setOption(leftv res, leftv v) |
---|
248 | { |
---|
249 | const char *n; |
---|
250 | do |
---|
251 | { |
---|
252 | if (v->Typ()==STRING_CMD) |
---|
253 | { |
---|
254 | n=(const char *)v->CopyD(STRING_CMD); |
---|
255 | } |
---|
256 | else |
---|
257 | { |
---|
258 | if (v->name==NULL) |
---|
259 | return TRUE; |
---|
260 | if (v->rtyp==0) |
---|
261 | { |
---|
262 | n=v->name; |
---|
263 | v->name=NULL; |
---|
264 | } |
---|
265 | else |
---|
266 | { |
---|
267 | n=omStrDup(v->name); |
---|
268 | } |
---|
269 | } |
---|
270 | |
---|
271 | int i; |
---|
272 | |
---|
273 | if(strcmp(n,"get")==0) |
---|
274 | { |
---|
275 | intvec *w=new intvec(2); |
---|
276 | (*w)[0]=test; |
---|
277 | (*w)[1]=verbose; |
---|
278 | res->rtyp=INTVEC_CMD; |
---|
279 | res->data=(void *)w; |
---|
280 | goto okay; |
---|
281 | } |
---|
282 | if(strcmp(n,"set")==0) |
---|
283 | { |
---|
284 | if((v->next!=NULL) |
---|
285 | &&(v->next->Typ()==INTVEC_CMD)) |
---|
286 | { |
---|
287 | v=v->next; |
---|
288 | intvec *w=(intvec*)v->Data(); |
---|
289 | test=(*w)[0]; |
---|
290 | verbose=(*w)[1]; |
---|
291 | #if 0 |
---|
292 | if (TEST_OPT_INTSTRATEGY && (currRing!=NULL) |
---|
293 | && rField_has_simple_inverse() |
---|
294 | #ifdef HAVE_RINGS |
---|
295 | && !rField_is_Ring(currRing) |
---|
296 | #endif |
---|
297 | ) { |
---|
298 | test &=~Sy_bit(OPT_INTSTRATEGY); |
---|
299 | } |
---|
300 | #endif |
---|
301 | goto okay; |
---|
302 | } |
---|
303 | } |
---|
304 | if(strcmp(n,"none")==0) |
---|
305 | { |
---|
306 | test=0; |
---|
307 | verbose=0; |
---|
308 | goto okay; |
---|
309 | } |
---|
310 | for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++) |
---|
311 | { |
---|
312 | if (strcmp(n,optionStruct[i].name)==0) |
---|
313 | { |
---|
314 | if (optionStruct[i].setval & validOpts) |
---|
315 | { |
---|
316 | test |= optionStruct[i].setval; |
---|
317 | // optOldStd disables redthrough |
---|
318 | if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD)) |
---|
319 | test &= ~Sy_bit(OPT_REDTHROUGH); |
---|
320 | } |
---|
321 | else |
---|
322 | Warn("cannot set option"); |
---|
323 | #if 0 |
---|
324 | if (TEST_OPT_INTSTRATEGY && (currRing!=NULL) |
---|
325 | && rField_has_simple_inverse() |
---|
326 | #ifdef HAVE_RINGS |
---|
327 | && !rField_is_Ring(currRing) |
---|
328 | #endif |
---|
329 | ) { |
---|
330 | test &=~Sy_bit(OPT_INTSTRATEGY); |
---|
331 | } |
---|
332 | #endif |
---|
333 | goto okay; |
---|
334 | } |
---|
335 | else if ((strncmp(n,"no",2)==0) |
---|
336 | && (strcmp(n+2,optionStruct[i].name)==0)) |
---|
337 | { |
---|
338 | if (optionStruct[i].setval & validOpts) |
---|
339 | { |
---|
340 | test &= optionStruct[i].resetval; |
---|
341 | } |
---|
342 | else |
---|
343 | Warn("cannot clear option"); |
---|
344 | goto okay; |
---|
345 | } |
---|
346 | } |
---|
347 | for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++) |
---|
348 | { |
---|
349 | if (strcmp(n,verboseStruct[i].name)==0) |
---|
350 | { |
---|
351 | verbose |= verboseStruct[i].setval; |
---|
352 | #ifdef YYDEBUG |
---|
353 | #if YYDEBUG |
---|
354 | if (BVERBOSE(V_YACC)) yydebug=1; |
---|
355 | else yydebug=0; |
---|
356 | #endif |
---|
357 | #endif |
---|
358 | goto okay; |
---|
359 | } |
---|
360 | else if ((strncmp(n,"no",2)==0) |
---|
361 | && (strcmp(n+2,verboseStruct[i].name)==0)) |
---|
362 | { |
---|
363 | verbose &= verboseStruct[i].resetval; |
---|
364 | #ifdef YYDEBUG |
---|
365 | #if YYDEBUG |
---|
366 | if (BVERBOSE(V_YACC)) yydebug=1; |
---|
367 | else yydebug=0; |
---|
368 | #endif |
---|
369 | #endif |
---|
370 | goto okay; |
---|
371 | } |
---|
372 | } |
---|
373 | Werror("unknown option `%s`",n); |
---|
374 | okay: |
---|
375 | if (currRing != NULL) |
---|
376 | currRing->options = test & TEST_RINGDEP_OPTS; |
---|
377 | omFree((ADDRESS)n); |
---|
378 | v=v->next; |
---|
379 | } while (v!=NULL); |
---|
380 | #ifdef HAVE_TCL |
---|
381 | if (tclmode) |
---|
382 | { |
---|
383 | BITSET tmp; |
---|
384 | int i; |
---|
385 | StringSetS(""); |
---|
386 | if ((test!=0)||(verbose!=0)) |
---|
387 | { |
---|
388 | tmp=test; |
---|
389 | if(tmp) |
---|
390 | { |
---|
391 | for (i=0; optionStruct[i].setval!=0; i++) |
---|
392 | { |
---|
393 | if (optionStruct[i].setval & test) |
---|
394 | { |
---|
395 | StringAppend(" %s",optionStruct[i].name); |
---|
396 | tmp &=optionStruct[i].resetval; |
---|
397 | } |
---|
398 | } |
---|
399 | } |
---|
400 | tmp=verbose; |
---|
401 | if (tmp) |
---|
402 | { |
---|
403 | for (i=0; verboseStruct[i].setval!=0; i++) |
---|
404 | { |
---|
405 | if (verboseStruct[i].setval & tmp) |
---|
406 | { |
---|
407 | StringAppend(" %s",verboseStruct[i].name); |
---|
408 | tmp &=verboseStruct[i].resetval; |
---|
409 | } |
---|
410 | } |
---|
411 | } |
---|
412 | PrintTCLS('O',StringAppendS("")); |
---|
413 | StringSetS(""); |
---|
414 | } |
---|
415 | else |
---|
416 | { |
---|
417 | PrintTCLS('O'," "); |
---|
418 | } |
---|
419 | } |
---|
420 | #endif |
---|
421 | // set global variable to show memory usage |
---|
422 | if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1; |
---|
423 | else om_sing_opt_show_mem = 0; |
---|
424 | return FALSE; |
---|
425 | } |
---|
426 | |
---|
427 | char * showOption() |
---|
428 | { |
---|
429 | int i; |
---|
430 | BITSET tmp; |
---|
431 | |
---|
432 | StringSetS("//options:"); |
---|
433 | if ((test!=0)||(verbose!=0)) |
---|
434 | { |
---|
435 | tmp=test; |
---|
436 | if(tmp) |
---|
437 | { |
---|
438 | for (i=0; optionStruct[i].setval!=0; i++) |
---|
439 | { |
---|
440 | if (optionStruct[i].setval & test) |
---|
441 | { |
---|
442 | StringAppend(" %s",optionStruct[i].name); |
---|
443 | tmp &=optionStruct[i].resetval; |
---|
444 | } |
---|
445 | } |
---|
446 | for (i=0; i<32; i++) |
---|
447 | { |
---|
448 | if (tmp & Sy_bit(i)) StringAppend(" %d",i); |
---|
449 | } |
---|
450 | } |
---|
451 | tmp=verbose; |
---|
452 | if (tmp) |
---|
453 | { |
---|
454 | for (i=0; verboseStruct[i].setval!=0; i++) |
---|
455 | { |
---|
456 | if (verboseStruct[i].setval & tmp) |
---|
457 | { |
---|
458 | StringAppend(" %s",verboseStruct[i].name); |
---|
459 | tmp &=verboseStruct[i].resetval; |
---|
460 | } |
---|
461 | } |
---|
462 | for (i=1; i<32; i++) |
---|
463 | { |
---|
464 | if (tmp & Sy_bit(i)) StringAppend(" %d",i+32); |
---|
465 | } |
---|
466 | } |
---|
467 | return omStrDup(StringAppendS("")); |
---|
468 | } |
---|
469 | else |
---|
470 | return omStrDup(StringAppendS(" none")); |
---|
471 | } |
---|
472 | |
---|
473 | char * versionString() |
---|
474 | { |
---|
475 | char* str = StringSetS(""); |
---|
476 | StringAppend("Singular for %s version %s (%d-%lu) %s\nwith\n", |
---|
477 | S_UNAME, S_VERSION1, SINGULAR_VERSION, |
---|
478 | feVersionId,singular_date); |
---|
479 | StringAppendS("\t"); |
---|
480 | #ifdef HAVE_FACTORY |
---|
481 | StringAppend("factory(%s),", factoryVersion); |
---|
482 | StringAppend("libfac(%s,%s),\n\t",libfac_version,libfac_date); |
---|
483 | #endif |
---|
484 | #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR) |
---|
485 | StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR); |
---|
486 | #else |
---|
487 | StringAppendS("GMP(1.3),"); |
---|
488 | #endif |
---|
489 | #ifdef HAVE_NTL |
---|
490 | #include "NTL/version.h" |
---|
491 | StringAppend("NTL(%s),",NTL_VERSION); |
---|
492 | #endif |
---|
493 | #ifdef HAVE_MPSR |
---|
494 | StringAppend("MP(%s),",MP_VERSION); |
---|
495 | #endif |
---|
496 | #if SIZEOF_VOIDP == 8 |
---|
497 | StringAppendS("64bit,"); |
---|
498 | #else |
---|
499 | StringAppendS("32bit,"); |
---|
500 | #endif |
---|
501 | #if defined(HAVE_DYN_RL) |
---|
502 | if (fe_fgets_stdin==fe_fgets_dummy) |
---|
503 | StringAppendS("no input,"); |
---|
504 | else if (fe_fgets_stdin==fe_fgets) |
---|
505 | StringAppendS("fgets,"); |
---|
506 | if (fe_fgets_stdin==fe_fgets_stdin_drl) |
---|
507 | StringAppendS("dynamic readline,"); |
---|
508 | #ifdef HAVE_FEREAD |
---|
509 | else if (fe_fgets_stdin==fe_fgets_stdin_emu) |
---|
510 | StringAppendS("emulated readline,"); |
---|
511 | #endif |
---|
512 | else |
---|
513 | StringAppendS("unknown fgets method,"); |
---|
514 | #else |
---|
515 | #if defined(HAVE_READLINE) && !defined(FEREAD) |
---|
516 | StringAppendS("static readline,"); |
---|
517 | #else |
---|
518 | #ifdef HAVE_FEREAD |
---|
519 | StringAppendS("emulated readline,"); |
---|
520 | #else |
---|
521 | StringAppendS("fgets,"); |
---|
522 | #endif |
---|
523 | #endif |
---|
524 | #endif |
---|
525 | #ifdef HAVE_PLURAL |
---|
526 | StringAppendS("Plural,"); |
---|
527 | #endif |
---|
528 | #ifdef HAVE_DBM |
---|
529 | StringAppendS("DBM,\n\t"); |
---|
530 | #else |
---|
531 | StringAppendS("\n\t"); |
---|
532 | #endif |
---|
533 | #ifdef HAVE_DYNAMIC_LOADING |
---|
534 | StringAppendS("dynamic modules,"); |
---|
535 | #endif |
---|
536 | if (p_procs_dynamic) StringAppendS("dynamic p_Procs,"); |
---|
537 | #ifdef TEST |
---|
538 | StringAppendS("TESTs,"); |
---|
539 | #endif |
---|
540 | #if YYDEBUG |
---|
541 | StringAppendS("YYDEBUG=1,"); |
---|
542 | #endif |
---|
543 | #ifdef HAVE_ASSUME |
---|
544 | StringAppendS("ASSUME,"); |
---|
545 | #endif |
---|
546 | #ifdef MDEBUG |
---|
547 | StringAppend("MDEBUG=%d,",MDEBUG); |
---|
548 | #endif |
---|
549 | #ifdef OM_CHECK |
---|
550 | StringAppend("OM_CHECK=%d,",OM_CHECK); |
---|
551 | #endif |
---|
552 | #ifdef OM_TRACK |
---|
553 | StringAppend("OM_TRACK=%d,",OM_TRACK); |
---|
554 | #endif |
---|
555 | #ifdef OM_NDEBUG |
---|
556 | StringAppendS("OM_NDEBUG,"); |
---|
557 | #endif |
---|
558 | #ifdef PDEBUG |
---|
559 | StringAppendS("PDEBUG,"); |
---|
560 | #endif |
---|
561 | #ifdef KDEBUG |
---|
562 | StringAppendS("KDEBUG,"); |
---|
563 | #endif |
---|
564 | #ifndef __OPTIMIZE__ |
---|
565 | StringAppendS("-g,"); |
---|
566 | #endif |
---|
567 | #ifdef HAVE_EIGENVAL |
---|
568 | StringAppendS("eigenvalues,"); |
---|
569 | #endif |
---|
570 | #ifdef HAVE_GMS |
---|
571 | StringAppendS("Gauss-Manin system,"); |
---|
572 | #endif |
---|
573 | #ifdef HAVE_RATGRING |
---|
574 | StringAppendS("ratGB,"); |
---|
575 | #endif |
---|
576 | StringAppend("random=%d\n",siRandomStart); |
---|
577 | StringAppend("\tCC=%s,\n\tCXX=%s" |
---|
578 | #ifdef __GNUC__ |
---|
579 | "(" __VERSION__ ")" |
---|
580 | #endif |
---|
581 | "\n",CC,CXX); |
---|
582 | feStringAppendResources(0); |
---|
583 | feStringAppendBrowsers(0); |
---|
584 | StringAppendS("\n"); |
---|
585 | return str; |
---|
586 | } |
---|
587 | |
---|
588 | #ifdef PDEBUG |
---|
589 | #if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM) |
---|
590 | void p_SetRingOfLeftv(leftv l, ring r) |
---|
591 | { |
---|
592 | switch(l->rtyp) |
---|
593 | { |
---|
594 | case INT_CMD: |
---|
595 | case BIGINT_CMD: |
---|
596 | break; |
---|
597 | case POLY_CMD: |
---|
598 | case VECTOR_CMD: |
---|
599 | { |
---|
600 | poly p=(poly)l->data; |
---|
601 | while(p!=NULL) { p_SetRingOfLm(p,r); pIter(p); } |
---|
602 | break; |
---|
603 | } |
---|
604 | case IDEAL_CMD: |
---|
605 | case MODUL_CMD: |
---|
606 | case MATRIX_CMD: |
---|
607 | { |
---|
608 | ideal I=(ideal)l->data; |
---|
609 | int i; |
---|
610 | for(i=IDELEMS(I)-1;i>=0;i--) |
---|
611 | { |
---|
612 | poly p=I->m[i]; |
---|
613 | while(p!=NULL) { p_SetRingOfLm(p,r); pIter(p); } |
---|
614 | } |
---|
615 | break; |
---|
616 | } |
---|
617 | case COMMAND: |
---|
618 | { |
---|
619 | command d=(command)l->data; |
---|
620 | p_SetRingOfLeftv(&d->arg1, r); |
---|
621 | if (d->argc>1) p_SetRingOfLeftv(&d->arg2, r); |
---|
622 | if (d->argc>2) p_SetRingOfLeftv(&d->arg3, r); |
---|
623 | break; |
---|
624 | } |
---|
625 | default: |
---|
626 | printf("type %d not yet implementd in p_SetRingOfLeftv\n",l->rtyp); |
---|
627 | break; |
---|
628 | } |
---|
629 | } |
---|
630 | #endif |
---|
631 | #endif |
---|
632 | |
---|
633 | void listall(int showproc) |
---|
634 | { |
---|
635 | idhdl hh=basePack->idroot; |
---|
636 | PrintS("====== Top ==============\n"); |
---|
637 | while (hh!=NULL) |
---|
638 | { |
---|
639 | if (showproc || (IDTYP(hh)!=PROC_CMD)) |
---|
640 | { |
---|
641 | if (IDDATA(hh)==(void *)currRing) PrintS("(R)"); |
---|
642 | else if (IDDATA(hh)==(void *)currPack) PrintS("(P)"); |
---|
643 | else PrintS(" "); |
---|
644 | Print("::%s, typ %s level %d data %lx", |
---|
645 | IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),(long)IDDATA(hh)); |
---|
646 | if ((IDTYP(hh)==RING_CMD) |
---|
647 | || (IDTYP(hh)==QRING_CMD)) |
---|
648 | Print(" ref: %d\n",IDRING(hh)->ref); |
---|
649 | else |
---|
650 | PrintLn(); |
---|
651 | } |
---|
652 | hh=IDNEXT(hh); |
---|
653 | } |
---|
654 | hh=basePack->idroot; |
---|
655 | while (hh!=NULL) |
---|
656 | { |
---|
657 | if (IDDATA(hh)==(void *)basePack) |
---|
658 | Print("(T)::%s, typ %s level %d data %lx\n", |
---|
659 | IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),(long)IDDATA(hh)); |
---|
660 | else |
---|
661 | if ((IDTYP(hh)==RING_CMD) |
---|
662 | || (IDTYP(hh)==QRING_CMD) |
---|
663 | || (IDTYP(hh)==PACKAGE_CMD)) |
---|
664 | { |
---|
665 | Print("====== %s ==============\n",IDID(hh)); |
---|
666 | idhdl h2=IDRING(hh)->idroot; |
---|
667 | while (h2!=NULL) |
---|
668 | { |
---|
669 | if (showproc || (IDTYP(h2)!=PROC_CMD)) |
---|
670 | { |
---|
671 | if ((IDDATA(h2)==(void *)currRing) |
---|
672 | && ((IDTYP(h2)==RING_CMD)||(IDTYP(h2)==QRING_CMD))) |
---|
673 | PrintS("(R)"); |
---|
674 | else if (IDDATA(h2)==(void *)currPack) PrintS("(P)"); |
---|
675 | else PrintS(" "); |
---|
676 | Print("%s::%s, typ %s level %d data %lx\n", |
---|
677 | IDID(hh),IDID(h2),Tok2Cmdname(IDTYP(h2)),IDLEV(h2),(long)IDDATA(h2)); |
---|
678 | } |
---|
679 | h2=IDNEXT(h2); |
---|
680 | } |
---|
681 | } |
---|
682 | hh=IDNEXT(hh); |
---|
683 | } |
---|
684 | Print("currRing:%lx, currPack:%lx,basePack:%lx\n",(long)currRing,(long)currPack,(long)basePack); |
---|
685 | iiCheckPack(currPack); |
---|
686 | } |
---|
687 | #ifndef NDEBUG |
---|
688 | void checkall() |
---|
689 | { |
---|
690 | idhdl hh=basePack->idroot; |
---|
691 | while (hh!=NULL) |
---|
692 | { |
---|
693 | omCheckAddr(hh); |
---|
694 | omCheckAddr((ADDRESS)IDID(hh)); |
---|
695 | if (RingDependend(IDTYP(hh))) Print("%s typ %d in Top\n",IDID(hh),IDTYP(hh)); |
---|
696 | hh=IDNEXT(hh); |
---|
697 | } |
---|
698 | hh=basePack->idroot; |
---|
699 | while (hh!=NULL) |
---|
700 | { |
---|
701 | if (IDTYP(hh)==PACKAGE_CMD) |
---|
702 | { |
---|
703 | idhdl h2=IDPACKAGE(hh)->idroot; |
---|
704 | while (h2!=NULL) |
---|
705 | { |
---|
706 | omCheckAddr(h2); |
---|
707 | omCheckAddr((ADDRESS)IDID(h2)); |
---|
708 | if (RingDependend(IDTYP(h2))) Print("%s typ %d in %s\n",IDID(h2),IDTYP(h2),IDID(hh)); |
---|
709 | h2=IDNEXT(h2); |
---|
710 | } |
---|
711 | } |
---|
712 | hh=IDNEXT(hh); |
---|
713 | } |
---|
714 | } |
---|
715 | #endif |
---|
716 | |
---|
717 | #include <sys/types.h> |
---|
718 | #include <sys/stat.h> |
---|
719 | #include <unistd.h> |
---|
720 | |
---|
721 | extern "C" |
---|
722 | int singular_fstat(int fd, struct stat *buf) |
---|
723 | { |
---|
724 | return fstat(fd,buf); |
---|
725 | } |
---|
726 | |
---|