1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* $Id: tesths.cc,v 1.63 1999-08-03 16:33:44 obachman Exp $ */ |
---|
5 | |
---|
6 | /* |
---|
7 | * ABSTRACT - initialize SINGULARs components, run Script and start SHELL |
---|
8 | */ |
---|
9 | |
---|
10 | #include <unistd.h> |
---|
11 | #include <string.h> |
---|
12 | #include <stdio.h> |
---|
13 | #include <stddef.h> |
---|
14 | #include <stdlib.h> |
---|
15 | #include <time.h> |
---|
16 | #include <errno.h> |
---|
17 | #include "version.h" |
---|
18 | #include "mod2.h" |
---|
19 | #include "tok.h" |
---|
20 | #include "ipshell.h" |
---|
21 | #include "sing_dld.h" |
---|
22 | #include "febase.h" |
---|
23 | #include "cntrlc.h" |
---|
24 | #include "mmemory.h" |
---|
25 | #include "silink.h" |
---|
26 | #include "ipid.h" |
---|
27 | #include "timer.h" |
---|
28 | #include "sdb.h" |
---|
29 | #ifdef HAVE_FACTORY |
---|
30 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
31 | #include <factory.h> |
---|
32 | #endif |
---|
33 | #include "getopt.h" |
---|
34 | |
---|
35 | // define the long option names here |
---|
36 | #define LON_BATCH "batch" |
---|
37 | #define LON_BROWSER "browser" |
---|
38 | #define LON_EXECUTE "execute" |
---|
39 | #define LON_ECHO "echo" |
---|
40 | #define LON_HELP "help" |
---|
41 | #define LON_RANDOM "random" |
---|
42 | #define LON_QUIET "quiet" |
---|
43 | #define LON_NO_TTY "no-tty" |
---|
44 | #define LON_USER_OPTION "user-option" |
---|
45 | #define LON_VERSION "verbose" |
---|
46 | #define LON_MIN_TIME "min-time" |
---|
47 | #define LON_NO_STDLIB "no-stdlib" |
---|
48 | #define LON_NO_RC "no-rc" |
---|
49 | #define LON_TICKS_PER_SEC "ticks-per-sec" |
---|
50 | #define LON_TCLMODE "tclmode" |
---|
51 | #define LON_MP_PORT "MPport" |
---|
52 | #define LON_MP_HOST "MPhost" |
---|
53 | #define LON_NO_WARN "no-warn" |
---|
54 | #define LON_NO_OUT "no-out" |
---|
55 | #define LON_SDB "sdb" |
---|
56 | // undocumented options |
---|
57 | #ifdef HAVE_MPSR |
---|
58 | #define LON_MP_TRANSP "MPtransp" |
---|
59 | #define LON_MP_MODE "MPmode" |
---|
60 | #endif |
---|
61 | |
---|
62 | #define LONG_OPTION_RETURN 13 |
---|
63 | static struct option longopts[] = |
---|
64 | { |
---|
65 | #ifdef HAVE_MPSR |
---|
66 | {LON_BATCH, 0, 0, 'b'}, |
---|
67 | #endif |
---|
68 | {LON_EXECUTE, 1, 0, 'c'}, |
---|
69 | {LON_SDB, 0, 0, 'd'}, |
---|
70 | {LON_ECHO, 2, 0, 'e'}, |
---|
71 | {LON_HELP, 0, 0, 'h'}, |
---|
72 | {LON_QUIET, 0, 0, 'q'}, |
---|
73 | {LON_RANDOM, 1, 0, 'r'}, |
---|
74 | {LON_NO_TTY, 0, 0, 't'}, |
---|
75 | {LON_USER_OPTION, 1, 0, 'u'}, |
---|
76 | {LON_VERSION, 0, 0, 'v'}, |
---|
77 | #ifdef HAVE_TCL |
---|
78 | {LON_TCLMODE, 0, 0, 'x'}, |
---|
79 | #endif |
---|
80 | {LON_BROWSER, 1, 0, LONG_OPTION_RETURN}, |
---|
81 | {LON_NO_STDLIB, 0, 0, LONG_OPTION_RETURN}, |
---|
82 | {LON_NO_RC, 0, 0, LONG_OPTION_RETURN}, |
---|
83 | {LON_NO_WARN, 0, 0, LONG_OPTION_RETURN}, |
---|
84 | {LON_NO_OUT, 0, 0, LONG_OPTION_RETURN}, |
---|
85 | {LON_MIN_TIME, 1, 0, LONG_OPTION_RETURN}, |
---|
86 | #ifdef HAVE_MPSR |
---|
87 | {LON_MP_PORT, 1, 0, LONG_OPTION_RETURN}, |
---|
88 | {LON_MP_HOST, 1, 0, LONG_OPTION_RETURN}, |
---|
89 | #endif |
---|
90 | {LON_TICKS_PER_SEC, 1, 0, LONG_OPTION_RETURN}, |
---|
91 | // undocumented options |
---|
92 | #ifdef HAVE_MPSR |
---|
93 | {LON_MP_TRANSP, 1, 0, LONG_OPTION_RETURN}, |
---|
94 | {LON_MP_MODE, 1, 0, LONG_OPTION_RETURN}, |
---|
95 | #endif |
---|
96 | // terminator |
---|
97 | { 0, 0, 0, 0 } |
---|
98 | }; |
---|
99 | // #define SHORT_OPTS_STRING "bc:e::hqr:tu:v" |
---|
100 | #define SHORT_OPTS_STRING "bdhqtvxec:r:u:" |
---|
101 | |
---|
102 | struct sing_option |
---|
103 | { |
---|
104 | const char* name; // as in option |
---|
105 | const char* arg_name;// name of argument, if has_arg > 0 |
---|
106 | const char* help; // (short) help string |
---|
107 | char* val; // (default) value of option: 0: not set 1:set |
---|
108 | // string:"" if has_arg > 0 |
---|
109 | }; |
---|
110 | |
---|
111 | // mention only documented options here |
---|
112 | static struct sing_option sing_longopts[] = |
---|
113 | { |
---|
114 | #ifdef HAVE_MPSR |
---|
115 | {LON_BATCH, 0, "Run in MP batch mode", 0}, |
---|
116 | #endif |
---|
117 | {LON_BROWSER, "BROWSER", "Display help in BROWSER ([x,tk]info, netscape)", ""}, |
---|
118 | {LON_HELP, 0, "Print help message and exit", 0}, |
---|
119 | {LON_QUIET, 0, "Do not print start-up banner and library load messages", 0}, |
---|
120 | {LON_SDB, 0, "Enable sdb debugger (experimental)", 0}, |
---|
121 | {LON_NO_TTY, 0, "Do not redefine the terminal characteristics", 0}, |
---|
122 | {LON_VERSION, 0, "Print extended version and configuration info", 0}, |
---|
123 | #ifdef HAVE_TCL |
---|
124 | {LON_TCLMODE, 0, "Run in TCL mode, i.e., with TCL user interface", 0}, |
---|
125 | #endif |
---|
126 | {LON_ECHO, "VAL", "Set value of variable `echo' to (integer) VAL", ""}, |
---|
127 | {LON_EXECUTE, "STRING", "Execute STRING on start-up", ""}, |
---|
128 | {LON_RANDOM, "SEED", "Seed random generator with integer (integer) SEED", ""}, |
---|
129 | {LON_USER_OPTION, "STRING", "Return STRING on `system(\"--user-option\")'", ""}, |
---|
130 | {LON_NO_STDLIB, 0, "Do not load `standard.lib' on start-up", 0}, |
---|
131 | {LON_NO_RC, 0, "Do not execute `.singularrc' file on start-up", 0}, |
---|
132 | {LON_NO_WARN, 0, "Do not display warning messages", 0}, |
---|
133 | {LON_NO_OUT, 0, "Suppress all output", 0}, |
---|
134 | {LON_MIN_TIME, "SECS", "Do not display times smaller than SECS (in seconds)", "0.5"}, |
---|
135 | #ifdef HAVE_MPSR |
---|
136 | {LON_MP_PORT, "PORT", "Use PORT number for MP conections", ""}, |
---|
137 | {LON_MP_HOST, "HOST", "Use HOST for MP connections", ""}, |
---|
138 | #endif |
---|
139 | {LON_TICKS_PER_SEC, "TICKS", "Sets unit of timer to TICKS per second", "1"}, |
---|
140 | { 0, 0, 0, 0 } |
---|
141 | }; |
---|
142 | |
---|
143 | static struct sing_option* mainGetSingOption(const char* name) |
---|
144 | { |
---|
145 | int i = 0; |
---|
146 | while (sing_longopts[i].name != 0) |
---|
147 | { |
---|
148 | if (strcmp(name, sing_longopts[i].name) == 0) |
---|
149 | return &(sing_longopts[i]); |
---|
150 | i++; |
---|
151 | } |
---|
152 | return NULL; |
---|
153 | } |
---|
154 | |
---|
155 | void mainSetSingOptionValue(const char* name, char* value) |
---|
156 | { |
---|
157 | sing_option* sopt = mainGetSingOption(name); |
---|
158 | if (sopt != NULL) |
---|
159 | { |
---|
160 | sopt->val = value; |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | char* mainGetSingOptionValue(const char* name) |
---|
165 | { |
---|
166 | sing_option* sopt = mainGetSingOption(name); |
---|
167 | if (sopt!=NULL) |
---|
168 | return sopt->val; |
---|
169 | return NULL; |
---|
170 | } |
---|
171 | |
---|
172 | |
---|
173 | // Prints help message |
---|
174 | static void mainHelp(const char* name) |
---|
175 | { |
---|
176 | int i = 0; |
---|
177 | struct sing_option *sopt; |
---|
178 | char tmp[20]; |
---|
179 | |
---|
180 | printf("Singular version %s -- a CAS for polynomial computations. Usage:\n", S_VERSION1); |
---|
181 | printf(" %s [options] [file1 [file2 ...]]\n", name); |
---|
182 | printf("Options:\n"); |
---|
183 | |
---|
184 | while (longopts[i].name != 0) |
---|
185 | { |
---|
186 | sopt = mainGetSingOption(longopts[i].name); |
---|
187 | if (sopt != NULL) |
---|
188 | { |
---|
189 | if (longopts[i].has_arg > 0) |
---|
190 | { |
---|
191 | if (longopts[i].has_arg > 1) |
---|
192 | sprintf(tmp, "%s[=%s]", longopts[i].name, sopt->arg_name); |
---|
193 | else |
---|
194 | sprintf(tmp, "%s=%s", longopts[i].name, sopt->arg_name); |
---|
195 | |
---|
196 | printf(" %c%c --%-19s %s\n", |
---|
197 | (longopts[i].val != 0 ? '-' : ' '), |
---|
198 | (longopts[i].val != 0 ? longopts[i].val : ' '), |
---|
199 | tmp, |
---|
200 | sopt->help); |
---|
201 | } |
---|
202 | else |
---|
203 | { |
---|
204 | printf(" %c%c --%-19s %s\n", |
---|
205 | (longopts[i].val != 0 ? '-' : ' '), |
---|
206 | (longopts[i].val != 0 ? longopts[i].val : ' '), |
---|
207 | longopts[i].name, |
---|
208 | sopt->help); |
---|
209 | } |
---|
210 | } |
---|
211 | #ifndef NDEBUG |
---|
212 | else |
---|
213 | printf("--%s Undocumented\n", longopts[i].name); |
---|
214 | #endif |
---|
215 | i++; |
---|
216 | } |
---|
217 | |
---|
218 | printf("\nFor more information, type `help;' from within Singular or visit\n"); |
---|
219 | printf("http://www.mathematik.uni-kl.de/~zca/Singular or consult the\n"); |
---|
220 | printf("Singular manual (available as on-line info or printed manual).\n"); |
---|
221 | } |
---|
222 | |
---|
223 | // Prints usage message |
---|
224 | static void mainUsage(char* argv0) |
---|
225 | { |
---|
226 | printf("Use `%s --help' for a complete list of options\n", argv0); |
---|
227 | } |
---|
228 | |
---|
229 | #ifndef NDEBUG |
---|
230 | void mainOptionValues() |
---|
231 | { |
---|
232 | int i = 0; |
---|
233 | struct sing_option *sopt; |
---|
234 | |
---|
235 | while (longopts[i].name != 0) |
---|
236 | { |
---|
237 | sopt = mainGetSingOption(longopts[i].name); |
---|
238 | if (sopt != NULL) |
---|
239 | { |
---|
240 | if (sopt->val == NULL || sopt->val == (char*) 1) |
---|
241 | Print("// --%-10s %d\n", sopt->name, sopt->val); |
---|
242 | else |
---|
243 | Print("// --%-10s %s\n", sopt->name, sopt->val); |
---|
244 | } |
---|
245 | else |
---|
246 | Print("// --%s Undocumented \n", longopts[i].name); |
---|
247 | i++; |
---|
248 | } |
---|
249 | } |
---|
250 | #endif // NDEBUG |
---|
251 | |
---|
252 | BOOLEAN mainGetSingOptionValue(const char* name, char** val) |
---|
253 | { |
---|
254 | sing_option* sopt = mainGetSingOption(name); |
---|
255 | if (sopt == NULL) |
---|
256 | { |
---|
257 | *val = NULL; |
---|
258 | return FALSE; |
---|
259 | } |
---|
260 | else |
---|
261 | { |
---|
262 | *val = sopt->val; |
---|
263 | return TRUE; |
---|
264 | } |
---|
265 | } |
---|
266 | |
---|
267 | /*0 implementation*/ |
---|
268 | int main( /* main entry to Singular */ |
---|
269 | int argc, /* number of parameter */ |
---|
270 | char** argv) /* parameter array */ |
---|
271 | { |
---|
272 | char * thisfile; |
---|
273 | /* initialize components */ |
---|
274 | siRandomStart=inits(); |
---|
275 | #ifdef INIT_BUG |
---|
276 | jjInitTab1(); |
---|
277 | #endif |
---|
278 | #ifdef GENTABLE |
---|
279 | extern void ttGen1(); |
---|
280 | extern void ttGen2(); |
---|
281 | #ifndef __MWERKS__ |
---|
282 | extern mpsr_ttGen(); // For initialization of (CMD, MP_COP) tables |
---|
283 | mpsr_ttGen(); |
---|
284 | #endif |
---|
285 | ttGen1(); |
---|
286 | ttGen2(); |
---|
287 | #else |
---|
288 | thisfile = argv[0]; |
---|
289 | BOOLEAN load_std_lib=TRUE; |
---|
290 | BOOLEAN load_rc = TRUE; |
---|
291 | char* execute_string = NULL; |
---|
292 | int optc, option_index; |
---|
293 | |
---|
294 | // do this first, because -v might print version path |
---|
295 | feInitResources(thisfile); |
---|
296 | |
---|
297 | // parse command line options |
---|
298 | while((optc = getopt_long(argc, argv, |
---|
299 | SHORT_OPTS_STRING, longopts, &option_index)) |
---|
300 | != EOF) |
---|
301 | { |
---|
302 | switch(optc) |
---|
303 | { |
---|
304 | |
---|
305 | case 'b': |
---|
306 | #ifdef HAVE_MPSR |
---|
307 | feBatch=TRUE; |
---|
308 | mainSetSingOptionValue(LON_BATCH, (char*) 1); |
---|
309 | break; |
---|
310 | #else |
---|
311 | printf("%s: Option `-b' not supported in this configuration\n", argv[0]); |
---|
312 | mainUsage(argv[0]); |
---|
313 | exit(1); |
---|
314 | #endif |
---|
315 | case 'h': |
---|
316 | mainHelp(argv[0]); |
---|
317 | exit(0); |
---|
318 | |
---|
319 | case 'q': |
---|
320 | verbose &= ~(Sy_bit(0)|Sy_bit(V_LOAD_LIB)); |
---|
321 | mainSetSingOptionValue(LON_QUIET, (char*) 1); |
---|
322 | break; |
---|
323 | |
---|
324 | case 't': |
---|
325 | #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) |
---|
326 | fe_use_fgets=TRUE; |
---|
327 | #endif |
---|
328 | mainSetSingOptionValue(LON_NO_TTY, (char*) 1); |
---|
329 | break; |
---|
330 | |
---|
331 | case 'd': |
---|
332 | sdb_flags = 1; |
---|
333 | break; |
---|
334 | |
---|
335 | case 'v': |
---|
336 | printf("Singular for %s version %s (%d) %s %s\n", |
---|
337 | S_UNAME, S_VERSION1, |
---|
338 | SINGULAR_VERSION_ID,__DATE__,__TIME__); |
---|
339 | printf("with\n"); |
---|
340 | printf(versionString()); |
---|
341 | printf("\n\n"); |
---|
342 | mainSetSingOptionValue(LON_VERSION, (char*) 1); |
---|
343 | break; |
---|
344 | |
---|
345 | case 'x': |
---|
346 | #ifdef HAVE_TCL |
---|
347 | tclmode = TRUE; |
---|
348 | mainSetSingOptionValue(LON_TCLMODE, (char*) 1); |
---|
349 | verbose|=Sy_bit(V_SHOW_MEM); |
---|
350 | break; |
---|
351 | #else |
---|
352 | printf("%s: Option `-x' not supported in this configuration\n", argv[0]); |
---|
353 | mainUsage(argv[0]); |
---|
354 | exit(1); |
---|
355 | #endif |
---|
356 | |
---|
357 | case 'e': |
---|
358 | if (optarg != NULL) |
---|
359 | { |
---|
360 | errno = 0; |
---|
361 | si_echo = strtol(optarg, NULL, 10); |
---|
362 | if (errno) |
---|
363 | { |
---|
364 | printf("%s: `%s' invalid integer argument for option `--%s'\n", argv[0], optarg, LON_ECHO); |
---|
365 | mainUsage(argv[0]); |
---|
366 | exit(1); |
---|
367 | } |
---|
368 | if (si_echo < 0 || si_echo > 9) |
---|
369 | { |
---|
370 | printf("%s: `%s' argument for option `--%s' is not in valid range 0..9\n", |
---|
371 | argv[0], optarg, LON_ECHO); |
---|
372 | mainUsage(argv[0]); |
---|
373 | exit(1); |
---|
374 | } |
---|
375 | mainSetSingOptionValue(LON_ECHO, optarg); |
---|
376 | } |
---|
377 | else |
---|
378 | { |
---|
379 | si_echo = 1; |
---|
380 | mainSetSingOptionValue(LON_ECHO, "1"); |
---|
381 | } |
---|
382 | break; |
---|
383 | |
---|
384 | case 'c': |
---|
385 | execute_string = optarg; |
---|
386 | mainSetSingOptionValue(LON_EXECUTE, optarg); |
---|
387 | break; |
---|
388 | |
---|
389 | case 'r': |
---|
390 | errno = 0; |
---|
391 | siRandomStart = strtol(optarg, NULL, 10); |
---|
392 | if (errno || siRandomStart == 0) |
---|
393 | { |
---|
394 | printf("%s: `%s' invalid integer argument for option `--%s'\n", argv[0], optarg, LON_RANDOM); |
---|
395 | mainUsage(argv[0]); |
---|
396 | exit(1); |
---|
397 | } |
---|
398 | #ifdef buildin_rand |
---|
399 | siSeed=siRandomStart; |
---|
400 | #else |
---|
401 | srand((unsigned int)siRandomStart); |
---|
402 | #endif |
---|
403 | #ifdef HAVE_FACTORY |
---|
404 | factoryseed(siRandomStart); |
---|
405 | #endif |
---|
406 | mainSetSingOptionValue(LON_RANDOM, optarg); |
---|
407 | break; |
---|
408 | |
---|
409 | case 'u': |
---|
410 | mainSetSingOptionValue(LON_USER_OPTION, optarg); |
---|
411 | break; |
---|
412 | |
---|
413 | case LONG_OPTION_RETURN: |
---|
414 | if (strcmp(longopts[option_index].name, LON_NO_STDLIB) == 0) |
---|
415 | { |
---|
416 | load_std_lib = FALSE; |
---|
417 | mainSetSingOptionValue(LON_NO_STDLIB, (char*) 1); |
---|
418 | } |
---|
419 | else if (strcmp(longopts[option_index].name, LON_BROWSER) == 0) |
---|
420 | { |
---|
421 | mainSetSingOptionValue(LON_BROWSER, optarg); |
---|
422 | } |
---|
423 | else if (strcmp(longopts[option_index].name, LON_NO_RC) == 0) |
---|
424 | { |
---|
425 | load_rc = FALSE; |
---|
426 | mainSetSingOptionValue(LON_NO_RC, (char*) 1); |
---|
427 | } |
---|
428 | else if (strcmp(longopts[option_index].name, LON_NO_WARN) == 0) |
---|
429 | { |
---|
430 | feWarn = FALSE; |
---|
431 | mainSetSingOptionValue(LON_NO_WARN, (char*) 1); |
---|
432 | } |
---|
433 | else if (strcmp(longopts[option_index].name, LON_NO_OUT) == 0) |
---|
434 | { |
---|
435 | feOut = FALSE; |
---|
436 | mainSetSingOptionValue(LON_NO_OUT, (char*) 1); |
---|
437 | } |
---|
438 | else if (strcmp(longopts[option_index].name, LON_MIN_TIME) == 0) |
---|
439 | { |
---|
440 | double mintime = atof(optarg); |
---|
441 | if (mintime <= 0) |
---|
442 | { |
---|
443 | printf("%s: `%s' invalid float argument for option `--%s'\n", |
---|
444 | argv[0], optarg, LON_MIN_TIME); |
---|
445 | mainUsage(argv[0]); |
---|
446 | exit(1); |
---|
447 | } |
---|
448 | SetMinDisplayTime(mintime); |
---|
449 | mainSetSingOptionValue(LON_MIN_TIME, optarg); |
---|
450 | } |
---|
451 | #ifdef HAVE_MPSR |
---|
452 | else if (strcmp(longopts[option_index].name, LON_MP_PORT) == 0) |
---|
453 | { |
---|
454 | mainSetSingOptionValue(LON_MP_PORT, optarg); |
---|
455 | } |
---|
456 | else if (strcmp(longopts[option_index].name, LON_MP_HOST) == 0) |
---|
457 | { |
---|
458 | mainSetSingOptionValue(LON_MP_HOST, optarg); |
---|
459 | } |
---|
460 | #endif |
---|
461 | else if (strcmp(longopts[option_index].name, LON_TICKS_PER_SEC) == 0) |
---|
462 | { |
---|
463 | int ticks = atoi(optarg); |
---|
464 | if (ticks <= 0) |
---|
465 | { |
---|
466 | printf("%s: `%s' invalid integer argument for option `--%s'\n", |
---|
467 | argv[0], optarg, LON_TICKS_PER_SEC); |
---|
468 | mainUsage(argv[0]); |
---|
469 | exit(1); |
---|
470 | } |
---|
471 | SetTimerResolution(ticks); |
---|
472 | mainSetSingOptionValue(LON_TICKS_PER_SEC, optarg); |
---|
473 | } |
---|
474 | else |
---|
475 | // undocumented options |
---|
476 | #ifdef HAVE_MPSR |
---|
477 | if (strcmp(longopts[option_index].name, LON_MP_MODE) == 0 || |
---|
478 | strcmp(longopts[option_index].name, LON_MP_TRANSP) == 0) |
---|
479 | { |
---|
480 | /* ignore */ |
---|
481 | } |
---|
482 | else |
---|
483 | #endif |
---|
484 | assume(0); |
---|
485 | break; |
---|
486 | |
---|
487 | default: |
---|
488 | // Error message already emmited by getopt_long |
---|
489 | mainUsage(argv[0]); |
---|
490 | exit(1); |
---|
491 | } |
---|
492 | } |
---|
493 | /*. say hello */ |
---|
494 | { |
---|
495 | idhdl h; |
---|
496 | namespaceroot->push(NULL, "Top", 0, TRUE); |
---|
497 | #ifdef HAVE_NAMESPACES |
---|
498 | h=enterid(mstrdup("Top"), 0, PACKAGE_CMD, &IDROOT, TRUE); |
---|
499 | IDPACKAGE(h) = NSPACK(namespaceroot); |
---|
500 | IDPACKAGE(h)->language = LANG_TOP; |
---|
501 | #endif /* HAVE_NAMESPACES */ |
---|
502 | } |
---|
503 | if (BVERBOSE(0) && !feBatch) |
---|
504 | { |
---|
505 | printf( |
---|
506 | " SINGULAR /" |
---|
507 | #ifndef MAKE_DISTRIBUTION |
---|
508 | " Development" |
---|
509 | #endif |
---|
510 | "\n" |
---|
511 | " A Computer Algebra System for Polynomial Computations / version %s\n" |
---|
512 | " 0<\n" |
---|
513 | " by: G.-M. Greuel, G. Pfister, H. Schoenemann \\ %s\n" |
---|
514 | #ifdef SDRING |
---|
515 | " preliminary experimental version\n" |
---|
516 | #endif |
---|
517 | "FB Mathematik der Universitaet, D-67653 Kaiserslautern \\\n" |
---|
518 | , S_VERSION1,S_VERSION2); |
---|
519 | } |
---|
520 | else |
---|
521 | { |
---|
522 | sdb_flags = 0; |
---|
523 | if (!feBatch) |
---|
524 | { |
---|
525 | #ifdef __MWERKS__ |
---|
526 | memcpy(stderr,stdout,sizeof(FILE)); |
---|
527 | #else |
---|
528 | dup2(1,2); |
---|
529 | #endif |
---|
530 | } |
---|
531 | } |
---|
532 | slStandardInit(); |
---|
533 | dlInit(thisfile); |
---|
534 | myynest=0; |
---|
535 | if (load_std_lib) |
---|
536 | { |
---|
537 | int vv=verbose; |
---|
538 | verbose &= ~Sy_bit(V_LOAD_LIB); |
---|
539 | #ifdef HAVE_NAMESPACES |
---|
540 | iiLibCmd(mstrdup("standard.lib"),TRUE, TRUE); |
---|
541 | #else /* HAVE_NAMESPACES */ |
---|
542 | iiLibCmd(mstrdup("standard.lib"), TRUE); |
---|
543 | #endif /* HAVE_NAMESPACES */ |
---|
544 | verbose=vv; |
---|
545 | } |
---|
546 | errorreported = 0; |
---|
547 | mmMarkInitDBMCB(); |
---|
548 | #ifndef macintosh |
---|
549 | #if defined(HAVE_READLINE) |
---|
550 | fe_set_input_mode(); |
---|
551 | #endif |
---|
552 | #endif |
---|
553 | setjmp(si_start_jmpbuf); |
---|
554 | |
---|
555 | // Now, put things on the stack of stuff to do |
---|
556 | |
---|
557 | // Last thing to do is to execute given scripts |
---|
558 | if (optind < argc) |
---|
559 | { |
---|
560 | int i = argc - 1; |
---|
561 | while (i >= optind) |
---|
562 | { |
---|
563 | newFile(argv[i]); |
---|
564 | i--; |
---|
565 | } |
---|
566 | } |
---|
567 | else |
---|
568 | { |
---|
569 | currentVoice=feInitStdin(); |
---|
570 | } |
---|
571 | |
---|
572 | // before scripts, we execute -c, if it was given |
---|
573 | // now execute -c, if it was given |
---|
574 | if (execute_string != NULL) |
---|
575 | newBuffer(mstrdup(execute_string), BT_execute); |
---|
576 | |
---|
577 | // first thing, however, is to load .singularrc |
---|
578 | if (load_rc) |
---|
579 | { |
---|
580 | FILE * rc=myfopen(".singularrc","r"); |
---|
581 | if (rc!=NULL) |
---|
582 | { |
---|
583 | fclose(rc); |
---|
584 | newFile(".singularrc"); |
---|
585 | } |
---|
586 | else |
---|
587 | { |
---|
588 | char buf[MAXPATHLEN]; |
---|
589 | char *home = getenv("HOME"); |
---|
590 | if (home != NULL) |
---|
591 | { |
---|
592 | strcpy(buf, home); |
---|
593 | strcat(buf, "/.singularrc"); |
---|
594 | rc = myfopen(buf, "r"); |
---|
595 | if (rc != NULL) |
---|
596 | { |
---|
597 | fclose(rc); |
---|
598 | newFile(buf); |
---|
599 | } |
---|
600 | } |
---|
601 | } |
---|
602 | } |
---|
603 | |
---|
604 | /* start shell */ |
---|
605 | if (feBatch) |
---|
606 | { |
---|
607 | #ifdef HAVE_MPSR |
---|
608 | extern int Batch_do(const char* port, const char* host); |
---|
609 | return Batch_do(mainGetSingOptionValue(LON_MP_PORT), |
---|
610 | mainGetSingOptionValue(LON_MP_HOST)); |
---|
611 | #else |
---|
612 | assume(0); |
---|
613 | #endif |
---|
614 | } |
---|
615 | setjmp(si_start_jmpbuf); |
---|
616 | yyparse(); |
---|
617 | #endif |
---|
618 | //Print("at very end\n"); |
---|
619 | m2_end(0); |
---|
620 | return 0; |
---|
621 | } |
---|