source: git/Singular/tesths.cc @ 3a20c1

fieker-DuValspielwiese
Last change on this file since 3a20c1 was 1caa72, checked in by Olaf Bachmann <obachman@…>, 26 years ago
1998-04-06 Olaf Bachmann <obachman@mathematik.uni-kl.de> * spSpolyLoop.h: neww calling interface for spGetSpolyLoop * kstd1.cc (kNF): moved strat->ak field initailization out of initBuchMora into single routines * febase.cc (feGetSearchPath): added feGetSearchPath; changed algorithm for searching files: $SINGULARPATH -> relative to executable -> burnt-in locations * added find_exec.c to get absolute pathname of executable git-svn-id: file:///usr/local/Singular/svn/trunk@1341 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.5 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: tesths.cc,v 1.32 1998-04-06 17:59:37 obachman 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 "ipid.h"
29#include "timer.h"
30#ifdef HAVE_FACTORY
31#define SI_DONT_HAVE_GLOBAL_VARS
32#include <factory.h>
33#endif
34
35
36/*0 implementation*/
37int main(          /* main entry to Singular */
38    int argc,      /* number of parameter */
39    char** argv)   /* parameter array */
40{
41  char * thisfile;
42  /* initialize components */
43  siRandomStart=inits();
44#ifdef INIT_BUG
45  jjInitTab1();
46#endif
47#ifdef GENTABLE
48  extern ttGen1();
49  extern ttGen2();
50  #ifndef macintosh
51    extern mpsr_ttGen(); // For initialization of (CMD, MP_COP) tables
52    mpsr_ttGen();
53  #endif
54  ttGen1();
55  ttGen2();
56#else
57  int i;
58  thisfile = argv[0];
59  BOOLEAN load_std_lib=TRUE;
60  feGetSearchPath(thisfile);
61 
62  /*. process parameters */
63  for (;(argc > 1) && (!feBatch); --argc, ++argv)
64  {
65    if (strcmp(argv[1], "-m") == 0)
66    {
67      {
68        if (argc > 2)
69        {
70          char* ptr = NULL;
71#ifdef HAVE_STRTOD
72          double mintime = strtod(argv[2], &ptr);
73          if (errno != ERANGE && ptr != argv[2])
74#else
75          double mintime = 0;
76          sscanf(argv[2],"%f", &mintime);
77          if (mintime != 0.0)
78#endif
79          {
80            argc--;
81            argv++;
82            SetMinDisplayTime(mintime);
83          }
84          else
85            fprintf(stderr, "Can not convert %s to a float\n", argv[2]);
86        }
87        else
88        {
89          fprintf(stderr, "Need a float to set mintime");
90        }
91      }
92    }
93    else if (strcmp(argv[1], "-d") == 0)
94    {
95     
96      if (argc > 2)
97      {
98        char* ptr = NULL;
99        // OLAF: try to avoid using long:
100#ifdef HAVE_STRTOL
101        long res = strtol(argv[2], &ptr, 10);
102        if (errno != ERANGE && ptr != argv[2] && res > 0)
103#else
104          long res = 0;
105        sscanf(argv[2],"%d", &res);
106        if (res > 0)
107#endif
108        {
109          argc--;
110          argv++;
111          i=0;
112          SetTimerResolution(res);
113        }
114        else
115          fprintf(stderr,"Can not convert %s to an integer > 0\n", argv[2]);
116      }
117      else
118      {
119        long res=0;
120        while ((argv[1][i+1]>='0') && (argv[1][i+1]<='9'))
121        {
122          i++;
123          res = res*10+(int)(argv[1][i] - '0');
124          SetTimerResolution(res);
125        }
126      }
127    }
128    else
129    {
130
131      if ((argv[1][0] != '-') ||(argv[1][1] == '-'))
132        break;
133      for (i=1;argv[1][i]!='\0';i++)
134      {
135        switch (argv[1][i])
136        {
137            case 'V':
138            case 'v':{
139              printf("Singular %s  %s  (%d)  %s %s\n",
140                     S_VERSION1,S_VERSION2,
141                     SINGULAR_VERSION_ID,__DATE__,__TIME__);
142              printf("with\n");
143              printf(versionString());
144              printf("\n\n");
145              break;
146            }
147            case 'e': if ((argv[1][i+1]>'0') && (argv[1][i+1]<='9'))
148            {
149              i++;
150              si_echo = (int)(argv[1][i] - '0');
151            }
152            else si_echo = 1;
153            break;
154            case 'r': siRandomStart = 0;
155              while((argv[1][i+1]>='0') && (argv[1][i+1]<='9'))
156              {
157                i++;
158                siRandomStart = siRandomStart*10+(int)(argv[1][i] - '0');
159              }
160              #ifdef buildin_rand
161                siSeed=siRandomStart;
162              #else
163                srand((unsigned int)siRandomStart);
164              #endif
165              #ifdef HAVE_FACTORY
166                factoryseed(siRandomStart);
167              #endif
168              break;
169#ifdef HAVE_TCL       
170            case 'x': tclmode=TRUE;
171              break;
172#endif       
173#ifdef HAVE_MPSR
174            case 'b': feBatch=TRUE;
175#endif
176            case 'q': verbose &= ~(Sy_bit(0)|Sy_bit(V_LOAD_LIB));
177              break;
178            case 't':
179#if defined(HAVE_FEREAD) || defined(HAVE_READLINE)
180              fe_use_fgets=TRUE;
181#endif
182              break;
183            case 'n':
184              load_std_lib=FALSE;
185              break;
186            default : printf("Unknown option -%c\n",argv[1][i]);
187              printf("Usage: %s [-bemqtvx] [file]\n",thisfile);
188              exit(1);
189        }
190      }
191    }
192  }
193
194
195  /*. say hello */
196  if (BVERBOSE(0))
197  {
198    printf(
199"              Welcome to SINGULAR                  /\n"
200"           A Computer Algebra System             o<\n"
201" for Commutative Algebra and Algebraic Geometry    \\\n\n"
202"by: G.-M. Greuel, G. Pfister, H. Schoenemann\n"
203"Fachbereich Mathematik der Universitaet, D-67653 Kaiserslautern\n"
204"contributions: O.Bachmann,W.Decker,H.Grassmann,B.Martin,M.Messollen,W.Neumann,\n"
205"\tW.Pohl,T.Siebert,R.Stobbe,T.Wichmann\n"
206"e-mail: singular@mathematik.uni-kl.de\n");
207    printf("%s  %s  (%d)",S_VERSION1,S_VERSION2, SINGULAR_VERSION_ID);
208    printf("\n\nPlease note:  EVERY COMMAND MUST END WITH A SEMICOLON \";"
209           "\"\n(e.g. help; help command; help General syntax; help ring; quit;)\n\n");
210  }
211  else
212  if (!feBatch)
213  {
214#ifdef macintosh
215    memcpy(stderr,stdout,sizeof(FILE));
216#else
217    dup2(1,2);
218#endif
219  }
220  slStandardInit();
221  dlInit(thisfile);
222  myynest=0;
223  if (load_std_lib)
224  {
225    iiLibCmd(mstrdup("standard.lib"),TRUE);
226  } 
227  errorreported = 0;
228#ifndef macintosh
229#if defined(HAVE_FEREAD) || defined(HAVE_READLINE)
230  fe_set_input_mode();
231#endif
232#endif
233  setjmp(si_start_jmpbuf);
234  /* if script is given */
235  if ((argc > 1)&&(argv[1][0]!='-'))
236  {
237    /* read and run the Script */
238    argc=1;
239    newFile(argv[1]);
240  }
241  else
242  {
243    currentVoice=feInitStdin();
244  }
245  // set up voice for .singularc
246  {
247    char * where=(char *)AllocL(256);
248    FILE * rc=feFopen(".singularrc","r",where,FALSE);
249    if (rc!=NULL)
250    {
251      fclose(rc);
252      newFile(where);
253    }
254    FreeL((ADDRESS)where);
255  }
256  /* start shell */
257  if (feBatch)
258  {
259#ifdef HAVE_MPSR
260    extern int Batch_do(int argc, char **argv);
261    return Batch_do(argc,argv);
262#else
263    fprintf(stderr, "Option -b not supported in this version");
264    return 1;
265#endif // HAVE_MPSR
266  }
267  setjmp(si_start_jmpbuf);
268  yyparse();
269#endif
270  //Print("at very end\n");
271  m2_end(0);
272  return 0;
273}
Note: See TracBrowser for help on using the repository browser.