source: git/Singular/tesths.cc @ 8520b7

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