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 | #include "version.h" |
---|
33 | |
---|
34 | #include "static.h" |
---|
35 | #ifdef HAVE_STATIC |
---|
36 | #undef HAVE_DYN_RL |
---|
37 | #endif |
---|
38 | |
---|
39 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
40 | |
---|
41 | //#ifdef HAVE_LIBPARSER |
---|
42 | //# include "libparse.h" |
---|
43 | //#endif /* HAVE_LIBPARSER */ |
---|
44 | |
---|
45 | #ifdef HAVE_FACTORY |
---|
46 | #include <factory.h> |
---|
47 | #endif |
---|
48 | |
---|
49 | /* version strings */ |
---|
50 | #ifdef HAVE_LIBFAC_P |
---|
51 | extern const char * libfac_version; |
---|
52 | extern const char * libfac_date; |
---|
53 | #endif |
---|
54 | extern "C" { |
---|
55 | #include <gmp.h> |
---|
56 | } |
---|
57 | #ifdef HAVE_MPSR |
---|
58 | #include <MP_Config.h> |
---|
59 | #endif |
---|
60 | |
---|
61 | /* init bins from structs.h */ |
---|
62 | |
---|
63 | omBin MP_INT_bin = omGetSpecBin(sizeof(MP_INT)); |
---|
64 | omBin char_ptr_bin = omGetSpecBin(sizeof(char_ptr)); |
---|
65 | omBin ideal_bin = omGetSpecBin(sizeof(ideal)); |
---|
66 | omBin int_bin = omGetSpecBin(sizeof(int)); |
---|
67 | omBin poly_bin = omGetSpecBin(sizeof(poly)); |
---|
68 | omBin void_ptr_bin = omGetSpecBin(sizeof(void_ptr)); |
---|
69 | omBin indlist_bin = omGetSpecBin(sizeof(indlist)); |
---|
70 | omBin naIdeal_bin = omGetSpecBin(sizeof(naIdeal)); |
---|
71 | omBin snaIdeal_bin = omGetSpecBin(sizeof(snaIdeal)); |
---|
72 | omBin sm_prec_bin = omGetSpecBin(sizeof(sm_prec)); |
---|
73 | omBin smprec_bin = omGetSpecBin(sizeof(smprec)); |
---|
74 | omBin sip_sideal_bin = omGetSpecBin(sizeof(sip_sideal)); |
---|
75 | omBin sip_smap_bin = omGetSpecBin(sizeof(sip_smap)); |
---|
76 | omBin sip_sring_bin = omGetSpecBin(sizeof(sip_sring)); |
---|
77 | omBin ip_sideal_bin = omGetSpecBin(sizeof(ip_sideal)); |
---|
78 | omBin ip_smap_bin = omGetSpecBin(sizeof(ip_smap)); |
---|
79 | omBin ip_sring_bin = omGetSpecBin(sizeof(ip_sring)); |
---|
80 | |
---|
81 | /*0 implementation*/ |
---|
82 | |
---|
83 | /*2 |
---|
84 | * initialize components of Singular |
---|
85 | */ |
---|
86 | int inits(void) |
---|
87 | { |
---|
88 | int t; |
---|
89 | /*4 signal handler:*/ |
---|
90 | init_signals(); |
---|
91 | /*4 randomize: */ |
---|
92 | t=initTimer(); |
---|
93 | /*t=(int)time(NULL);*/ |
---|
94 | if (t==0) t=1; |
---|
95 | #ifdef HAVE_RTIMER |
---|
96 | initRTimer(); |
---|
97 | #endif |
---|
98 | #ifdef buildin_rand |
---|
99 | siSeed=t; |
---|
100 | #else |
---|
101 | srand((unsigned int)t); |
---|
102 | #endif |
---|
103 | #ifdef HAVE_FACTORY |
---|
104 | factoryseed(t); |
---|
105 | #endif |
---|
106 | /*4 private data of other modules*/ |
---|
107 | memset(&sLastPrinted,0,sizeof(sleftv)); |
---|
108 | sLastPrinted.rtyp=NONE; |
---|
109 | return t; |
---|
110 | } |
---|
111 | |
---|
112 | /*2 |
---|
113 | * the global exit routine of Singular |
---|
114 | */ |
---|
115 | extern "C" { |
---|
116 | void m2_end(short i) |
---|
117 | { |
---|
118 | fe_reset_input_mode(); |
---|
119 | #ifdef PAGE_TEST |
---|
120 | mmEndStat(); |
---|
121 | #endif |
---|
122 | #ifdef HAVE_TCL |
---|
123 | if (tclmode) |
---|
124 | { |
---|
125 | PrintTCL('Q',0,NULL); |
---|
126 | } |
---|
127 | #endif |
---|
128 | fe_reset_input_mode(); |
---|
129 | if (i<=0) |
---|
130 | { |
---|
131 | #ifdef HAVE_TCL |
---|
132 | if (!tclmode) |
---|
133 | #endif |
---|
134 | if (BVERBOSE(0)) |
---|
135 | { |
---|
136 | if (i==0) |
---|
137 | printf("Auf Wiedersehen.\n"); |
---|
138 | else |
---|
139 | printf("\n$Bye.\n"); |
---|
140 | } |
---|
141 | #ifdef sun |
---|
142 | #ifndef __svr4__ |
---|
143 | _cleanup(); |
---|
144 | _exit(0); |
---|
145 | #endif |
---|
146 | #endif |
---|
147 | exit(0); |
---|
148 | } |
---|
149 | else |
---|
150 | { |
---|
151 | #ifdef HAVE_TCL |
---|
152 | if (!tclmode) |
---|
153 | #endif |
---|
154 | printf("\nhalt %d\n",i); |
---|
155 | } |
---|
156 | exit(i); |
---|
157 | } |
---|
158 | } |
---|
159 | |
---|
160 | /*2 |
---|
161 | * the renice routine for very large jobs |
---|
162 | * works only on unix machines, |
---|
163 | * testet on : linux, HP 9.0 |
---|
164 | * |
---|
165 | *#ifndef MSDOS |
---|
166 | *#ifndef macintosh |
---|
167 | *#include <sys/times.h> |
---|
168 | *#include <sys/resource.h> |
---|
169 | *extern "C" int setpriority(int,int,int); |
---|
170 | *void very_nice() |
---|
171 | *{ |
---|
172 | *#ifndef NO_SETPRIORITY |
---|
173 | * setpriority(PRIO_PROCESS,0,19); |
---|
174 | *#endif |
---|
175 | * sleep(10); |
---|
176 | *} |
---|
177 | *#else |
---|
178 | *void very_nice(){} |
---|
179 | *#endif |
---|
180 | *#else |
---|
181 | *void very_nice(){} |
---|
182 | *#endif |
---|
183 | */ |
---|
184 | |
---|
185 | /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
---|
186 | #ifdef buildin_rand |
---|
187 | /* |
---|
188 | * |
---|
189 | * A prime modulus multiplicative linear congruential |
---|
190 | * generator (PMMLCG), or "Lehmer generator". |
---|
191 | * Implementation directly derived from the article: |
---|
192 | * |
---|
193 | * S. K. Park and K. W. Miller |
---|
194 | * Random Number Generators: Good Ones are Hard to Find |
---|
195 | * CACM vol 31, #10. Oct. 1988. pp 1192-1201. |
---|
196 | * |
---|
197 | * Using the following multiplier and modulus, we obtain a |
---|
198 | * generator which: |
---|
199 | * |
---|
200 | * 1) Has a full period: 1 to 2^31 - 2. |
---|
201 | * 2) Is testably "random" (see the article). |
---|
202 | * 3) Has a known implementation by E. L. Schrage. |
---|
203 | */ |
---|
204 | |
---|
205 | |
---|
206 | #define A 16807L /* A "good" multiplier */ |
---|
207 | #define M 2147483647L /* Modulus: 2^31 - 1 */ |
---|
208 | #define Q 127773L /* M / A */ |
---|
209 | #define R 2836L /* M % A */ |
---|
210 | |
---|
211 | |
---|
212 | int siSeed = 1L; |
---|
213 | |
---|
214 | |
---|
215 | int siRand() |
---|
216 | { |
---|
217 | siSeed = A * (siSeed % Q) - R * (siSeed / Q); |
---|
218 | |
---|
219 | if ( siSeed < 0 ) |
---|
220 | siSeed += M; |
---|
221 | |
---|
222 | return( siSeed ); |
---|
223 | } |
---|
224 | #endif |
---|
225 | |
---|
226 | void singular_example(char *str) |
---|
227 | { |
---|
228 | char *s=str; |
---|
229 | while (*s==' ') s++; |
---|
230 | char *ss=s; |
---|
231 | while (*ss!='\0') ss++; |
---|
232 | while (*ss<=' ') |
---|
233 | { |
---|
234 | *ss='\0'; |
---|
235 | ss--; |
---|
236 | } |
---|
237 | #ifdef HAVE_NAMESPACES |
---|
238 | idhdl h, ns; |
---|
239 | iiname2hdl(s, &ns, &h); |
---|
240 | #else /* HAVE_NAMESPACES */ |
---|
241 | idhdl h=IDROOT->get(s,myynest); |
---|
242 | #endif /* HAVE_NAMESPACES */ |
---|
243 | if ((h!=NULL) && (IDTYP(h)==PROC_CMD)) |
---|
244 | { |
---|
245 | char *lib=iiGetLibName(IDPROC(h)); |
---|
246 | if((lib!=NULL)&&(*lib!='\0')) |
---|
247 | { |
---|
248 | Print("// proc %s from lib %s\n",s,lib); |
---|
249 | s=iiGetLibProcBuffer(IDPROC(h), 2); |
---|
250 | if (s!=NULL) |
---|
251 | { |
---|
252 | if (strlen(s)>5) |
---|
253 | { |
---|
254 | iiEStart(s,IDPROC(h)); |
---|
255 | return; |
---|
256 | } |
---|
257 | else omFree((ADDRESS)s); |
---|
258 | } |
---|
259 | } |
---|
260 | } |
---|
261 | else |
---|
262 | { |
---|
263 | char sing_file[MAXPATHLEN]; |
---|
264 | FILE *fd; |
---|
265 | sprintf(sing_file, "%s/%s.sing", feResource('m', 0), s); |
---|
266 | fd = feFopen(sing_file, "r"); |
---|
267 | if (fd != NULL) |
---|
268 | { |
---|
269 | |
---|
270 | int old_echo = si_echo; |
---|
271 | int length, got; |
---|
272 | char* s; |
---|
273 | |
---|
274 | fseek(fd, 0, SEEK_END); |
---|
275 | length = ftell(fd); |
---|
276 | fseek(fd, 0, SEEK_SET); |
---|
277 | s = (char*) omAlloc((length+20)*sizeof(char)); |
---|
278 | got = fread(s, sizeof(char), length, fd); |
---|
279 | fclose(fd); |
---|
280 | if (got != length) |
---|
281 | { |
---|
282 | Werror("Error while reading file %s", sing_file); |
---|
283 | omFree(s); |
---|
284 | } |
---|
285 | else |
---|
286 | { |
---|
287 | s[length] = '\0'; |
---|
288 | strcat(s, "\n;return();\n\n"); |
---|
289 | si_echo = 2; |
---|
290 | iiEStart(s, NULL); |
---|
291 | si_echo = old_echo; |
---|
292 | } |
---|
293 | } |
---|
294 | else |
---|
295 | { |
---|
296 | Werror("no example for %s", str); |
---|
297 | } |
---|
298 | } |
---|
299 | } |
---|
300 | |
---|
301 | |
---|
302 | struct soptionStruct |
---|
303 | { |
---|
304 | char * name; |
---|
305 | unsigned setval; |
---|
306 | unsigned resetval; |
---|
307 | }; |
---|
308 | |
---|
309 | struct soptionStruct optionStruct[]= |
---|
310 | { |
---|
311 | {"prot", Sy_bit(OPT_PROT), ~Sy_bit(OPT_PROT) }, |
---|
312 | {"redSB", Sy_bit(OPT_REDSB), ~Sy_bit(OPT_REDSB) }, |
---|
313 | {"notBuckets", Sy_bit(OPT_NOT_BUCKETS), ~Sy_bit(OPT_NOT_BUCKETS) }, |
---|
314 | {"notSugar", Sy_bit(OPT_NOT_SUGAR), ~Sy_bit(OPT_NOT_SUGAR) }, |
---|
315 | {"interrupt", Sy_bit(OPT_INTERRUPT), ~Sy_bit(OPT_INTERRUPT) }, |
---|
316 | {"sugarCrit", Sy_bit(OPT_SUGARCRIT), ~Sy_bit(OPT_SUGARCRIT) }, |
---|
317 | {"teach", Sy_bit(OPT_DEBUG), ~Sy_bit(OPT_DEBUG) }, |
---|
318 | /* 9 return SB in syz, quotient, intersect */ |
---|
319 | {"returnSB", Sy_bit(OPT_RETURN_SB), ~Sy_bit(OPT_RETURN_SB) }, |
---|
320 | {"fastHC", Sy_bit(OPT_FASTHC), ~Sy_bit(OPT_FASTHC) }, |
---|
321 | /* 11-19 sort in L/T */ |
---|
322 | {"keepvars", Sy_bit(OPT_KEEPVARS), ~Sy_bit(OPT_KEEPVARS) }, |
---|
323 | {"staircaseBound",Sy_bit(OPT_STAIRCASEBOUND),~Sy_bit(OPT_STAIRCASEBOUND) }, |
---|
324 | {"multBound", Sy_bit(OPT_MULTBOUND), ~Sy_bit(OPT_MULTBOUND) }, |
---|
325 | {"degBound", Sy_bit(OPT_DEGBOUND), ~Sy_bit(OPT_DEGBOUND) }, |
---|
326 | /* 25 no redTail(p)/redTail(s) */ |
---|
327 | {"redTail", Sy_bit(OPT_REDTAIL), ~Sy_bit(OPT_REDTAIL) }, |
---|
328 | {"redThrough", Sy_bit(OPT_REDTHROUGH), ~Sy_bit(OPT_REDTHROUGH) }, |
---|
329 | {"lazy", Sy_bit(OPT_OLDSTD), ~Sy_bit(OPT_OLDSTD) }, |
---|
330 | {"intStrategy", Sy_bit(OPT_INTSTRATEGY), ~Sy_bit(OPT_INTSTRATEGY) }, |
---|
331 | {"infRedTail", Sy_bit(OPT_INFREDTAIL), ~Sy_bit(OPT_INFREDTAIL) }, |
---|
332 | /* 30: use not regularity for syz */ |
---|
333 | {"notRegularity",Sy_bit(OPT_NOTREGULARITY), ~Sy_bit(OPT_NOTREGULARITY) }, |
---|
334 | {"weightM", Sy_bit(OPT_WEIGHTM), ~Sy_bit(OPT_WEIGHTM) }, |
---|
335 | /*special for "none" and also end marker for showOption:*/ |
---|
336 | {"ne", 0, 0 } |
---|
337 | }; |
---|
338 | |
---|
339 | struct soptionStruct verboseStruct[]= |
---|
340 | { |
---|
341 | {"mem", Sy_bit(V_SHOW_MEM), ~Sy_bit(V_SHOW_MEM) }, |
---|
342 | {"yacc", Sy_bit(V_YACC), ~Sy_bit(V_YACC) }, |
---|
343 | {"redefine", Sy_bit(V_REDEFINE), ~Sy_bit(V_REDEFINE) }, |
---|
344 | {"reading", Sy_bit(V_READING), ~Sy_bit(V_READING) }, |
---|
345 | {"loadLib", Sy_bit(V_LOAD_LIB), ~Sy_bit(V_LOAD_LIB) }, |
---|
346 | {"debugLib", Sy_bit(V_DEBUG_LIB), ~Sy_bit(V_DEBUG_LIB) }, |
---|
347 | {"loadProc", Sy_bit(V_LOAD_PROC), ~Sy_bit(V_LOAD_PROC) }, |
---|
348 | {"defRes", Sy_bit(V_DEF_RES), ~Sy_bit(V_DEF_RES) }, |
---|
349 | {"debugMem", Sy_bit(V_DEBUG_MEM), ~Sy_bit(V_DEBUG_MEM) }, |
---|
350 | {"usage", Sy_bit(V_SHOW_USE), ~Sy_bit(V_SHOW_USE) }, |
---|
351 | {"Imap", Sy_bit(V_IMAP), ~Sy_bit(V_IMAP) }, |
---|
352 | {"prompt", Sy_bit(V_PROMPT), ~Sy_bit(V_PROMPT) }, |
---|
353 | {"notWarnSB",Sy_bit(V_NSB), ~Sy_bit(V_NSB) }, |
---|
354 | {"contentSB",Sy_bit(V_CONTENTSB), ~Sy_bit(V_CONTENTSB) }, |
---|
355 | /*special for "none" and also end marker for showOption:*/ |
---|
356 | {"ne", 0, 0 } |
---|
357 | }; |
---|
358 | |
---|
359 | BOOLEAN setOption(leftv res, leftv v) |
---|
360 | { |
---|
361 | char *n; |
---|
362 | do |
---|
363 | { |
---|
364 | if (v->Typ()==STRING_CMD) |
---|
365 | { |
---|
366 | n=(char *)v->CopyD(STRING_CMD); |
---|
367 | } |
---|
368 | else |
---|
369 | { |
---|
370 | if (v->name==NULL) |
---|
371 | return TRUE; |
---|
372 | if (v->rtyp==0) |
---|
373 | { |
---|
374 | n=v->name; |
---|
375 | v->name=NULL; |
---|
376 | } |
---|
377 | else |
---|
378 | { |
---|
379 | n=omStrDup(v->name); |
---|
380 | } |
---|
381 | } |
---|
382 | |
---|
383 | int i; |
---|
384 | |
---|
385 | if(strcmp(n,"get")==0) |
---|
386 | { |
---|
387 | intvec *w=new intvec(2); |
---|
388 | (*w)[0]=test; |
---|
389 | (*w)[1]=verbose; |
---|
390 | res->rtyp=INTVEC_CMD; |
---|
391 | res->data=(void *)w; |
---|
392 | goto okay; |
---|
393 | } |
---|
394 | if(strcmp(n,"set")==0) |
---|
395 | { |
---|
396 | if((v->next!=NULL) |
---|
397 | &&(v->next->Typ()==INTVEC_CMD)) |
---|
398 | { |
---|
399 | v=v->next; |
---|
400 | intvec *w=(intvec*)v->Data(); |
---|
401 | test=(*w)[0]; |
---|
402 | verbose=(*w)[1]; |
---|
403 | |
---|
404 | if (TEST_OPT_INTSTRATEGY && (currRing!=NULL) |
---|
405 | && rField_has_simple_inverse()) |
---|
406 | { |
---|
407 | test &=~Sy_bit(OPT_INTSTRATEGY); |
---|
408 | } |
---|
409 | goto okay; |
---|
410 | } |
---|
411 | } |
---|
412 | if(strcmp(n,"none")==0) |
---|
413 | { |
---|
414 | test=0; |
---|
415 | verbose=0; |
---|
416 | goto okay; |
---|
417 | } |
---|
418 | for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++) |
---|
419 | { |
---|
420 | if (strcmp(n,optionStruct[i].name)==0) |
---|
421 | { |
---|
422 | if (optionStruct[i].setval & validOpts) |
---|
423 | { |
---|
424 | test |= optionStruct[i].setval; |
---|
425 | // optOldStd disables redthrough |
---|
426 | if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD)) |
---|
427 | test &= ~Sy_bit(OPT_REDTHROUGH); |
---|
428 | } |
---|
429 | else |
---|
430 | Warn("cannot set option"); |
---|
431 | if (TEST_OPT_INTSTRATEGY && (currRing!=NULL) |
---|
432 | && rField_has_simple_inverse()) |
---|
433 | { |
---|
434 | test &=~Sy_bit(OPT_INTSTRATEGY); |
---|
435 | } |
---|
436 | goto okay; |
---|
437 | } |
---|
438 | else if ((strncmp(n,"no",2)==0) |
---|
439 | && (strcmp(n+2,optionStruct[i].name)==0)) |
---|
440 | { |
---|
441 | if (optionStruct[i].setval & validOpts) |
---|
442 | { |
---|
443 | test &= optionStruct[i].resetval; |
---|
444 | } |
---|
445 | else |
---|
446 | Warn("cannot clear option"); |
---|
447 | goto okay; |
---|
448 | } |
---|
449 | } |
---|
450 | for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++) |
---|
451 | { |
---|
452 | if (strcmp(n,verboseStruct[i].name)==0) |
---|
453 | { |
---|
454 | verbose |= verboseStruct[i].setval; |
---|
455 | #ifdef YYDEBUG |
---|
456 | #if YYDEBUG |
---|
457 | if (BVERBOSE(V_YACC)) yydebug=1; |
---|
458 | else yydebug=0; |
---|
459 | #endif |
---|
460 | #endif |
---|
461 | goto okay; |
---|
462 | } |
---|
463 | else if ((strncmp(n,"no",2)==0) |
---|
464 | && (strcmp(n+2,verboseStruct[i].name)==0)) |
---|
465 | { |
---|
466 | verbose &= verboseStruct[i].resetval; |
---|
467 | #ifdef YYDEBUG |
---|
468 | #if YYDEBUG |
---|
469 | if (BVERBOSE(V_YACC)) yydebug=1; |
---|
470 | else yydebug=0; |
---|
471 | #endif |
---|
472 | #endif |
---|
473 | goto okay; |
---|
474 | } |
---|
475 | } |
---|
476 | Werror("unknown option `%s`",n); |
---|
477 | okay: |
---|
478 | if (currRing != NULL) |
---|
479 | currRing->options = test & TEST_RINGDEP_OPTS; |
---|
480 | omFree((ADDRESS)n); |
---|
481 | v=v->next; |
---|
482 | } while (v!=NULL); |
---|
483 | #ifdef HAVE_TCL |
---|
484 | if (tclmode) |
---|
485 | { |
---|
486 | BITSET tmp; |
---|
487 | int i; |
---|
488 | StringSetS(""); |
---|
489 | if ((test!=0)||(verbose!=0)) |
---|
490 | { |
---|
491 | tmp=test; |
---|
492 | if(tmp) |
---|
493 | { |
---|
494 | for (i=0; optionStruct[i].setval!=0; i++) |
---|
495 | { |
---|
496 | if (optionStruct[i].setval & test) |
---|
497 | { |
---|
498 | StringAppend(" %s",optionStruct[i].name); |
---|
499 | tmp &=optionStruct[i].resetval; |
---|
500 | } |
---|
501 | } |
---|
502 | } |
---|
503 | tmp=verbose; |
---|
504 | if (tmp) |
---|
505 | { |
---|
506 | for (i=0; verboseStruct[i].setval!=0; i++) |
---|
507 | { |
---|
508 | if (verboseStruct[i].setval & tmp) |
---|
509 | { |
---|
510 | StringAppend(" %s",verboseStruct[i].name); |
---|
511 | tmp &=verboseStruct[i].resetval; |
---|
512 | } |
---|
513 | } |
---|
514 | } |
---|
515 | PrintTCLS('O',StringAppendS("")); |
---|
516 | StringSetS(""); |
---|
517 | } |
---|
518 | else |
---|
519 | { |
---|
520 | PrintTCLS('O'," "); |
---|
521 | } |
---|
522 | } |
---|
523 | #endif |
---|
524 | // set global variable to show memory usage |
---|
525 | if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1; |
---|
526 | else om_sing_opt_show_mem = 0; |
---|
527 | return FALSE; |
---|
528 | } |
---|
529 | |
---|
530 | char * showOption() |
---|
531 | { |
---|
532 | int i; |
---|
533 | BITSET tmp; |
---|
534 | |
---|
535 | StringSetS("//options:"); |
---|
536 | if ((test!=0)||(verbose!=0)) |
---|
537 | { |
---|
538 | tmp=test; |
---|
539 | if(tmp) |
---|
540 | { |
---|
541 | for (i=0; optionStruct[i].setval!=0; i++) |
---|
542 | { |
---|
543 | if (optionStruct[i].setval & test) |
---|
544 | { |
---|
545 | StringAppend(" %s",optionStruct[i].name); |
---|
546 | tmp &=optionStruct[i].resetval; |
---|
547 | } |
---|
548 | } |
---|
549 | for (i=0; i<32; i++) |
---|
550 | { |
---|
551 | if (tmp & Sy_bit(i)) StringAppend(" %d",i); |
---|
552 | } |
---|
553 | } |
---|
554 | tmp=verbose; |
---|
555 | if (tmp) |
---|
556 | { |
---|
557 | for (i=0; verboseStruct[i].setval!=0; i++) |
---|
558 | { |
---|
559 | if (verboseStruct[i].setval & tmp) |
---|
560 | { |
---|
561 | StringAppend(" %s",verboseStruct[i].name); |
---|
562 | tmp &=verboseStruct[i].resetval; |
---|
563 | } |
---|
564 | } |
---|
565 | for (i=1; i<32; i++) |
---|
566 | { |
---|
567 | if (tmp & Sy_bit(i)) StringAppend(" %d",i+32); |
---|
568 | } |
---|
569 | } |
---|
570 | return omStrDup(StringAppendS("")); |
---|
571 | } |
---|
572 | else |
---|
573 | return omStrDup(StringAppendS(" none")); |
---|
574 | } |
---|
575 | |
---|
576 | char * versionString() |
---|
577 | { |
---|
578 | char* str = StringSetS(""); |
---|
579 | StringAppend("Singular for %s version %s (%lu) %s\nwith\n", |
---|
580 | S_UNAME, S_VERSION1, |
---|
581 | feVersionId,singular_date); |
---|
582 | StringAppend("\t"); |
---|
583 | #ifdef HAVE_FACTORY |
---|
584 | StringAppend("factory(%s),", factoryVersion); |
---|
585 | #endif |
---|
586 | #ifdef HAVE_LIBFAC_P |
---|
587 | StringAppend("libfac(%s,%s),\n\t",libfac_version,libfac_date); |
---|
588 | #endif |
---|
589 | #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR) |
---|
590 | StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR); |
---|
591 | #elif defined (HAVE_SMALLGMP) |
---|
592 | StringAppendS("SmallGMP(2.0.2.0),"); |
---|
593 | #else |
---|
594 | StringAppendS("GMP(1.3),"); |
---|
595 | #endif |
---|
596 | #ifdef HAVE_MPSR |
---|
597 | StringAppend("MP(%s),",MP_VERSION); |
---|
598 | #endif |
---|
599 | #if defined(HAVE_DYN_RL) |
---|
600 | if (fe_fgets_stdin==fe_fgets_dummy) |
---|
601 | StringAppendS("no input,"); |
---|
602 | else if (fe_fgets_stdin==fe_fgets) |
---|
603 | StringAppendS("fgets,"); |
---|
604 | if (fe_fgets_stdin==fe_fgets_stdin_drl) |
---|
605 | StringAppendS("dynamic readline,"); |
---|
606 | else if (fe_fgets_stdin==fe_fgets_stdin_emu) |
---|
607 | StringAppendS("emulated readline,"); |
---|
608 | else |
---|
609 | StringAppendS("unknown fgets method,"); |
---|
610 | #else |
---|
611 | #if defined(HAVE_READLINE) && !defined(FEREAD) |
---|
612 | StringAppendS("static readline,"); |
---|
613 | #else |
---|
614 | #ifdef HAVE_FEREAD |
---|
615 | StringAppendS("emulated readline,"); |
---|
616 | #else |
---|
617 | StringAppendS("fgets,"); |
---|
618 | #endif |
---|
619 | #endif |
---|
620 | #endif |
---|
621 | #ifdef SRING |
---|
622 | StringAppendS("super algebra,"); |
---|
623 | #endif |
---|
624 | #ifdef DRING |
---|
625 | StringAppendS("Weyl algebra,"); |
---|
626 | #endif |
---|
627 | #ifdef HAVE_DBM |
---|
628 | StringAppendS("DBM,\n\t"); |
---|
629 | #else |
---|
630 | StringAppendS("\n\t"); |
---|
631 | #endif |
---|
632 | #ifdef HAVE_NAMESPACES |
---|
633 | StringAppendS("Namespaces,"); |
---|
634 | #endif |
---|
635 | #ifdef HAVE_NS |
---|
636 | StringAppendS("namespaces,"); |
---|
637 | #endif |
---|
638 | #ifdef HAVE_DYNAMIC_LOADING |
---|
639 | StringAppendS("dynamic modules,"); |
---|
640 | #endif |
---|
641 | if (p_procs_dynamic) StringAppendS("dynamic p_Procs,"); |
---|
642 | #ifdef TEST |
---|
643 | StringAppendS("TESTs,"); |
---|
644 | #endif |
---|
645 | #if YYDEBUG |
---|
646 | StringAppendS("YYDEBUG=1,"); |
---|
647 | #endif |
---|
648 | #ifdef HAVE_ASSUME |
---|
649 | StringAppendS("ASSUME,"); |
---|
650 | #endif |
---|
651 | #ifdef MDEBUG |
---|
652 | StringAppend("MDEBUG=%d,",MDEBUG); |
---|
653 | #endif |
---|
654 | #ifdef OM_CHECK |
---|
655 | StringAppend("OM_CHECK=%d,",OM_CHECK); |
---|
656 | #endif |
---|
657 | #ifdef OM_TRACK |
---|
658 | StringAppend("OM_TRACK=%d,",OM_TRACK); |
---|
659 | #endif |
---|
660 | #ifdef OM_NDEBUG |
---|
661 | StringAppend("OM_NDEBUG,"); |
---|
662 | #endif |
---|
663 | #ifdef PDEBUG |
---|
664 | StringAppendS("PDEBUG,"); |
---|
665 | #endif |
---|
666 | #ifdef KDEBUG |
---|
667 | StringAppendS("KDEBUG,"); |
---|
668 | #endif |
---|
669 | #ifndef __OPTIMIZE__ |
---|
670 | #ifdef __MWERKS__ |
---|
671 | StringAppendS(" Codewarrior 2.0,"); |
---|
672 | #else |
---|
673 | StringAppendS("-g,"); |
---|
674 | #endif |
---|
675 | #endif |
---|
676 | #ifdef HAVE_EIGENVAL |
---|
677 | StringAppendS("eigenvalues,"); |
---|
678 | #endif |
---|
679 | #ifdef HAVE_GMS |
---|
680 | StringAppendS("Gauss-Manin system,"); |
---|
681 | #endif |
---|
682 | StringAppend("random=%d\n",siRandomStart); |
---|
683 | |
---|
684 | feStringAppendResources(0); |
---|
685 | feStringAppendBrowsers(0); |
---|
686 | StringAppend("\n"); |
---|
687 | return str; |
---|
688 | } |
---|
689 | |
---|
690 | #ifdef HAVE_NS |
---|
691 | void listall(int showproc) |
---|
692 | { |
---|
693 | idhdl hh=basePack->idroot; |
---|
694 | PrintS("====== Top ==============\n"); |
---|
695 | while (hh!=NULL) |
---|
696 | { |
---|
697 | if (showproc || (IDTYP(hh)!=PROC_CMD)) |
---|
698 | { |
---|
699 | if (IDDATA(hh)==(void *)currRing) PrintS("(R)"); |
---|
700 | else if (IDDATA(hh)==(void *)currPack) PrintS("(P)"); |
---|
701 | else PrintS(" "); |
---|
702 | Print("::%s, typ %s level %d data %x", |
---|
703 | IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),IDDATA(hh)); |
---|
704 | if ((IDTYP(hh)==RING_CMD) |
---|
705 | || (IDTYP(hh)==QRING_CMD)) |
---|
706 | Print(" ref: %d\n",IDRING(hh)->ref); |
---|
707 | else |
---|
708 | PrintLn(); |
---|
709 | } |
---|
710 | hh=IDNEXT(hh); |
---|
711 | } |
---|
712 | hh=basePack->idroot; |
---|
713 | while (hh!=NULL) |
---|
714 | { |
---|
715 | if (IDDATA(hh)==(void *)basePack) |
---|
716 | Print("(T)::%s, typ %s level %d data %x\n", |
---|
717 | IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),IDDATA(hh)); |
---|
718 | else |
---|
719 | if ((IDTYP(hh)==RING_CMD) |
---|
720 | || (IDTYP(hh)==QRING_CMD) |
---|
721 | || (IDTYP(hh)==PACKAGE_CMD)) |
---|
722 | { |
---|
723 | Print("====== %s ==============\n",IDID(hh)); |
---|
724 | idhdl h2=IDRING(hh)->idroot; |
---|
725 | while (h2!=NULL) |
---|
726 | { |
---|
727 | if (showproc || (IDTYP(h2)!=PROC_CMD)) |
---|
728 | { |
---|
729 | if (IDDATA(h2)==(void *)currRing) PrintS("(R)"); |
---|
730 | else if (IDDATA(h2)==(void *)currPack) PrintS("(P)"); |
---|
731 | else PrintS(" "); |
---|
732 | Print("%s::%s, typ %s level %d data %x\n", |
---|
733 | IDID(hh),IDID(h2),Tok2Cmdname(IDTYP(h2)),IDLEV(h2),IDDATA(h2)); |
---|
734 | } |
---|
735 | h2=IDNEXT(h2); |
---|
736 | } |
---|
737 | } |
---|
738 | hh=IDNEXT(hh); |
---|
739 | } |
---|
740 | Print("currRing:%x, currPack:%x,basePack:%x\n",currRing,currPack,basePack); |
---|
741 | } |
---|
742 | void checkall() |
---|
743 | { |
---|
744 | idhdl hh=basePack->idroot; |
---|
745 | while (hh!=NULL) |
---|
746 | { |
---|
747 | omCheckAddr(hh); |
---|
748 | omCheckAddr(IDID(hh)); |
---|
749 | if (RingDependend(IDTYP(hh))) Print("%s typ %d in Top\n",IDID(hh),IDTYP(hh)); |
---|
750 | hh=IDNEXT(hh); |
---|
751 | } |
---|
752 | hh=basePack->idroot; |
---|
753 | while (hh!=NULL) |
---|
754 | { |
---|
755 | if (IDTYP(hh)==PACKAGE_CMD) |
---|
756 | { |
---|
757 | idhdl h2=IDPACKAGE(hh)->idroot; |
---|
758 | while (h2!=NULL) |
---|
759 | { |
---|
760 | omCheckAddr(h2); |
---|
761 | omCheckAddr(IDID(h2)); |
---|
762 | if (RingDependend(IDTYP(h2))) Print("%s typ %d in %s\n",IDID(h2),IDTYP(h2),IDID(hh)); |
---|
763 | h2=IDNEXT(h2); |
---|
764 | } |
---|
765 | } |
---|
766 | hh=IDNEXT(hh); |
---|
767 | } |
---|
768 | } |
---|
769 | #endif |
---|