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