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