source: git/Singular/tesths.cc @ dfc6b54

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