[0e1846] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
| 4 | /* |
---|
| 5 | * ABSTRACT: |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include <string.h> |
---|
| 9 | #include "mod2.h" |
---|
[99965c5] | 10 | #ifndef macintosh |
---|
[0e1846] | 11 | #include <unistd.h> |
---|
| 12 | #endif |
---|
| 13 | #include <stdio.h> |
---|
| 14 | #include <stddef.h> |
---|
| 15 | #include <stdlib.h> |
---|
| 16 | #include <time.h> |
---|
| 17 | #include <limits.h> |
---|
| 18 | |
---|
| 19 | #include "tok.h" |
---|
| 20 | #include "febase.h" |
---|
| 21 | #include "cntrlc.h" |
---|
| 22 | #include "mmemory.h" |
---|
| 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" |
---|
[8b6255] | 29 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
[dc32d42] | 30 | |
---|
[5480da] | 31 | #ifdef HAVE_LIBPARSER |
---|
| 32 | # include "libparse.h" |
---|
| 33 | #endif /* HAVE_LIBPARSER */ |
---|
| 34 | |
---|
[dc32d42] | 35 | #ifdef HAVE_FACTORY |
---|
[8b6255] | 36 | #include <factory.h> |
---|
[dc32d42] | 37 | #endif |
---|
[0e1846] | 38 | |
---|
[9ea9c6] | 39 | /* version strings */ |
---|
| 40 | #ifdef HAVE_LIBFAC_P |
---|
| 41 | extern const char * libfac_version; |
---|
| 42 | extern const char * libfac_date; |
---|
| 43 | #endif |
---|
| 44 | #ifdef HAVE_GMP |
---|
| 45 | extern "C" { |
---|
| 46 | #include <gmp.h> |
---|
| 47 | } |
---|
| 48 | #endif |
---|
| 49 | #ifdef HAVE_MPSR |
---|
| 50 | #include <MP_Config.h> |
---|
| 51 | #endif |
---|
| 52 | |
---|
[0e1846] | 53 | /*0 implementation*/ |
---|
| 54 | |
---|
| 55 | /*2 |
---|
| 56 | * initialize components of Singular |
---|
| 57 | */ |
---|
| 58 | int inits(void) |
---|
| 59 | { |
---|
| 60 | int t; |
---|
| 61 | /*4 signal handler:*/ |
---|
| 62 | init_signals(); |
---|
| 63 | /*4 randomize: */ |
---|
| 64 | t=initTimer(); |
---|
| 65 | /*t=(int)time(NULL);*/ |
---|
[8b6255] | 66 | if (t==0) t=1; |
---|
[34ab5de] | 67 | #ifdef HAVE_RTIMER |
---|
| 68 | initRTimer(); |
---|
| 69 | #endif |
---|
[0e1846] | 70 | #ifdef buildin_rand |
---|
| 71 | siSeed=t; |
---|
| 72 | #else |
---|
| 73 | srand((unsigned int)t); |
---|
| 74 | #endif |
---|
[8b6255] | 75 | #ifdef HAVE_FACTORY |
---|
| 76 | factoryseed(t); |
---|
[9ea9c6] | 77 | #endif |
---|
[0e1846] | 78 | /*4 private data of other modules*/ |
---|
| 79 | memset(&sLastPrinted,0,sizeof(sleftv)); |
---|
[6ae4f5] | 80 | sLastPrinted.rtyp=NONE; |
---|
[0e1846] | 81 | #ifdef HAVE_MPSR |
---|
| 82 | extern void mpsr_Init(); |
---|
| 83 | mpsr_Init(); |
---|
| 84 | #endif |
---|
| 85 | return t; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | /*2 |
---|
| 89 | * the global exit routine of Singular |
---|
| 90 | */ |
---|
| 91 | extern "C" { |
---|
| 92 | void m2_end(short i) |
---|
| 93 | { |
---|
| 94 | if (i==0) |
---|
| 95 | { |
---|
| 96 | #ifdef HAVE_TCL |
---|
| 97 | if (tclmode) |
---|
| 98 | PrintTCL('Q',0,NULL); |
---|
| 99 | else |
---|
| 100 | #endif |
---|
| 101 | printf("Auf Wiedersehen.\n"); |
---|
| 102 | } |
---|
| 103 | else |
---|
| 104 | { |
---|
| 105 | #ifdef HAVE_TCL |
---|
| 106 | if (tclmode) |
---|
| 107 | PrintTCL('Q',0,NULL); |
---|
| 108 | else |
---|
| 109 | #endif |
---|
| 110 | printf("\nhalt %d\n",i); |
---|
| 111 | } |
---|
| 112 | exit(i); |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | /*2 |
---|
| 117 | * the renice routine for very large jobs |
---|
| 118 | * works only on unix machines, |
---|
| 119 | * testet on : linux, HP 9.0 |
---|
| 120 | * |
---|
| 121 | *#ifndef MSDOS |
---|
| 122 | *#ifndef macintosh |
---|
[40edb03] | 123 | *#include <sys/times.h> |
---|
[0e1846] | 124 | *#include <sys/resource.h> |
---|
| 125 | *extern "C" int setpriority(int,int,int); |
---|
| 126 | *void very_nice() |
---|
| 127 | *{ |
---|
| 128 | *#ifndef NO_SETPRIORITY |
---|
| 129 | * setpriority(PRIO_PROCESS,0,19); |
---|
| 130 | *#endif |
---|
| 131 | * sleep(10); |
---|
| 132 | *} |
---|
| 133 | *#else |
---|
| 134 | *void very_nice(){} |
---|
| 135 | *#endif |
---|
| 136 | *#else |
---|
| 137 | *void very_nice(){} |
---|
| 138 | *#endif |
---|
| 139 | */ |
---|
| 140 | |
---|
| 141 | /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
---|
| 142 | #ifdef buildin_rand |
---|
| 143 | /* |
---|
| 144 | * |
---|
| 145 | * A prime modulus multiplicative linear congruential |
---|
| 146 | * generator (PMMLCG), or "Lehmer generator". |
---|
| 147 | * Implementation directly derived from the article: |
---|
| 148 | * |
---|
| 149 | * S. K. Park and K. W. Miller |
---|
| 150 | * Random Number Generators: Good Ones are Hard to Find |
---|
| 151 | * CACM vol 31, #10. Oct. 1988. pp 1192-1201. |
---|
| 152 | * |
---|
| 153 | * Using the following multiplier and modulus, we obtain a |
---|
| 154 | * generator which: |
---|
| 155 | * |
---|
| 156 | * 1) Has a full period: 1 to 2^31 - 2. |
---|
| 157 | * 2) Is testably "random" (see the article). |
---|
| 158 | * 3) Has a known implementation by E. L. Schrage. |
---|
| 159 | */ |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | #define A 16807L /* A "good" multiplier */ |
---|
| 163 | #define M 2147483647L /* Modulus: 2^31 - 1 */ |
---|
| 164 | #define Q 127773L /* M / A */ |
---|
| 165 | #define R 2836L /* M % A */ |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | int siSeed = 1L; |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | int siRand() |
---|
| 172 | { |
---|
| 173 | siSeed = A * (siSeed % Q) - R * (siSeed / Q); |
---|
| 174 | |
---|
| 175 | if ( siSeed < 0 ) |
---|
| 176 | siSeed += M; |
---|
| 177 | |
---|
| 178 | return( siSeed ); |
---|
| 179 | } |
---|
| 180 | #endif |
---|
| 181 | |
---|
| 182 | /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
---|
| 183 | #define HELP_OK 0 |
---|
| 184 | |
---|
| 185 | #ifdef buildin_help |
---|
| 186 | |
---|
| 187 | #define FIN_INDEX '\037' |
---|
| 188 | #define not ! |
---|
| 189 | #define HELP_NOT_OPEN 1 |
---|
| 190 | #define HELP_NOT_FOUND 2 |
---|
[05fc79] | 191 | #ifndef macintosh |
---|
[dc32d42] | 192 | #define Index_File SINGULAR_INFODIR "/singular.hlp" |
---|
| 193 | #define Help_File SINGULAR_INFODIR "/singular.hlp" |
---|
[05fc79] | 194 | #else |
---|
[f46b24] | 195 | #define Index_File SINGULAR_INFODIR "singular.hlp" |
---|
| 196 | #define Help_File SINGULAR_INFODIR "singular.hlp" |
---|
[05fc79] | 197 | #endif |
---|
[0e1846] | 198 | #define BUF_LEN 128 |
---|
| 199 | #define IDX_LEN 64 |
---|
| 200 | #define MAX_LINES 21 |
---|
| 201 | |
---|
| 202 | static int compare(char *s1,char *s2) |
---|
| 203 | { |
---|
| 204 | for(;*s1==*s2;s1++,s2++) |
---|
| 205 | if(*s2=='\0') return(0); |
---|
| 206 | return(*s2); |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | #ifdef macintosh |
---|
| 210 | static char tolow(char p) |
---|
| 211 | #else |
---|
| 212 | static inline char tolow(char p) |
---|
| 213 | #endif |
---|
| 214 | { |
---|
| 215 | if (('A'<=p)&&(p<='Z')) return p | 040; |
---|
| 216 | return p; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | /*************************************************/ |
---|
| 220 | static int show(unsigned long offset,FILE *help, char *close) |
---|
| 221 | { char buffer[BUF_LEN+1]; |
---|
| 222 | int lines = 0; |
---|
| 223 | |
---|
| 224 | if( help== NULL) |
---|
| 225 | if( (help = feFopen(Help_File, "r")) == NULL) |
---|
| 226 | return HELP_NOT_OPEN; |
---|
| 227 | |
---|
| 228 | fseek(help, (long)(offset+1), (int)0); |
---|
| 229 | while( !feof(help) |
---|
| 230 | && *fgets(buffer, BUF_LEN, help) != EOF |
---|
| 231 | && buffer[0] != FIN_INDEX) |
---|
[057e93c] | 232 | { |
---|
| 233 | printf("%s", buffer); |
---|
[0e1846] | 234 | if(lines++> MAX_LINES) |
---|
[057e93c] | 235 | { |
---|
[0e1846] | 236 | #ifdef macintosh |
---|
[057e93c] | 237 | printf("\n Press <RETURN> to continue or x and <RETURN> to exit help.\n"); |
---|
[0e1846] | 238 | #else |
---|
[057e93c] | 239 | printf("\n Press <RETURN> to continue or x to exit help.\n"); |
---|
[0e1846] | 240 | #endif |
---|
| 241 | fflush(stdout); |
---|
| 242 | *close = (char)getchar(); |
---|
| 243 | if(*close=='x') |
---|
| 244 | { |
---|
| 245 | getchar(); |
---|
| 246 | break; |
---|
| 247 | } |
---|
| 248 | lines=0; |
---|
| 249 | } |
---|
| 250 | } |
---|
| 251 | if(*close!='x') |
---|
| 252 | { |
---|
| 253 | #ifdef macintosh |
---|
[057e93c] | 254 | printf("\nEnd of part. Press <RETURN> to continue or x and <RETURN> to exit help.\n"); |
---|
[0e1846] | 255 | #else |
---|
[057e93c] | 256 | printf("\nEnd of part. Press <RETURN> to continue or x to exit help.\n"); |
---|
[0e1846] | 257 | #endif |
---|
| 258 | fflush(stdout); |
---|
| 259 | *close = (char)getchar(); |
---|
| 260 | if(*close=='x') |
---|
| 261 | getchar(); |
---|
| 262 | } |
---|
| 263 | return HELP_OK; |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | /*************************************************/ |
---|
| 267 | int singular_manual(char *str) |
---|
| 268 | { FILE *index=NULL,*help=NULL; |
---|
| 269 | unsigned long offset; |
---|
| 270 | char *p,close; |
---|
| 271 | int done = 0; |
---|
| 272 | char buffer[BUF_LEN+1], |
---|
| 273 | Index[IDX_LEN+1], |
---|
| 274 | String[IDX_LEN+1]; |
---|
| 275 | |
---|
| 276 | if( (index = feFopen(Index_File, "r",NULL,TRUE)) == NULL) |
---|
| 277 | { |
---|
| 278 | return HELP_NOT_OPEN; |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | for(p=str; *p; p++) *p = tolow(*p);/* */ |
---|
| 282 | do |
---|
| 283 | { |
---|
| 284 | p--; |
---|
| 285 | } |
---|
| 286 | while ((p != str) && (*p<=' ')); |
---|
| 287 | p++; |
---|
| 288 | *p='\0'; |
---|
| 289 | (void)sprintf(String, " %s ", str); |
---|
| 290 | |
---|
| 291 | while(!feof(index) |
---|
| 292 | && *fgets(buffer, BUF_LEN, index) != EOF |
---|
| 293 | && buffer[0] != FIN_INDEX); |
---|
| 294 | |
---|
| 295 | while(!feof(index)) |
---|
| 296 | { |
---|
| 297 | (void)fgets(buffer, BUF_LEN, index); /* */ |
---|
| 298 | (void)sscanf(buffer, "Node:%[^\177]\177%ld\n", Index, &offset); |
---|
| 299 | for(p=Index; *p; p++) *p = tolow(*p);/* */ |
---|
| 300 | (void)strcat(Index, " "); |
---|
| 301 | if( strstr(Index, String)!=NULL) |
---|
| 302 | { |
---|
| 303 | done++; (void)show(offset, help, &close); |
---|
| 304 | } |
---|
| 305 | Index[0]='\0'; |
---|
| 306 | if(close=='x') |
---|
| 307 | break; |
---|
| 308 | } |
---|
| 309 | (void)fclose(index); |
---|
| 310 | (void)fclose(help); |
---|
| 311 | if(not done) |
---|
| 312 | { |
---|
| 313 | Warn("`%s` not found",String); |
---|
| 314 | return HELP_NOT_FOUND; |
---|
| 315 | } |
---|
| 316 | return HELP_OK; |
---|
| 317 | } |
---|
| 318 | #endif |
---|
| 319 | /*************************************************/ |
---|
| 320 | |
---|
| 321 | void singular_help(char *str,BOOLEAN example) |
---|
| 322 | { |
---|
| 323 | char *s=str; |
---|
| 324 | while (*s==' ') s++; |
---|
| 325 | char *ss=s; |
---|
| 326 | while (*ss!='\0') ss++; |
---|
| 327 | while (*ss<=' ') |
---|
| 328 | { |
---|
| 329 | *ss='\0'; |
---|
| 330 | ss--; |
---|
| 331 | } |
---|
| 332 | /* --------- is it a proc ? --------------------------------*/ |
---|
| 333 | idhdl h=idroot->get(s,myynest); |
---|
| 334 | if ((h!=NULL) && (IDTYP(h)==PROC_CMD)) |
---|
| 335 | { |
---|
[2ba9a6] | 336 | char *lib=iiGetLibName(IDPROC(h)); |
---|
[0e1846] | 337 | Print("// proc %s ",s); |
---|
| 338 | if((lib==NULL)||(*lib=='\0')) |
---|
| 339 | { |
---|
| 340 | PrintLn(); |
---|
| 341 | } |
---|
| 342 | else |
---|
| 343 | { |
---|
| 344 | Print("from lib %s\n",lib); |
---|
[2ba9a6] | 345 | s=iiGetLibProcBuffer(IDPROC(h), example ? 2 : 0); |
---|
[057e93c] | 346 | if (!example) |
---|
| 347 | { |
---|
| 348 | PrintS(s); |
---|
| 349 | FreeL((ADDRESS)s); |
---|
[2ba9a6] | 350 | } |
---|
[057e93c] | 351 | else |
---|
| 352 | { |
---|
| 353 | if (s!=NULL) |
---|
| 354 | { |
---|
| 355 | if (strlen(s)>5) iiEStart(s,IDPROC(h)); |
---|
| 356 | else FreeL((ADDRESS)s); |
---|
| 357 | } |
---|
[0e1846] | 358 | } |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | else if (example) |
---|
| 362 | { |
---|
| 363 | Werror("%s not found",s); |
---|
| 364 | } |
---|
| 365 | else |
---|
| 366 | { |
---|
| 367 | /* --------- is it a library ? --------------------------------*/ |
---|
[5480da] | 368 | char libnamebuf[128]; |
---|
| 369 | FILE *fp=feFopen(str,"rb", libnamebuf); |
---|
[0e1846] | 370 | if (fp!=NULL) |
---|
| 371 | { |
---|
[5480da] | 372 | #ifdef HAVE_LIBPARSER |
---|
| 373 | extern FILE *yylpin; |
---|
| 374 | lib_style_types lib_style; // = OLD_LIBSTYLE; |
---|
| 375 | |
---|
| 376 | yylpin = fp; |
---|
| 377 | yylplex(str, libnamebuf, &lib_style, GET_INFO); |
---|
| 378 | reinit_yylp(); |
---|
| 379 | if(lib_style == OLD_LIBSTYLE) { |
---|
| 380 | char buf[256]; |
---|
| 381 | fseek(fp, 0, SEEK_SET); |
---|
| 382 | #else /* HAVE_LIBPARSER */ |
---|
| 383 | { char buf[256]; |
---|
| 384 | #endif /* HAVE_LIBPARSER */ |
---|
| 385 | Warn( "library %s has an old format. Please fix it for the next time", |
---|
| 386 | str); |
---|
| 387 | BOOLEAN found=FALSE; |
---|
| 388 | while (fgets( buf, sizeof(buf), fp)) |
---|
| 389 | { |
---|
| 390 | if (strncmp(buf,"//",2)==0) |
---|
| 391 | { |
---|
| 392 | if (found) return; |
---|
| 393 | } |
---|
| 394 | else if ((strncmp(buf,"proc ",5)==0)||(strncmp(buf,"LIB ",4)==0)) |
---|
| 395 | { |
---|
| 396 | if (!found) Warn("no help part in library found"); |
---|
| 397 | return; |
---|
| 398 | } |
---|
| 399 | else |
---|
| 400 | { |
---|
| 401 | found=TRUE; |
---|
| 402 | PrintS(buf); |
---|
| 403 | } |
---|
| 404 | } |
---|
[c4bbf1f] | 405 | } |
---|
| 406 | #ifdef HAVE_LIBPARSER |
---|
| 407 | else { |
---|
[5480da] | 408 | fclose( yylpin ); |
---|
| 409 | PrintS(text_buffer); |
---|
| 410 | FreeL(text_buffer); |
---|
[0e1846] | 411 | } |
---|
[c4bbf1f] | 412 | #endif /* HAVE_LIBPARSER */ |
---|
[0e1846] | 413 | } |
---|
| 414 | /* --------- everything else is for the manual ----------------*/ |
---|
| 415 | else |
---|
| 416 | { |
---|
| 417 | #ifdef buildin_help |
---|
| 418 | singular_manual(str); |
---|
| 419 | #else |
---|
[05fc79] | 420 | char tmp[150]; |
---|
[4c001a] | 421 | char tmp2[150]; |
---|
| 422 | char strstr[100]; |
---|
[05fc79] | 423 | sprintf(tmp,"%s/singular.hlp", SINGULAR_INFODIR); |
---|
[4c001a] | 424 | if (strcmp(str,"index")==0) |
---|
| 425 | strstr[0]='\0'; |
---|
| 426 | else |
---|
[9ea9c6] | 427 | sprintf(strstr," Index \"%s\"",str); |
---|
[05fc79] | 428 | if (!access(tmp, R_OK)) |
---|
[4c001a] | 429 | { |
---|
| 430 | sprintf(tmp, "info -f %s/singular.hlp %s", SINGULAR_INFODIR, strstr); |
---|
| 431 | } |
---|
[05fc79] | 432 | else |
---|
[4c001a] | 433 | { |
---|
| 434 | FILE *fd = feFopen("singular.hlp", "r", tmp2, FALSE); |
---|
| 435 | if (fd != NULL) |
---|
| 436 | { |
---|
| 437 | fclose(fd); |
---|
| 438 | sprintf(tmp, "info -f %s %s", tmp2,strstr); |
---|
| 439 | } |
---|
| 440 | else |
---|
| 441 | sprintf(tmp,"info singular %s",strstr); |
---|
| 442 | } |
---|
[0e1846] | 443 | system(tmp); |
---|
| 444 | #ifndef MSDOS |
---|
| 445 | //sprintf(tmp,"clear"); |
---|
| 446 | //system(tmp); |
---|
| 447 | #endif |
---|
| 448 | #endif |
---|
| 449 | } |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | |
---|
| 454 | struct soptionStruct |
---|
| 455 | { |
---|
| 456 | char * name; |
---|
| 457 | int setval; |
---|
| 458 | int resetval; |
---|
| 459 | }; |
---|
| 460 | |
---|
| 461 | struct soptionStruct optionStruct[]= |
---|
| 462 | { |
---|
| 463 | {"prot", Sy_bit(OPT_PROT), ~Sy_bit(OPT_PROT) }, |
---|
| 464 | {"redSB", Sy_bit(OPT_REDSB), ~Sy_bit(OPT_REDSB) }, |
---|
| 465 | /* 2 Gebauer/Moeller */ |
---|
| 466 | {"notSugar", Sy_bit(OPT_NOT_SUGAR), ~Sy_bit(OPT_NOT_SUGAR) }, |
---|
| 467 | {"interrupt", Sy_bit(OPT_INTERRUPT), ~Sy_bit(OPT_INTERRUPT) }, |
---|
| 468 | {"sugarCrit", Sy_bit(OPT_SUGARCRIT), ~Sy_bit(OPT_SUGARCRIT) }, |
---|
[057e93c] | 469 | {"teach", Sy_bit(OPT_DEBUG), ~Sy_bit(OPT_DEBUG) }, |
---|
[0e1846] | 470 | /* 7 cancel unit */ |
---|
| 471 | {"morePairs", Sy_bit(OPT_MOREPAIRS), ~Sy_bit(OPT_MOREPAIRS) }, |
---|
| 472 | /* 9 return SB in syz, quotient, intersect */ |
---|
| 473 | {"returnSB", Sy_bit(OPT_RETURN_SB), ~Sy_bit(OPT_RETURN_SB) }, |
---|
| 474 | {"fastHC", Sy_bit(OPT_FASTHC), ~Sy_bit(OPT_FASTHC) }, |
---|
| 475 | /* 11-19 sort in L/T */ |
---|
| 476 | /* 20 redBest */ |
---|
| 477 | {"keepvars", Sy_bit(OPT_KEEPVARS), ~Sy_bit(OPT_KEEPVARS) }, |
---|
| 478 | {"staircaseBound",Sy_bit(OPT_STAIRCASEBOUND),~Sy_bit(OPT_STAIRCASEBOUND) }, |
---|
| 479 | {"multBound", Sy_bit(OPT_MULTBOUND), ~Sy_bit(OPT_MULTBOUND) }, |
---|
| 480 | {"degBound", Sy_bit(OPT_DEGBOUND), ~Sy_bit(OPT_DEGBOUND) }, |
---|
| 481 | /* 25 no redTail(p)/redTail(s) */ |
---|
| 482 | {"redTail", Sy_bit(OPT_REDTAIL), ~Sy_bit(OPT_REDTAIL) }, |
---|
| 483 | {"intStrategy", Sy_bit(OPT_INTSTRATEGY), ~Sy_bit(OPT_INTSTRATEGY) }, |
---|
| 484 | /* 27 stop at HC (finiteDeterminacyTest) */ |
---|
| 485 | {"minRes", Sy_bit(OPT_MINRES), ~Sy_bit(OPT_MINRES) }, |
---|
| 486 | /* 30: use not regularity for syz */ |
---|
| 487 | {"notRegularity",Sy_bit(OPT_NOTREGULARITY), ~Sy_bit(OPT_NOTREGULARITY) }, |
---|
| 488 | {"weightM", Sy_bit(OPT_WEIGHTM), ~Sy_bit(OPT_WEIGHTM) }, |
---|
| 489 | /*special for "none" and also end marker for showOption:*/ |
---|
| 490 | {"ne", 0, 0 } |
---|
| 491 | }; |
---|
| 492 | |
---|
| 493 | struct soptionStruct verboseStruct[]= |
---|
| 494 | { |
---|
| 495 | {"mem", Sy_bit(V_SHOW_MEM), ~Sy_bit(V_SHOW_MEM) }, |
---|
| 496 | {"yacc", Sy_bit(V_YACC), ~Sy_bit(V_YACC) }, |
---|
| 497 | {"redefine", Sy_bit(V_REDEFINE), ~Sy_bit(V_REDEFINE) }, |
---|
| 498 | {"reading", Sy_bit(V_READING), ~Sy_bit(V_READING) }, |
---|
| 499 | {"loadLib", Sy_bit(V_LOAD_LIB), ~Sy_bit(V_LOAD_LIB) }, |
---|
| 500 | {"debugLib", Sy_bit(V_DEBUG_LIB), ~Sy_bit(V_DEBUG_LIB) }, |
---|
| 501 | {"loadProc", Sy_bit(V_LOAD_PROC), ~Sy_bit(V_LOAD_PROC) }, |
---|
| 502 | {"defRes", Sy_bit(V_DEF_RES), ~Sy_bit(V_DEF_RES) }, |
---|
| 503 | {"debugMem", Sy_bit(V_DEBUG_MEM), ~Sy_bit(V_DEBUG_MEM) }, |
---|
| 504 | {"usage", Sy_bit(V_SHOW_USE), ~Sy_bit(V_SHOW_USE) }, |
---|
| 505 | {"Imap", Sy_bit(V_IMAP), ~Sy_bit(V_IMAP) }, |
---|
| 506 | {"prompt", Sy_bit(V_PROMPT), ~Sy_bit(V_PROMPT) }, |
---|
| 507 | {"notWarnSB",Sy_bit(V_NSB), ~Sy_bit(V_NSB) }, |
---|
| 508 | /*special for "none" and also end marker for showOption:*/ |
---|
| 509 | {"ne", 0, 0 } |
---|
| 510 | }; |
---|
| 511 | |
---|
| 512 | BOOLEAN setOption(leftv res, leftv v) |
---|
| 513 | { |
---|
| 514 | char *n; |
---|
| 515 | do |
---|
| 516 | { |
---|
| 517 | n=v->name; |
---|
| 518 | if (n==NULL) return TRUE; |
---|
| 519 | v->name=NULL; |
---|
| 520 | |
---|
| 521 | int i; |
---|
| 522 | |
---|
[58b151c] | 523 | if(strcmp(n,"get")==0) |
---|
[0e1846] | 524 | { |
---|
[58b151c] | 525 | intvec *w=new intvec(2); |
---|
| 526 | (*w)[0]=test; |
---|
| 527 | (*w)[1]=verbose; |
---|
| 528 | res->rtyp=INTVEC_CMD; |
---|
| 529 | res->data=(void *)w; |
---|
| 530 | goto okay; |
---|
| 531 | } |
---|
| 532 | if(strcmp(n,"set")==0) |
---|
| 533 | { |
---|
| 534 | if((v->next!=NULL) |
---|
| 535 | &&(v->next->Typ()==INTVEC_CMD)) |
---|
[0e1846] | 536 | { |
---|
[58b151c] | 537 | v=v->next; |
---|
[9ea9c6] | 538 | intvec *w=(intvec*)v->Data(); |
---|
[58b151c] | 539 | test=(*w)[0]; |
---|
| 540 | verbose=(*w)[1]; |
---|
[9ea9c6] | 541 | |
---|
[58b151c] | 542 | if (TEST_OPT_INTSTRATEGY && (currRing!=NULL) && (currRing->ch>=2)) |
---|
| 543 | { |
---|
| 544 | test &=~Sy_bit(OPT_INTSTRATEGY); |
---|
| 545 | } |
---|
[0e1846] | 546 | goto okay; |
---|
[9ea9c6] | 547 | } |
---|
[58b151c] | 548 | } |
---|
[667247] | 549 | if(strcmp(n,"none")==0) |
---|
| 550 | { |
---|
| 551 | test=0; |
---|
| 552 | verbose=0; |
---|
| 553 | goto okay; |
---|
[9ea9c6] | 554 | } |
---|
[58b151c] | 555 | for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++) |
---|
| 556 | { |
---|
| 557 | if (strcmp(n,optionStruct[i].name)==0) |
---|
[0e1846] | 558 | { |
---|
[58b151c] | 559 | if (optionStruct[i].setval & validOpts) |
---|
| 560 | test |= optionStruct[i].setval; |
---|
| 561 | else |
---|
| 562 | Warn("cannot set option"); |
---|
| 563 | if (TEST_OPT_INTSTRATEGY && (currRing!=NULL) && (currRing->ch>=2)) |
---|
[0e1846] | 564 | { |
---|
[58b151c] | 565 | test &=~Sy_bit(OPT_INTSTRATEGY); |
---|
| 566 | } |
---|
| 567 | goto okay; |
---|
[0e1846] | 568 | } |
---|
[58b151c] | 569 | else if ((strncmp(n,"no",2)==0) |
---|
| 570 | && (strcmp(n+2,optionStruct[i].name)==0)) |
---|
[0e1846] | 571 | { |
---|
[667247] | 572 | if (optionStruct[i].setval & validOpts) |
---|
[0e1846] | 573 | { |
---|
[58b151c] | 574 | test &= optionStruct[i].resetval; |
---|
[0e1846] | 575 | } |
---|
[58b151c] | 576 | else |
---|
| 577 | Warn("cannot clear option"); |
---|
| 578 | goto okay; |
---|
[0e1846] | 579 | } |
---|
| 580 | } |
---|
[58b151c] | 581 | for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++) |
---|
[0e1846] | 582 | { |
---|
[58b151c] | 583 | if (strcmp(n,verboseStruct[i].name)==0) |
---|
[0e1846] | 584 | { |
---|
[58b151c] | 585 | verbose |= verboseStruct[i].setval; |
---|
| 586 | #ifdef YYDEBUG |
---|
| 587 | #if YYDEBUG |
---|
| 588 | if (BVERBOSE(V_YACC)) yydebug=1; |
---|
| 589 | else yydebug=0; |
---|
| 590 | #endif |
---|
| 591 | #endif |
---|
[0e1846] | 592 | goto okay; |
---|
| 593 | } |
---|
[58b151c] | 594 | else if ((strncmp(n,"no",2)==0) |
---|
| 595 | && (strcmp(n+2,verboseStruct[i].name)==0)) |
---|
[0e1846] | 596 | { |
---|
[58b151c] | 597 | verbose &= verboseStruct[i].resetval; |
---|
| 598 | #ifdef YYDEBUG |
---|
| 599 | #if YYDEBUG |
---|
| 600 | if (BVERBOSE(V_YACC)) yydebug=1; |
---|
| 601 | else yydebug=0; |
---|
| 602 | #endif |
---|
| 603 | #endif |
---|
| 604 | goto okay; |
---|
[0e1846] | 605 | } |
---|
[58b151c] | 606 | } |
---|
| 607 | Werror("unknown option `%s`",n); |
---|
[0e1846] | 608 | okay: |
---|
| 609 | FreeL((ADDRESS)n); |
---|
| 610 | v=v->next; |
---|
[9ea9c6] | 611 | } while (v!=NULL); |
---|
[0e1846] | 612 | return FALSE; |
---|
| 613 | } |
---|
| 614 | |
---|
[58b151c] | 615 | void showOption() |
---|
[0e1846] | 616 | { |
---|
| 617 | int i; |
---|
| 618 | BITSET tmp; |
---|
| 619 | |
---|
[58b151c] | 620 | PrintS("//options:"); |
---|
| 621 | if ((test!=0)||(verbose!=0)) |
---|
[0e1846] | 622 | { |
---|
| 623 | tmp=test; |
---|
[58b151c] | 624 | if(tmp) |
---|
[0e1846] | 625 | { |
---|
| 626 | for (i=0; optionStruct[i].setval!=0; i++) |
---|
| 627 | { |
---|
| 628 | if (optionStruct[i].setval & test) |
---|
| 629 | { |
---|
| 630 | Print(" %s",optionStruct[i].name); |
---|
| 631 | tmp &=optionStruct[i].resetval; |
---|
| 632 | } |
---|
| 633 | } |
---|
| 634 | for (i=0; i<32; i++) |
---|
| 635 | { |
---|
| 636 | if (tmp & Sy_bit(i)) Print(" %d",i); |
---|
| 637 | } |
---|
| 638 | } |
---|
| 639 | tmp=verbose; |
---|
| 640 | if (tmp) |
---|
| 641 | { |
---|
| 642 | for (i=0; verboseStruct[i].setval!=0; i++) |
---|
| 643 | { |
---|
| 644 | if (verboseStruct[i].setval & tmp) |
---|
| 645 | { |
---|
| 646 | Print(" %s",verboseStruct[i].name); |
---|
| 647 | tmp &=verboseStruct[i].resetval; |
---|
| 648 | } |
---|
| 649 | } |
---|
| 650 | for (i=1; i<32; i++) |
---|
| 651 | { |
---|
[58b151c] | 652 | if (tmp & Sy_bit(i)) Print(" %d",i+32); |
---|
[0e1846] | 653 | } |
---|
| 654 | } |
---|
[58b151c] | 655 | PrintLn(); |
---|
[0e1846] | 656 | } |
---|
[58b151c] | 657 | else |
---|
| 658 | PrintS(" none\n"); |
---|
[0e1846] | 659 | } |
---|
| 660 | |
---|
[9ea9c6] | 661 | char * versionString() |
---|
| 662 | { |
---|
[38cfbb] | 663 | StringSet("\t"); |
---|
[9ea9c6] | 664 | #ifdef HAVE_FACTORY |
---|
[97454d] | 665 | StringAppend("factory(%s),", factoryVersion); |
---|
[9ea9c6] | 666 | #endif |
---|
| 667 | #ifdef HAVE_LIBFAC_P |
---|
[38cfbb] | 668 | StringAppend("libfac(%s,%s),\n\t",libfac_version,libfac_date); |
---|
[9ea9c6] | 669 | #endif |
---|
| 670 | #ifdef HAVE_GMP |
---|
| 671 | #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR) |
---|
[38cfbb] | 672 | StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR); |
---|
[9ea9c6] | 673 | #elif defined (HAVE_SMALLGMP) |
---|
[38cfbb] | 674 | StringAppendS("SmallGMP(2.0.2.0),"); |
---|
[9ea9c6] | 675 | #else |
---|
[38cfbb] | 676 | StringAppendS("GMP(1.3),"); |
---|
[9ea9c6] | 677 | #endif |
---|
| 678 | #endif |
---|
| 679 | #ifdef HAVE_MPSR |
---|
[38cfbb] | 680 | StringAppend("MP(%s),\n\t",MP_VERSION); |
---|
[9ea9c6] | 681 | #endif |
---|
| 682 | #if defined(HAVE_READLINE) && !defined(FEREAD) |
---|
[38cfbb] | 683 | StringAppendS("libreadline,\n\t"); |
---|
[9ea9c6] | 684 | #endif |
---|
| 685 | #ifdef HAVE_FEREAD |
---|
[38cfbb] | 686 | StringAppendS("emulated libreadline,\n"); |
---|
| 687 | #endif |
---|
| 688 | #ifdef SRING |
---|
| 689 | StringAppendS("super algebra,"); |
---|
| 690 | #endif |
---|
| 691 | #ifdef DRING |
---|
| 692 | StringAppendS("Weyl algebra,"); |
---|
| 693 | #endif |
---|
| 694 | #ifdef HAVE_DBM |
---|
| 695 | StringAppendS("DBM,"); |
---|
[9ea9c6] | 696 | #endif |
---|
| 697 | #ifdef HAVE_INFO |
---|
[38cfbb] | 698 | StringAppendS("info,"); |
---|
[9ea9c6] | 699 | #endif |
---|
| 700 | #ifdef TEST |
---|
[38cfbb] | 701 | StringAppendS("TESTs,"); |
---|
[9ea9c6] | 702 | #endif |
---|
| 703 | #if YYDEBUG |
---|
[38cfbb] | 704 | StringAppendS("YYDEBUG=1,"); |
---|
[9ea9c6] | 705 | #endif |
---|
| 706 | #ifdef MDEBUG |
---|
[38cfbb] | 707 | StringAppend("MDEBUG=%d,",MDEBUG); |
---|
| 708 | #endif |
---|
[275397] | 709 | #ifdef PDEBUG |
---|
| 710 | StringAppend("PDEBUG,"); |
---|
| 711 | #endif |
---|
| 712 | #ifdef KDEBUG |
---|
| 713 | StringAppend("KDEBUG,"); |
---|
| 714 | #endif |
---|
[38cfbb] | 715 | #ifdef TEST_MAC_ORDER |
---|
| 716 | StringAppendS("mac_order,"); |
---|
[9ea9c6] | 717 | #endif |
---|
| 718 | #ifndef __OPTIMIZE__ |
---|
[38cfbb] | 719 | StringAppend("-g,"); |
---|
[9ea9c6] | 720 | #endif |
---|
[38cfbb] | 721 | StringAppend("random=%d\n",siRandomStart); |
---|
[1caa72] | 722 | return StringAppend("search path %s", feGetSearchPath()); |
---|
[9ea9c6] | 723 | } |
---|