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