source: git/Singular/tesths.cc @ fda54cc

spielwiese
Last change on this file since fda54cc was fda54cc, checked in by Hans Schönemann <hannes@…>, 27 years ago
* hannes: added factoryseed to '-r' option git-svn-id: file:///usr/local/Singular/svn/trunk@273 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 7.0 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: tesths.cc,v 1.13 1997-05-06 18:14:26 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*/
48char * thisfile;
49int main(          /* main entry to Singular */
50    int argc,      /* number of parameter */
51    char** argv)   /* parameter array */
52{
53  /* initialize components */
54  siRandomStart=inits();
55#ifdef INIT_BUG
56  jjInitTab1();
57#endif
58#ifdef GENTABLE
59  extern ttGen1();
60  extern ttGen2();
61#ifdef HAVE_MPSR   
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              printf("\tGMP(%d.%d),\n",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR);
156#endif
157#ifdef HAVE_DBM
158              printf("\tDBM,\n");
159#endif
160#ifdef HAVE_MPSR
161              printf("\tMP(%s),\n",MP_VERSION);
162#endif
163#if defined(HAVE_READLINE) && !defined(FEREAD)
164              printf("\tlibreadline,\n");
165#endif
166#ifdef HAVE_FEREAD
167              printf("\temulated libreadline,\n");
168#endif
169#ifdef TEST
170              printf("\tTESTs,\n");
171#endif
172#if YYDEBUG
173              printf("\tYYDEBUG=1,\n");
174#endif
175#ifdef MDEBUG
176              printf("\tMDEBUG=%d,\n",MDEBUG);
177#endif
178#ifndef __OPTIMIZE__
179              printf("\t-g,\n");
180#endif
181              printf("\trandom=%d\n",siRandomStart);
182#ifdef MSDOS
183              char *p=getenv("SPATH");
184#else
185              char *p=getenv("SINGULARPATH");
186#endif
187              if (p!=NULL)
188                printf("search path:%s:%s\n\n",p,SINGULAR_DATADIR);
189              else
190                printf("search path:%s\n\n", SINGULAR_DATADIR);
191              break;
192            }
193            case 'e': if ((argv[1][i+1]>'0') && (argv[1][i+1]<='9'))
194            {
195              i++;
196              si_echo = (int)(argv[1][i] - '0');
197            }
198            else si_echo = 2;
199            break;
200            case 'r': siRandomStart = 0;
201              while((argv[1][i+1]>='0') && (argv[1][i+1]<='9'))
202              {
203                i++;
204                siRandomStart = siRandomStart*10+(int)(argv[1][i] - '0');
205              }
206              #ifdef buildin_rand
207                siSeed=siRandomStart;
208              #else
209                srand((unsigned int)siRandomStart);
210              #endif
211              #ifdef HAVE_FACTORY
212                factoryseed(siRandomStart);
213              #endif 
214              break;
215            case 'x': tclmode=TRUE;
216              break;
217#ifdef HAVE_MPSR
218            case 'b': feBatch=TRUE;
219#endif
220            case 'q': verbose &= ~(Sy_bit(0)|Sy_bit(V_LOAD_LIB));
221              break;
222            case 't':
223#ifdef HAVE_FEREAD
224              fe_use_fgets=TRUE;
225#endif
226              break;
227            default : printf("Unknown option -%c\n",argv[1][i]);
228              printf("Usage: %s [-bemqtvx] [file]\n",thisfile);
229              exit(1);
230        }
231      }
232    }
233  }
234 
235
236  /*. say hello */
237  if (BVERBOSE(0))
238  {
239    printf(
240"              Welcome to SINGULAR                  /\n"
241"           A Computer Algebra System             o<\n"
242" for Commutative Algebra and Algebraic Geometry    \\\n\n"
243"by: G.-M. Greuel, G. Pfister, H. Schoenemann\n"
244"Fachbereich Mathematik der Universitaet, D-67653 Kaiserslautern\n"
245"contributions: O.Bachmann,W.Decker,H.Grassmann,B.Martin,M.Messollen,W.Neumann,\n"
246"W.Pohl,T.Siebert,R.Stobbe                 e-mail: singular@mathematik.uni-kl.de\n");
247    printf("%s  %s  (%d)",S_VERSION1,S_VERSION2, SINGULAR_VERSION_ID);
248    printf("\n\nPlease note:  EVERY COMMAND MUST END WITH A SEMICOLON \";"
249           "\"\n(e.g. help; help command; help General syntax; help ring; quit;)\n\n");
250  }
251  else
252  if (!feBatch)
253  {
254#ifdef macintosh
255    memcpy(stderr,stdout,sizeof(FILE));
256#else
257    dup2(1,2);
258#endif
259  }
260  slStandardInit();
261#ifdef HAVE_DLD
262  dlInit(thisfile);
263#endif
264  myynest=0;
265  /* if script is given */
266  if ((argc > 1)&&(argv[1][0]!='-'))
267  {
268    /* read and run the Script */
269    iiPStart(NULL,argv[1],NULL);
270  }
271  /* start shell */
272  if (feBatch)
273  {
274#ifdef HAVE_MPSR
275    extern int Batch_do(int argc, char **argv);
276    return Batch_do(argc,argv);
277#else
278    fprintf(stderr, "Option -b not supported in this version");
279    return 1;
280#endif // HAVE_MPSR
281  }
282#ifndef macintosh
283#if defined(HAVE_FEREAD) || defined(HAVE_READLINE)
284  fe_set_input_mode();
285#endif
286#endif
287  yyparse();
288#endif
289  return 0;
290}
Note: See TracBrowser for help on using the repository browser.