source: git/Singular/tesths.cc @ 07dacd

spielwiese
Last change on this file since 07dacd was 07dacd, checked in by Hans Schönemann <hannes@…>, 27 years ago
* hannes: clean up unused code: binom.cc extra.cc scanner.cc scanner.l numbers.cc numbers.h recovery with setjmp/longjmp: tesths.cc cntrlc.cc cntrlc.h changed error messages: ipassign.cc git-svn-id: file:///usr/local/Singular/svn/trunk@479 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 7.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: tesths.cc,v 1.20 1997-07-01 15:41:55 Singular Exp $ */
5
6/*
7* ABSTRACT - initialize SINGULARs components, run Script and start SHELL
8*/
9
10#ifndef macintosh
11#include <unistd.h>
12#endif
13#include <string.h>
14#include <stdio.h>
15#include <stddef.h>
16#include <stdlib.h>
17#include <time.h>
18#include <errno.h>
19#include "version.h"
20#include "mod2.h"
21#include "tok.h"
22#include "ipshell.h"
23#include "febase.h"
24#include "cntrlc.h"
25#include "mmemory.h"
26#include "silink.h"
27#include "timer.h"
28
29/* version strings */
30#ifdef HAVE_FACTORY
31#define SI_DONT_HAVE_GLOBAL_VARS
32#include <factory.h>
33#endif
34#ifdef HAVE_LIBFAC_P
35  extern const char * libfac_version;
36  extern const char * libfac_date;
37#endif
38#ifdef HAVE_GMP
39extern "C" {
40#include <gmp.h>
41}
42#endif
43#ifdef HAVE_MPSR
44#include <MP_Config.h>
45#endif
46
47/*0 implementation*/
48int main(          /* main entry to Singular */
49    int argc,      /* number of parameter */
50    char** argv)   /* parameter array */
51{
52  char * thisfile;
53  /* initialize components */
54  siRandomStart=inits();
55#ifdef INIT_BUG
56  jjInitTab1();
57#endif
58#ifdef GENTABLE
59  extern ttGen1();
60  extern ttGen2();
61  #ifndef macintosh
62    extern mpsr_ttGen(); // For initialization of (CMD, MP_COP) tables
63    mpsr_ttGen();
64  #endif
65  ttGen1();
66  ttGen2();
67#else
68  int i;
69  thisfile = argv[0];
70  /*. process parameters */
71  for (;(argc > 1) && (!feBatch); --argc, ++argv)
72  {
73    if (strcmp(argv[1], "-m") == 0)
74    {
75      {
76        if (argc > 2)
77        {
78          char* ptr = NULL;
79#ifdef HAVE_STRTOD         
80          double mintime = strtod(argv[2], &ptr);
81          if (errno != ERANGE && ptr != argv[2])
82#else
83          double mintime = 0;
84          sscanf(argv[2],"%f", &mintime);
85          if (mintime != 0.0)
86#endif
87          {
88            argc--;
89            argv++;
90            SetMinDisplayTime(mintime);
91          }
92          else
93            fprintf(stderr, "Can not convert %s to a float\n", argv[2]);
94        }
95        else
96        {
97          fprintf(stderr, "Need a float to set mintime");
98        }
99      }
100    }
101    else if (strcmp(argv[1], "-d") == 0)
102    {
103      if (argc > 2)
104      {
105        char* ptr = NULL;
106#ifdef HAVE_STRTOL       
107        long res = strtol(argv[2], &ptr, 10);
108        if (errno != ERANGE && ptr != argv[2] && res > 0)
109#else
110        long res = 0;
111        sscanf(argv[2],"%d", &res);
112        if (res > 0)
113#endif         
114        {
115          argc--;
116          argv++;
117          SetTimerResolution(res);
118        }
119        else
120          fprintf(stderr,"Can not convert %s to an integer > 0\n", argv[2]);
121      }
122      else
123      {
124        fprintf(stderr,"Need an integer to set timer resolution");
125      }
126    }
127    else
128    {
129   
130      if ((argv[1][0] != '-') ||(argv[1][1] == '-'))
131        break;
132      for (i=1;argv[1][i]!='\0';i++)
133      {
134        switch (argv[1][i])
135        {
136            case 'V':
137            case 'v':{
138              printf("Singular %s  %s  (%d)  %s %s\n",
139                     S_VERSION1,S_VERSION2,
140                     SINGULAR_VERSION_ID,__DATE__,__TIME__);
141              printf("with\n");
142#ifdef HAVE_FACTORY
143              printf("\tfactory (%s),\n", factoryVersion);
144#endif
145#ifdef HAVE_LIBFAC_P
146              printf("\tlibfac(%s,%s),\n",libfac_version,libfac_date);
147#endif
148#ifdef SRING
149              printf("\tsuper algebra,\n");
150#endif
151#ifdef DRING
152              printf("\tWeyl algebra,\n");
153#endif
154#ifdef HAVE_GMP
155#if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR)
156              printf("\tGMP(%d.%d),\n",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR);
157#elif defined (HAVE_SMALLGMP)
158              printf("\tSmallGMP(2.0.2.0),\n");
159#else               
160              printf("\tGMP(1.3),\n");
161#endif             
162#endif
163#ifdef HAVE_DBM
164              printf("\tDBM,\n");
165#endif
166#ifdef HAVE_MPSR
167              printf("\tMP(%s),\n",MP_VERSION);
168#endif
169#if defined(HAVE_READLINE) && !defined(FEREAD)
170              printf("\tlibreadline,\n");
171#endif
172#ifdef HAVE_FEREAD
173              printf("\temulated libreadline,\n");
174#endif
175#ifdef HAVE_INFO
176              printf("\tinfo,\n");
177#else             
178              printf("\twithout info,\n");
179#endif
180#ifdef TEST
181              printf("\tTESTs,\n");
182#endif
183#if YYDEBUG
184              printf("\tYYDEBUG=1,\n");
185#endif
186#ifdef MDEBUG
187              printf("\tMDEBUG=%d,\n",MDEBUG);
188#endif
189#ifndef __OPTIMIZE__
190              printf("\t-g,\n");
191#endif
192              printf("\trandom=%d\n",siRandomStart);
193#ifdef MSDOS
194              char *p=getenv("SPATH");
195#else
196              char *p=getenv("SINGULARPATH");
197#endif
198              if (p!=NULL)
199                printf("search path:%s:%s\n\n",p,SINGULAR_DATADIR);
200              else
201                printf("search path:%s\n\n", SINGULAR_DATADIR);
202              break;
203            }
204            case 'e': if ((argv[1][i+1]>'0') && (argv[1][i+1]<='9'))
205            {
206              i++;
207              si_echo = (int)(argv[1][i] - '0');
208            }
209            else si_echo = 2;
210            break;
211            case 'r': siRandomStart = 0;
212              while((argv[1][i+1]>='0') && (argv[1][i+1]<='9'))
213              {
214                i++;
215                siRandomStart = siRandomStart*10+(int)(argv[1][i] - '0');
216              }
217              #ifdef buildin_rand
218                siSeed=siRandomStart;
219              #else
220                srand((unsigned int)siRandomStart);
221              #endif
222              #ifdef HAVE_FACTORY
223                factoryseed(siRandomStart);
224              #endif 
225              break;
226            case 'x': tclmode=TRUE;
227              break;
228#ifdef HAVE_MPSR
229            case 'b': feBatch=TRUE;
230#endif
231            case 'q': verbose &= ~(Sy_bit(0)|Sy_bit(V_LOAD_LIB));
232              break;
233            case 't':
234#ifdef HAVE_FEREAD
235              fe_use_fgets=TRUE;
236#endif
237              break;
238            default : printf("Unknown option -%c\n",argv[1][i]);
239              printf("Usage: %s [-bemqtvx] [file]\n",thisfile);
240              exit(1);
241        }
242      }
243    }
244  }
245 
246
247  /*. say hello */
248  if (BVERBOSE(0))
249  {
250    printf(
251"              Welcome to SINGULAR                  /\n"
252"           A Computer Algebra System             o<\n"
253" for Commutative Algebra and Algebraic Geometry    \\\n\n"
254"by: G.-M. Greuel, G. Pfister, H. Schoenemann\n"
255"Fachbereich Mathematik der Universitaet, D-67653 Kaiserslautern\n"
256"contributions: O.Bachmann,W.Decker,H.Grassmann,B.Martin,M.Messollen,W.Neumann,\n"
257"W.Pohl,T.Siebert,R.Stobbe                 e-mail: singular@mathematik.uni-kl.de\n");
258    printf("%s  %s  (%d)",S_VERSION1,S_VERSION2, SINGULAR_VERSION_ID);
259    printf("\n\nPlease note:  EVERY COMMAND MUST END WITH A SEMICOLON \";"
260           "\"\n(e.g. help; help command; help General syntax; help ring; quit;)\n\n");
261  }
262  else
263  if (!feBatch)
264  {
265#ifdef macintosh
266    memcpy(stderr,stdout,sizeof(FILE));
267#else
268    dup2(1,2);
269#endif
270  }
271  slStandardInit();
272#ifdef HAVE_DLD
273  dlInit(thisfile);
274#endif
275  myynest=0;
276  /* if script is given */
277  if ((argc > 1)&&(argv[1][0]!='-'))
278  {
279    /* read and run the Script */
280    iiPStart(NULL,argv[1],NULL);
281  }
282  /* start shell */
283  if (feBatch)
284  {
285#ifdef HAVE_MPSR
286    extern int Batch_do(int argc, char **argv);
287    return Batch_do(argc,argv);
288#else
289    fprintf(stderr, "Option -b not supported in this version");
290    return 1;
291#endif // HAVE_MPSR
292  }
293#ifndef macintosh
294#if defined(HAVE_FEREAD) || defined(HAVE_READLINE)
295  fe_set_input_mode();
296#endif
297#endif
298  setjmp(si_start_jmpbuf);
299  yyparse();
300#endif
301  return 0;
302}
Note: See TracBrowser for help on using the repository browser.