[0e1846] | 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 | |
---|
[2685a1] | 16 | #include "mod2.h" |
---|
[512a2b] | 17 | #include "omalloc.h" |
---|
[c232af] | 18 | #include "structs.h" |
---|
[0e1846] | 19 | #include "tok.h" |
---|
| 20 | #include "febase.h" |
---|
| 21 | #include "cntrlc.h" |
---|
[93266c5] | 22 | #include "page.h" |
---|
[0e1846] | 23 | #include "ipid.h" |
---|
| 24 | #include "ipshell.h" |
---|
| 25 | #include "kstd1.h" |
---|
| 26 | #include "subexpr.h" |
---|
| 27 | #include "timer.h" |
---|
[58b151c] | 28 | #include "intvec.h" |
---|
[be0d84] | 29 | #include "ring.h" |
---|
[c232af] | 30 | #include "omSingularConfig.h" |
---|
[7e5a38] | 31 | #include "p_Procs.h" |
---|
[a3705ae] | 32 | #include "version.h" |
---|
[8a679a] | 33 | |
---|
| 34 | #include "static.h" |
---|
| 35 | #ifdef HAVE_STATIC |
---|
| 36 | #undef HAVE_DYN_RL |
---|
| 37 | #endif |
---|
| 38 | |
---|
[8b6255] | 39 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
[dc32d42] | 40 | |
---|
[706c95] | 41 | //#ifdef HAVE_LIBPARSER |
---|
| 42 | //# include "libparse.h" |
---|
| 43 | //#endif /* HAVE_LIBPARSER */ |
---|
[5480da] | 44 | |
---|
[dc32d42] | 45 | #ifdef HAVE_FACTORY |
---|
[8b6255] | 46 | #include <factory.h> |
---|
[dc32d42] | 47 | #endif |
---|
[0e1846] | 48 | |
---|
[9ea9c6] | 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 | |
---|
[c232af] | 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 | |
---|
[0e1846] | 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);*/ |
---|
[8b6255] | 94 | if (t==0) t=1; |
---|
[34ab5de] | 95 | #ifdef HAVE_RTIMER |
---|
| 96 | initRTimer(); |
---|
| 97 | #endif |
---|
[0e1846] | 98 | #ifdef buildin_rand |
---|
| 99 | siSeed=t; |
---|
| 100 | #else |
---|
| 101 | srand((unsigned int)t); |
---|
| 102 | #endif |
---|
[8b6255] | 103 | #ifdef HAVE_FACTORY |
---|
| 104 | factoryseed(t); |
---|
[9ea9c6] | 105 | #endif |
---|
[0e1846] | 106 | /*4 private data of other modules*/ |
---|
| 107 | memset(&sLastPrinted,0,sizeof(sleftv)); |
---|
[6ae4f5] | 108 | sLastPrinted.rtyp=NONE; |
---|
[0e1846] | 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 | { |
---|
[83c9ec] | 118 | fe_reset_input_mode(); |
---|
[93266c5] | 119 | #ifdef PAGE_TEST |
---|
| 120 | mmEndStat(); |
---|
| 121 | #endif |
---|
[e9ad8a6] | 122 | #ifdef HAVE_TCL |
---|
| 123 | if (tclmode) |
---|
[c19d54] | 124 | { |
---|
[e9ad8a6] | 125 | PrintTCL('Q',0,NULL); |
---|
[c19d54] | 126 | } |
---|
[e9ad8a6] | 127 | #endif |
---|
[8f769bb] | 128 | fe_reset_input_mode(); |
---|
[e9ad8a6] | 129 | if (i<=0) |
---|
[0e1846] | 130 | { |
---|
| 131 | #ifdef HAVE_TCL |
---|
[e9ad8a6] | 132 | if (!tclmode) |
---|
[0e1846] | 133 | #endif |
---|
[e9ad8a6] | 134 | if (BVERBOSE(0)) |
---|
| 135 | { |
---|
| 136 | if (i==0) |
---|
| 137 | printf("Auf Wiedersehen.\n"); |
---|
[c19d54] | 138 | else |
---|
| 139 | printf("\n$Bye.\n"); |
---|
[e9ad8a6] | 140 | } |
---|
| 141 | #ifdef sun |
---|
| 142 | #ifndef __svr4__ |
---|
| 143 | _cleanup(); |
---|
| 144 | _exit(0); |
---|
| 145 | #endif |
---|
| 146 | #endif |
---|
| 147 | exit(0); |
---|
[0e1846] | 148 | } |
---|
| 149 | else |
---|
| 150 | { |
---|
| 151 | #ifdef HAVE_TCL |
---|
[e9ad8a6] | 152 | if (!tclmode) |
---|
[0e1846] | 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 |
---|
[40edb03] | 167 | *#include <sys/times.h> |
---|
[0e1846] | 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 | |
---|
[62fba0c] | 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)); |
---|
[c73fc6] | 246 | if((lib!=NULL)&&(*lib!='\0')) |
---|
[62fba0c] | 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 | } |
---|
[c232af] | 257 | else omFree((ADDRESS)s); |
---|
[62fba0c] | 258 | } |
---|
| 259 | } |
---|
| 260 | } |
---|
[c04b94] | 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 | { |
---|
[2ddc2e2] | 269 | |
---|
[c04b94] | 270 | int old_echo = si_echo; |
---|
| 271 | int length, got; |
---|
| 272 | char* s; |
---|
[2ddc2e2] | 273 | |
---|
[c04b94] | 274 | fseek(fd, 0, SEEK_END); |
---|
| 275 | length = ftell(fd); |
---|
| 276 | fseek(fd, 0, SEEK_SET); |
---|
[c232af] | 277 | s = (char*) omAlloc((length+20)*sizeof(char)); |
---|
[c04b94] | 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); |
---|
[c232af] | 283 | omFree(s); |
---|
[c04b94] | 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 | } |
---|
[62fba0c] | 299 | } |
---|
| 300 | |
---|
[0e1846] | 301 | |
---|
| 302 | struct soptionStruct |
---|
| 303 | { |
---|
| 304 | char * name; |
---|
| 305 | int setval; |
---|
| 306 | int 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) }, |
---|
[bd4fa1] | 313 | {"notBuckets", Sy_bit(OPT_NOT_BUCKETS), ~Sy_bit(OPT_NOT_BUCKETS) }, |
---|
[0e1846] | 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) }, |
---|
[057e93c] | 317 | {"teach", Sy_bit(OPT_DEBUG), ~Sy_bit(OPT_DEBUG) }, |
---|
[0e1846] | 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) }, |
---|
[bef194] | 328 | {"redThrough", Sy_bit(OPT_REDTHROUGH), ~Sy_bit(OPT_REDTHROUGH) }, |
---|
| 329 | {"oldStd", Sy_bit(OPT_OLDSTD), ~Sy_bit(OPT_OLDSTD) }, |
---|
[0e1846] | 330 | {"intStrategy", Sy_bit(OPT_INTSTRATEGY), ~Sy_bit(OPT_INTSTRATEGY) }, |
---|
[82f0a0] | 331 | {"infRedTail", Sy_bit(OPT_INFREDTAIL), ~Sy_bit(OPT_INFREDTAIL) }, |
---|
[0e1846] | 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 | /*special for "none" and also end marker for showOption:*/ |
---|
| 355 | {"ne", 0, 0 } |
---|
| 356 | }; |
---|
| 357 | |
---|
| 358 | BOOLEAN setOption(leftv res, leftv v) |
---|
| 359 | { |
---|
| 360 | char *n; |
---|
| 361 | do |
---|
| 362 | { |
---|
[3e35a1] | 363 | if (v->Typ()==STRING_CMD) |
---|
| 364 | { |
---|
[2166ad3] | 365 | n=(char *)v->CopyD(STRING_CMD); |
---|
[3e35a1] | 366 | } |
---|
| 367 | else |
---|
| 368 | { |
---|
| 369 | if (v->name==NULL) |
---|
| 370 | return TRUE; |
---|
| 371 | if (v->rtyp==0) |
---|
| 372 | { |
---|
| 373 | n=v->name; |
---|
| 374 | v->name=NULL; |
---|
| 375 | } |
---|
| 376 | else |
---|
| 377 | { |
---|
[c232af] | 378 | n=omStrDup(v->name); |
---|
[3e35a1] | 379 | } |
---|
| 380 | } |
---|
[0e1846] | 381 | |
---|
| 382 | int i; |
---|
| 383 | |
---|
[58b151c] | 384 | if(strcmp(n,"get")==0) |
---|
[0e1846] | 385 | { |
---|
[c232af] | 386 | intvec *w=new intvec(2); |
---|
[58b151c] | 387 | (*w)[0]=test; |
---|
| 388 | (*w)[1]=verbose; |
---|
| 389 | res->rtyp=INTVEC_CMD; |
---|
| 390 | res->data=(void *)w; |
---|
| 391 | goto okay; |
---|
| 392 | } |
---|
| 393 | if(strcmp(n,"set")==0) |
---|
| 394 | { |
---|
| 395 | if((v->next!=NULL) |
---|
| 396 | &&(v->next->Typ()==INTVEC_CMD)) |
---|
[0e1846] | 397 | { |
---|
[58b151c] | 398 | v=v->next; |
---|
[9ea9c6] | 399 | intvec *w=(intvec*)v->Data(); |
---|
[58b151c] | 400 | test=(*w)[0]; |
---|
| 401 | verbose=(*w)[1]; |
---|
[9ea9c6] | 402 | |
---|
[be0d84] | 403 | if (TEST_OPT_INTSTRATEGY && (currRing!=NULL) |
---|
[743c32] | 404 | && rField_has_simple_inverse()) |
---|
[58b151c] | 405 | { |
---|
| 406 | test &=~Sy_bit(OPT_INTSTRATEGY); |
---|
| 407 | } |
---|
[0e1846] | 408 | goto okay; |
---|
[9ea9c6] | 409 | } |
---|
[58b151c] | 410 | } |
---|
[667247] | 411 | if(strcmp(n,"none")==0) |
---|
| 412 | { |
---|
| 413 | test=0; |
---|
| 414 | verbose=0; |
---|
| 415 | goto okay; |
---|
[9ea9c6] | 416 | } |
---|
[58b151c] | 417 | for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++) |
---|
| 418 | { |
---|
| 419 | if (strcmp(n,optionStruct[i].name)==0) |
---|
[0e1846] | 420 | { |
---|
[58b151c] | 421 | if (optionStruct[i].setval & validOpts) |
---|
[6227ad] | 422 | { |
---|
[58b151c] | 423 | test |= optionStruct[i].setval; |
---|
[bef194] | 424 | // optOldStd disables redthrough |
---|
| 425 | if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD)) |
---|
| 426 | test &= ~Sy_bit(OPT_REDTHROUGH); |
---|
[6227ad] | 427 | } |
---|
[58b151c] | 428 | else |
---|
| 429 | Warn("cannot set option"); |
---|
[be0d84] | 430 | if (TEST_OPT_INTSTRATEGY && (currRing!=NULL) |
---|
[743c32] | 431 | && rField_has_simple_inverse()) |
---|
[0e1846] | 432 | { |
---|
[58b151c] | 433 | test &=~Sy_bit(OPT_INTSTRATEGY); |
---|
| 434 | } |
---|
| 435 | goto okay; |
---|
[0e1846] | 436 | } |
---|
[58b151c] | 437 | else if ((strncmp(n,"no",2)==0) |
---|
| 438 | && (strcmp(n+2,optionStruct[i].name)==0)) |
---|
[0e1846] | 439 | { |
---|
[667247] | 440 | if (optionStruct[i].setval & validOpts) |
---|
[0e1846] | 441 | { |
---|
[58b151c] | 442 | test &= optionStruct[i].resetval; |
---|
[0e1846] | 443 | } |
---|
[58b151c] | 444 | else |
---|
| 445 | Warn("cannot clear option"); |
---|
| 446 | goto okay; |
---|
[0e1846] | 447 | } |
---|
| 448 | } |
---|
[58b151c] | 449 | for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++) |
---|
[0e1846] | 450 | { |
---|
[58b151c] | 451 | if (strcmp(n,verboseStruct[i].name)==0) |
---|
[0e1846] | 452 | { |
---|
[58b151c] | 453 | verbose |= verboseStruct[i].setval; |
---|
| 454 | #ifdef YYDEBUG |
---|
| 455 | #if YYDEBUG |
---|
| 456 | if (BVERBOSE(V_YACC)) yydebug=1; |
---|
| 457 | else yydebug=0; |
---|
| 458 | #endif |
---|
| 459 | #endif |
---|
[0e1846] | 460 | goto okay; |
---|
| 461 | } |
---|
[58b151c] | 462 | else if ((strncmp(n,"no",2)==0) |
---|
| 463 | && (strcmp(n+2,verboseStruct[i].name)==0)) |
---|
[0e1846] | 464 | { |
---|
[58b151c] | 465 | verbose &= verboseStruct[i].resetval; |
---|
| 466 | #ifdef YYDEBUG |
---|
| 467 | #if YYDEBUG |
---|
| 468 | if (BVERBOSE(V_YACC)) yydebug=1; |
---|
| 469 | else yydebug=0; |
---|
| 470 | #endif |
---|
| 471 | #endif |
---|
| 472 | goto okay; |
---|
[0e1846] | 473 | } |
---|
[58b151c] | 474 | } |
---|
| 475 | Werror("unknown option `%s`",n); |
---|
[0e1846] | 476 | okay: |
---|
[5ecf042] | 477 | if (currRing != NULL) |
---|
| 478 | currRing->options = test & TEST_RINGDEP_OPTS; |
---|
[c232af] | 479 | omFree((ADDRESS)n); |
---|
[0e1846] | 480 | v=v->next; |
---|
[9ea9c6] | 481 | } while (v!=NULL); |
---|
[1e3015] | 482 | #ifdef HAVE_TCL |
---|
| 483 | if (tclmode) |
---|
| 484 | { |
---|
| 485 | BITSET tmp; |
---|
| 486 | int i; |
---|
[a79a128] | 487 | StringSetS(""); |
---|
[1e3015] | 488 | if ((test!=0)||(verbose!=0)) |
---|
| 489 | { |
---|
| 490 | tmp=test; |
---|
| 491 | if(tmp) |
---|
| 492 | { |
---|
| 493 | for (i=0; optionStruct[i].setval!=0; i++) |
---|
| 494 | { |
---|
| 495 | if (optionStruct[i].setval & test) |
---|
| 496 | { |
---|
| 497 | StringAppend(" %s",optionStruct[i].name); |
---|
| 498 | tmp &=optionStruct[i].resetval; |
---|
| 499 | } |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | tmp=verbose; |
---|
| 503 | if (tmp) |
---|
| 504 | { |
---|
| 505 | for (i=0; verboseStruct[i].setval!=0; i++) |
---|
| 506 | { |
---|
| 507 | if (verboseStruct[i].setval & tmp) |
---|
| 508 | { |
---|
| 509 | StringAppend(" %s",verboseStruct[i].name); |
---|
| 510 | tmp &=verboseStruct[i].resetval; |
---|
| 511 | } |
---|
| 512 | } |
---|
| 513 | } |
---|
[b45d97] | 514 | PrintTCLS('O',StringAppendS("")); |
---|
[a79a128] | 515 | StringSetS(""); |
---|
[1e3015] | 516 | } |
---|
| 517 | else |
---|
| 518 | { |
---|
| 519 | PrintTCLS('O'," "); |
---|
| 520 | } |
---|
| 521 | } |
---|
| 522 | #endif |
---|
[c232af] | 523 | // set global variable to show memory usage |
---|
| 524 | if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1; |
---|
| 525 | else om_sing_opt_show_mem = 0; |
---|
[0e1846] | 526 | return FALSE; |
---|
| 527 | } |
---|
| 528 | |
---|
[979a09f] | 529 | char * showOption() |
---|
[0e1846] | 530 | { |
---|
| 531 | int i; |
---|
| 532 | BITSET tmp; |
---|
| 533 | |
---|
[a79a128] | 534 | StringSetS("//options:"); |
---|
[58b151c] | 535 | if ((test!=0)||(verbose!=0)) |
---|
[0e1846] | 536 | { |
---|
| 537 | tmp=test; |
---|
[58b151c] | 538 | if(tmp) |
---|
[0e1846] | 539 | { |
---|
| 540 | for (i=0; optionStruct[i].setval!=0; i++) |
---|
| 541 | { |
---|
| 542 | if (optionStruct[i].setval & test) |
---|
| 543 | { |
---|
[979a09f] | 544 | StringAppend(" %s",optionStruct[i].name); |
---|
[0e1846] | 545 | tmp &=optionStruct[i].resetval; |
---|
| 546 | } |
---|
| 547 | } |
---|
| 548 | for (i=0; i<32; i++) |
---|
| 549 | { |
---|
[979a09f] | 550 | if (tmp & Sy_bit(i)) StringAppend(" %d",i); |
---|
[0e1846] | 551 | } |
---|
| 552 | } |
---|
| 553 | tmp=verbose; |
---|
| 554 | if (tmp) |
---|
| 555 | { |
---|
| 556 | for (i=0; verboseStruct[i].setval!=0; i++) |
---|
| 557 | { |
---|
| 558 | if (verboseStruct[i].setval & tmp) |
---|
| 559 | { |
---|
[979a09f] | 560 | StringAppend(" %s",verboseStruct[i].name); |
---|
[0e1846] | 561 | tmp &=verboseStruct[i].resetval; |
---|
| 562 | } |
---|
| 563 | } |
---|
| 564 | for (i=1; i<32; i++) |
---|
| 565 | { |
---|
[979a09f] | 566 | if (tmp & Sy_bit(i)) StringAppend(" %d",i+32); |
---|
[0e1846] | 567 | } |
---|
| 568 | } |
---|
[c232af] | 569 | return omStrDup(StringAppendS("")); |
---|
[0e1846] | 570 | } |
---|
[58b151c] | 571 | else |
---|
[c232af] | 572 | return omStrDup(StringAppendS(" none")); |
---|
[0e1846] | 573 | } |
---|
| 574 | |
---|
[9ea9c6] | 575 | char * versionString() |
---|
| 576 | { |
---|
[b7b08c] | 577 | char* str = StringSetS(""); |
---|
[923c27] | 578 | StringAppend("Singular for %s version %s (%lu) %s\nwith\n", |
---|
[b7b08c] | 579 | S_UNAME, S_VERSION1, |
---|
[923c27] | 580 | feVersionId,singular_date); |
---|
[b7b08c] | 581 | StringAppend("\t"); |
---|
[9ea9c6] | 582 | #ifdef HAVE_FACTORY |
---|
[97454d] | 583 | StringAppend("factory(%s),", factoryVersion); |
---|
[9ea9c6] | 584 | #endif |
---|
| 585 | #ifdef HAVE_LIBFAC_P |
---|
[38cfbb] | 586 | StringAppend("libfac(%s,%s),\n\t",libfac_version,libfac_date); |
---|
[9ea9c6] | 587 | #endif |
---|
| 588 | #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR) |
---|
[38cfbb] | 589 | StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR); |
---|
[9ea9c6] | 590 | #elif defined (HAVE_SMALLGMP) |
---|
[38cfbb] | 591 | StringAppendS("SmallGMP(2.0.2.0),"); |
---|
[9ea9c6] | 592 | #else |
---|
[38cfbb] | 593 | StringAppendS("GMP(1.3),"); |
---|
[9ea9c6] | 594 | #endif |
---|
| 595 | #ifdef HAVE_MPSR |
---|
[f69a29] | 596 | StringAppend("MP(%s),",MP_VERSION); |
---|
[9ea9c6] | 597 | #endif |
---|
[f413ec5] | 598 | #if defined(HAVE_DYN_RL) |
---|
[2ddc2e2] | 599 | if (fe_fgets_stdin==fe_fgets_dummy) |
---|
| 600 | StringAppendS("no input,"); |
---|
| 601 | else if (fe_fgets_stdin==fe_fgets) |
---|
| 602 | StringAppendS("fgets,"); |
---|
| 603 | if (fe_fgets_stdin==fe_fgets_stdin_drl) |
---|
| 604 | StringAppendS("dynamic readline,"); |
---|
| 605 | else if (fe_fgets_stdin==fe_fgets_stdin_emu) |
---|
| 606 | StringAppendS("emulated readline,"); |
---|
| 607 | else |
---|
| 608 | StringAppendS("unknown fgets method,"); |
---|
[f69a29] | 609 | #else |
---|
[f413ec5] | 610 | #if defined(HAVE_READLINE) && !defined(FEREAD) |
---|
[7e5a38] | 611 | StringAppendS("static readline,"); |
---|
[f413ec5] | 612 | #else |
---|
| 613 | #ifdef HAVE_FEREAD |
---|
[2ddc2e2] | 614 | StringAppendS("emulated readline,"); |
---|
[8a679a] | 615 | #else |
---|
| 616 | StringAppendS("fgets,"); |
---|
[f413ec5] | 617 | #endif |
---|
| 618 | #endif |
---|
[38cfbb] | 619 | #endif |
---|
| 620 | #ifdef SRING |
---|
| 621 | StringAppendS("super algebra,"); |
---|
| 622 | #endif |
---|
| 623 | #ifdef DRING |
---|
| 624 | StringAppendS("Weyl algebra,"); |
---|
| 625 | #endif |
---|
| 626 | #ifdef HAVE_DBM |
---|
[58124a3] | 627 | StringAppendS("DBM,\n\t"); |
---|
| 628 | #else |
---|
| 629 | StringAppendS("\n\t"); |
---|
[9ea9c6] | 630 | #endif |
---|
[0a3ddd] | 631 | #ifdef HAVE_NAMESPACES |
---|
[7e5a38] | 632 | StringAppendS("namespaces,"); |
---|
[0a3ddd] | 633 | #endif |
---|
[cd6b45] | 634 | #ifdef HAVE_DYNAMIC_LOADING |
---|
[7e5a38] | 635 | StringAppendS("dynamic modules,"); |
---|
[cd6b45] | 636 | #endif |
---|
[7e5a38] | 637 | if (p_procs_dynamic) StringAppendS("dynamic p_Procs,"); |
---|
[9ea9c6] | 638 | #ifdef TEST |
---|
[38cfbb] | 639 | StringAppendS("TESTs,"); |
---|
[9ea9c6] | 640 | #endif |
---|
| 641 | #if YYDEBUG |
---|
[38cfbb] | 642 | StringAppendS("YYDEBUG=1,"); |
---|
[9ea9c6] | 643 | #endif |
---|
[98555e] | 644 | #ifdef HAVE_ASSUME |
---|
[8f769bb] | 645 | StringAppendS("ASSUME,"); |
---|
[98555e] | 646 | #endif |
---|
[9ea9c6] | 647 | #ifdef MDEBUG |
---|
[38cfbb] | 648 | StringAppend("MDEBUG=%d,",MDEBUG); |
---|
| 649 | #endif |
---|
[c232af] | 650 | #ifdef OM_CHECK |
---|
| 651 | StringAppend("OM_CHECK=%d,",OM_CHECK); |
---|
| 652 | #endif |
---|
| 653 | #ifdef OM_TRACK |
---|
| 654 | StringAppend("OM_TRACK=%d,",OM_TRACK); |
---|
| 655 | #endif |
---|
| 656 | #ifdef OM_NDEBUG |
---|
| 657 | StringAppend("OM_NDEBUG,"); |
---|
[58124a3] | 658 | #endif |
---|
[275397] | 659 | #ifdef PDEBUG |
---|
[b45d97] | 660 | StringAppendS("PDEBUG,"); |
---|
[275397] | 661 | #endif |
---|
| 662 | #ifdef KDEBUG |
---|
[b45d97] | 663 | StringAppendS("KDEBUG,"); |
---|
[275397] | 664 | #endif |
---|
[9ea9c6] | 665 | #ifndef __OPTIMIZE__ |
---|
[12310e] | 666 | #ifdef __MWERKS__ |
---|
[b45d97] | 667 | StringAppendS(" Codewarrior 2.0,"); |
---|
[12310e] | 668 | #else |
---|
[b45d97] | 669 | StringAppendS("-g,"); |
---|
[12310e] | 670 | #endif |
---|
[9ea9c6] | 671 | #endif |
---|
[38cfbb] | 672 | StringAppend("random=%d\n",siRandomStart); |
---|
[9c35ef] | 673 | |
---|
[9f1850] | 674 | feStringAppendResources(0); |
---|
| 675 | feStringAppendBrowsers(0); |
---|
[b7b08c] | 676 | StringAppend("\n"); |
---|
[09f0ee] | 677 | return str; |
---|
[9ea9c6] | 678 | } |
---|
[cb66fa] | 679 | |
---|
| 680 | |
---|