source: git/Singular/misc_ip.cc @ c7ede7

fieker-DuValspielwiese
Last change on this file since c7ede7 was c7ede7, checked in by Hans Schoenemann <hannes@…>, 7 years ago
port to mac: RL_VERSION_MAJOR 0
  • Property mode set to 100644
File size: 34.2 KB
Line 
1/*****************************************************************************\
2 * Computer Algebra System SINGULAR
3\*****************************************************************************/
4/** @file misc_ip.cc
5 *
6 * This file provides miscellaneous functionality.
7 *
8 * For more general information, see the documentation in misc_ip.h.
9 *
10 **/
11/*****************************************************************************/
12
13// include header files
14#define PLURAL_INTERNAL_DECLARATIONS 1
15
16#include "kernel/mod2.h"
17#include "misc/sirandom.h"
18
19#include "omalloc/omalloc.h"
20#include "misc/mylimits.h"
21
22#include "reporter/si_signals.h"
23
24#include "factory/factory.h"
25
26#include "coeffs/si_gmp.h"
27#include "coeffs/coeffs.h"
28#include "coeffs/OPAE.h"
29#include "coeffs/OPAEQ.h"
30#include "coeffs/OPAEp.h"
31#include "coeffs/flintcf_Q.h"
32#include "coeffs/flintcf_Zn.h"
33
34#include "polys/ext_fields/algext.h"
35#include "polys/ext_fields/transext.h"
36#include "polys/nc/gb_hack.h"
37
38#ifdef HAVE_SIMPLEIPC
39#include "Singular/links/simpleipc.h"
40#endif
41
42#include "misc_ip.h"
43#include "ipid.h"
44#include "feOpt.h"
45#include "links/silink.h"
46#include "mod_lib.h"
47#include "Singular/distrib.h"
48
49#include "misc/options.h"
50#include "misc/intvec.h"
51
52#include "polys/monomials/ring.h"
53#include "polys/templates/p_Procs.h"
54
55#include "kernel/GBEngine/kstd1.h"
56#include "kernel/oswrapper/timer.h"
57#include "resources/feResource.h"
58#include "kernel/oswrapper/feread.h"
59
60#include "subexpr.h"
61#include "cntrlc.h"
62#include "ipshell.h"
63
64#include "fehelp.h"
65
66#ifdef HAVE_READLINE
67  #ifdef READLINE_READLINE_H_OK
68    #include <readline/readline.h>
69  #endif
70  #ifndef RL_VERSION_MAJOR
71    #define RL_VERSION_MAJOR 0
72  #endif
73#endif
74
75static FORCE_INLINE void number2mpz(number n, mpz_t m){ number2mpz(n, coeffs_BIGINT, m); }
76static FORCE_INLINE number mpz2number(mpz_t m){ return mpz2number(m, coeffs_BIGINT); }
77
78
79void setListEntry(lists L, int index, mpz_t n)
80{ /* assumes n > 0 */
81  /* try to fit nn into an int: */
82  if (mpz_size1(n)<=1)
83  {
84    int ui=(int)mpz_get_si(n);
85    if ((((ui<<3)>>3)==ui)
86    && (mpz_cmp_si(n,(long)ui)==0))
87    {
88      L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)ui;
89      return;
90    }
91  }
92  number nn = mpz2number(n);
93  L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
94}
95
96void setListEntry_ui(lists L, int index, unsigned long ui)
97{ /* assumes n > 0 */
98  /* try to fit nn into an int: */
99  int i=(int)ui;
100  if ((((unsigned long)i)==ui) && (((i<<3)>>3)==i))
101  {
102    L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)i;
103  }
104  else
105  {
106    number nn = n_Init(ui, coeffs_BIGINT);
107    L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
108  }
109}
110
111/* Factoring with Pollard's rho method. stolen from GMP/demos */
112static unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6};
113
114static int factor_using_division (mpz_t t, unsigned int limit,lists primes, int *multiplicities,int &index, unsigned long bound)
115{
116  mpz_t q, r;
117  unsigned long int f;
118  int ai;
119  unsigned *addv = add;
120  unsigned int failures;
121  int bound_not_reached=1;
122
123  mpz_init (q);
124  mpz_init (r);
125
126  f = mpz_scan1 (t, 0);
127  mpz_div_2exp (t, t, f);
128  if (f>0)
129  {
130    setListEntry_ui(primes, index, 2);
131    multiplicities[index++] = f;
132  }
133
134  f=0;
135  loop
136  {
137    mpz_tdiv_qr_ui (q, r, t, 3);
138    if (mpz_cmp_ui (r, 0) != 0)
139        break;
140    mpz_set (t, q);
141    f++;
142  }
143  if (f>0)
144  {
145    setListEntry_ui(primes, index, 3);
146    multiplicities[index++] = f;
147  }
148  f=0;
149  loop
150  {
151    mpz_tdiv_qr_ui (q, r, t, 5);
152    if (mpz_cmp_ui (r, 0) != 0)
153        break;
154    mpz_set (t, q);
155    f++;
156  }
157  if (f>0)
158  {
159    setListEntry_ui(primes, index, 5);
160    multiplicities[index++] = f;
161  }
162
163  failures = 0;
164  f = 7;
165  ai = 0;
166  unsigned long last_f=0;
167  while (mpz_cmp_ui (t, 1) != 0)
168  {
169    mpz_tdiv_qr_ui (q, r, t, f);
170    if (mpz_cmp_ui (r, 0) != 0)
171    {
172      f += addv[ai];
173      if (mpz_cmp_ui (t, f) < 0)
174        break;
175      ai = (ai + 1) & 7;
176      failures++;
177      if (failures > limit)
178        break;
179      if ((bound!=0) && (f>bound))
180      {
181        bound_not_reached=0;
182        break;
183      }
184    }
185    else
186    {
187      mpz_swap (t, q);
188      if (f!=last_f)
189      {
190        setListEntry_ui(primes, index, f);
191        multiplicities[index]++;
192        index++;
193      }
194      else
195      {
196        multiplicities[index-1]++;
197      }
198      last_f=f;
199      failures = 0;
200    }
201  }
202
203  mpz_clear (q);
204  mpz_clear (r);
205  //printf("bound=%d,f=%d,failures=%d, reached=%d\n",bound,f,failures,bound_not_reached);
206  return bound_not_reached;
207}
208
209static void factor_using_pollard_rho (mpz_t n, unsigned long a, lists primes, int * multiplicities,int &index)
210{
211  mpz_t x, x1, y, P;
212  mpz_t t1, t2;
213  mpz_t last_f;
214  unsigned long long k, l, i;
215
216  mpz_init (t1);
217  mpz_init (t2);
218  mpz_init_set_si (last_f, 0);
219  mpz_init_set_si (y, 2);
220  mpz_init_set_si (x, 2);
221  mpz_init_set_si (x1, 2);
222  mpz_init_set_ui (P, 1);
223  k = 1;
224  l = 1;
225
226  while (mpz_cmp_ui (n, 1) != 0)
227  {
228    loop
229    {
230      do
231      {
232        mpz_mul (t1, x, x);
233        mpz_mod (x, t1, n);
234        mpz_add_ui (x, x, a);
235        mpz_sub (t1, x1, x);
236        mpz_mul (t2, P, t1);
237        mpz_mod (P, t2, n);
238
239        if (k % 32 == 1)
240        {
241          mpz_gcd (t1, P, n);
242          if (mpz_cmp_ui (t1, 1) != 0)
243            goto factor_found;
244          mpz_set (y, x);
245        }
246      }
247      while (--k != 0);
248
249      mpz_gcd (t1, P, n);
250      if (mpz_cmp_ui (t1, 1) != 0)
251        goto factor_found;
252
253      mpz_set (x1, x);
254      k = l;
255      l = 2 * l;
256      for (i = 0; i < k; i++)
257      {
258        mpz_mul (t1, x, x);
259        mpz_mod (x, t1, n);
260        mpz_add_ui (x, x, a);
261      }
262      mpz_set (y, x);
263    }
264
265  factor_found:
266    do
267    {
268      mpz_mul (t1, y, y);
269      mpz_mod (y, t1, n);
270      mpz_add_ui (y, y, a);
271      mpz_sub (t1, x1, y);
272      mpz_gcd (t1, t1, n);
273    }
274    while (mpz_cmp_ui (t1, 1) == 0);
275
276    mpz_divexact (n, n, t1);        /* divide by t1, before t1 is overwritten */
277
278    if (!mpz_probab_prime_p (t1, 10))
279    {
280      do
281      {
282        mp_limb_t a_limb;
283        mpn_random (&a_limb, (mp_size_t) 1);
284        a = a_limb;
285      }
286      while (a == 0);
287
288      factor_using_pollard_rho (t1, a, primes,multiplicities,index);
289    }
290    else
291    {
292      if (mpz_cmp(t1,last_f)==0)
293      {
294        multiplicities[index-1]++;
295      }
296      else
297      {
298        mpz_set(last_f,t1);
299        setListEntry(primes, index, t1);
300        multiplicities[index++] = 1;
301      }
302    }
303    mpz_mod (x, x, n);
304    mpz_mod (x1, x1, n);
305    mpz_mod (y, y, n);
306    if (mpz_probab_prime_p (n, 10))
307    {
308      if (mpz_cmp(n,last_f)==0)
309      {
310        multiplicities[index-1]++;
311      }
312      else
313      {
314        mpz_set(last_f,n);
315        setListEntry(primes, index, n);
316        multiplicities[index++] = 1;
317      }
318      mpz_set_ui(n,1);
319      break;
320    }
321  }
322
323  mpz_clear (P);
324  mpz_clear (t2);
325  mpz_clear (t1);
326  mpz_clear (x1);
327  mpz_clear (x);
328  mpz_clear (y);
329  mpz_clear (last_f);
330}
331
332static void factor_gmp (mpz_t t,lists primes,int *multiplicities,int &index,unsigned long bound)
333{
334  unsigned int division_limit;
335
336  if (mpz_sgn (t) == 0)
337    return;
338
339  /* Set the trial division limit according the size of t.  */
340  division_limit = mpz_sizeinbase (t, 2);
341  if (division_limit > 1000)
342    division_limit = 1000 * 1000;
343  else
344    division_limit = division_limit * division_limit;
345
346  if (factor_using_division (t, division_limit,primes,multiplicities,index,bound))
347  {
348    if (mpz_cmp_ui (t, 1) != 0)
349    {
350      if (mpz_probab_prime_p (t, 10))
351      {
352        setListEntry(primes, index, t);
353        multiplicities[index++] = 1;
354        mpz_set_ui(t,1);
355      }
356      else
357        factor_using_pollard_rho (t, 1L, primes,multiplicities,index);
358    }
359  }
360}
361/* n and pBound are assumed to be bigint numbers */
362lists primeFactorisation(const number n, const int pBound)
363{
364  int i;
365  int index=0;
366  mpz_t nn; number2mpz(n, nn);
367  lists primes = (lists)omAllocBin(slists_bin); primes->Init(1000);
368  int* multiplicities = (int*)omAlloc0(1000*sizeof(int));
369  int positive=1;
370
371  if (!n_IsZero(n, coeffs_BIGINT))
372  {
373    if (!n_GreaterZero(n, coeffs_BIGINT))
374    {
375      positive=-1;
376      mpz_neg(nn,nn);
377    }
378    factor_gmp(nn,primes,multiplicities,index,pBound);
379  }
380
381  lists primesL = (lists)omAllocBin(slists_bin);
382  primesL->Init(index);
383  for (i = 0; i < index; i++)
384  {
385    primesL->m[i].rtyp = primes->m[i].rtyp;
386    primesL->m[i].data = primes->m[i].data;
387    primes->m[i].rtyp=0;
388    primes->m[i].data=NULL;
389  }
390  primes->Clean(NULL);
391
392  lists multiplicitiesL = (lists)omAllocBin(slists_bin);
393  multiplicitiesL->Init(index);
394  for (i = 0; i < index; i++)
395  {
396    multiplicitiesL->m[i].rtyp = INT_CMD;
397    multiplicitiesL->m[i].data = (void*)(long)multiplicities[i];
398  }
399  omFree(multiplicities);
400
401  lists L=(lists)omAllocBin(slists_bin);
402  L->Init(3);
403  if (positive==-1) mpz_neg(nn,nn);
404  L->m[0].rtyp = LIST_CMD; L->m[0].data = (void*)primesL;
405  L->m[1].rtyp = LIST_CMD; L->m[1].data = (void*)multiplicitiesL;
406  setListEntry(L, 2, nn);
407
408  mpz_clear(nn);
409
410  return L;
411}
412
413#ifdef HAVE_STATIC
414#undef HAVE_DYN_RL
415#endif
416
417//#ifdef HAVE_LIBPARSER
418//#  include "libparse.h"
419//#endif /* HAVE_LIBPARSER */
420
421
422/*2
423* the renice routine for very large jobs
424* works only on unix machines,
425* testet on : linux, HP 9.0
426*
427*#include <sys/times.h>
428*#include <sys/resource.h>
429*extern "C" int setpriority(int,int,int);
430*void very_nice()
431*{
432*#ifndef NO_SETPRIORITY
433*  setpriority(PRIO_PROCESS,0,19);
434*#endif
435*  sleep(10);
436*}
437*/
438
439#include <string.h>
440#include <unistd.h>
441#include <stdio.h>
442#include <stddef.h>
443#include <stdlib.h>
444#include <time.h>
445
446
447void singular_example(char *str)
448{
449  assume(str!=NULL);
450  char *s=str;
451  while (*s==' ') s++;
452  char *ss=s;
453  while (*ss!='\0') ss++;
454  while (*ss<=' ')
455  {
456    *ss='\0';
457    ss--;
458  }
459  idhdl h=IDROOT->get(s,myynest);
460  if ((h!=NULL) && (IDTYP(h)==PROC_CMD))
461  {
462    char *lib=iiGetLibName(IDPROC(h));
463    if((lib!=NULL)&&(*lib!='\0'))
464    {
465      Print("// proc %s from lib %s\n",s,lib);
466      s=iiGetLibProcBuffer(IDPROC(h), 2);
467      if (s!=NULL)
468      {
469        if (strlen(s)>5)
470        {
471          iiEStart(s,IDPROC(h));
472          omFree((ADDRESS)s);
473          return;
474        }
475        else omFree((ADDRESS)s);
476      }
477    }
478  }
479  else
480  {
481    char sing_file[MAXPATHLEN];
482    FILE *fd=NULL;
483    char *res_m=feResource('m', 0);
484    if (res_m!=NULL)
485    {
486      sprintf(sing_file, "%s/%s.sing", res_m, s);
487      fd = feFopen(sing_file, "r");
488    }
489    if (fd != NULL)
490    {
491
492      int old_echo = si_echo;
493      int length, got;
494      char* s;
495
496      fseek(fd, 0, SEEK_END);
497      length = ftell(fd);
498      fseek(fd, 0, SEEK_SET);
499      s = (char*) omAlloc((length+20)*sizeof(char));
500      got = fread(s, sizeof(char), length, fd);
501      fclose(fd);
502      if (got != length)
503      {
504        Werror("Error while reading file %s", sing_file);
505      }
506      else
507      {
508        s[length] = '\0';
509        strcat(s, "\n;return();\n\n");
510        si_echo = 2;
511        iiEStart(s, NULL);
512        si_echo = old_echo;
513      }
514      omFree(s);
515    }
516    else
517    {
518      Werror("no example for %s", str);
519    }
520  }
521}
522
523
524const struct soptionStruct optionStruct[]=
525{
526  {"prot",         Sy_bit(OPT_PROT),           ~Sy_bit(OPT_PROT)   },
527  {"redSB",        Sy_bit(OPT_REDSB),          ~Sy_bit(OPT_REDSB)   },
528  {"notBuckets",   Sy_bit(OPT_NOT_BUCKETS),    ~Sy_bit(OPT_NOT_BUCKETS)   },
529  {"notSugar",     Sy_bit(OPT_NOT_SUGAR),      ~Sy_bit(OPT_NOT_SUGAR)   },
530  {"interrupt",    Sy_bit(OPT_INTERRUPT),      ~Sy_bit(OPT_INTERRUPT)   },
531  {"sugarCrit",    Sy_bit(OPT_SUGARCRIT),      ~Sy_bit(OPT_SUGARCRIT)   },
532  {"teach",        Sy_bit(OPT_DEBUG),          ~Sy_bit(OPT_DEBUG)  },
533  {"notSyzMinim",  Sy_bit(OPT_NO_SYZ_MINIM),   ~Sy_bit(OPT_NO_SYZ_MINIM)  },
534  /* 9 return SB in syz, quotient, intersect */
535  {"returnSB",     Sy_bit(OPT_RETURN_SB),      ~Sy_bit(OPT_RETURN_SB)  },
536  {"fastHC",       Sy_bit(OPT_FASTHC),         ~Sy_bit(OPT_FASTHC)  },
537  /* 11-19 sort in L/T */
538  {"staircaseBound",Sy_bit(OPT_STAIRCASEBOUND),~Sy_bit(OPT_STAIRCASEBOUND)  },
539  {"multBound",    Sy_bit(OPT_MULTBOUND),      ~Sy_bit(OPT_MULTBOUND)  },
540  {"degBound",     Sy_bit(OPT_DEGBOUND),       ~Sy_bit(OPT_DEGBOUND)  },
541  /* 25 no redTail(p)/redTail(s) */
542  {"redTail",      Sy_bit(OPT_REDTAIL),        ~Sy_bit(OPT_REDTAIL)  },
543  {"redThrough",   Sy_bit(OPT_REDTHROUGH),     ~Sy_bit(OPT_REDTHROUGH)  },
544  {"lazy",         Sy_bit(OPT_OLDSTD),         ~Sy_bit(OPT_OLDSTD)  },
545  {"intStrategy",  Sy_bit(OPT_INTSTRATEGY),    ~Sy_bit(OPT_INTSTRATEGY)  },
546  {"infRedTail",   Sy_bit(OPT_INFREDTAIL),     ~Sy_bit(OPT_INFREDTAIL)  },
547  /* 30: use not regularity for syz */
548  {"notRegularity",Sy_bit(OPT_NOTREGULARITY),  ~Sy_bit(OPT_NOTREGULARITY)  },
549  {"weightM",      Sy_bit(OPT_WEIGHTM),        ~Sy_bit(OPT_WEIGHTM)  },
550/*special for "none" and also end marker for showOption:*/
551  {"ne",           0,                          0 }
552};
553
554const struct soptionStruct verboseStruct[]=
555{
556  {"mem",      Sy_bit(V_SHOW_MEM),  ~Sy_bit(V_SHOW_MEM)   },
557  {"yacc",     Sy_bit(V_YACC),      ~Sy_bit(V_YACC)       },
558  {"redefine", Sy_bit(V_REDEFINE),  ~Sy_bit(V_REDEFINE)   },
559  {"reading",  Sy_bit(V_READING),   ~Sy_bit(V_READING)    },
560  {"loadLib",  Sy_bit(V_LOAD_LIB),  ~Sy_bit(V_LOAD_LIB)   },
561  {"debugLib", Sy_bit(V_DEBUG_LIB), ~Sy_bit(V_DEBUG_LIB)  },
562  {"loadProc", Sy_bit(V_LOAD_PROC), ~Sy_bit(V_LOAD_PROC)  },
563  {"defRes",   Sy_bit(V_DEF_RES),   ~Sy_bit(V_DEF_RES)    },
564  {"usage",    Sy_bit(V_SHOW_USE),  ~Sy_bit(V_SHOW_USE)   },
565  {"Imap",     Sy_bit(V_IMAP),      ~Sy_bit(V_IMAP)       },
566  {"prompt",   Sy_bit(V_PROMPT),    ~Sy_bit(V_PROMPT)     },
567  {"length",   Sy_bit(V_LENGTH),    ~Sy_bit(V_LENGTH)     },
568  {"notWarnSB",Sy_bit(V_NSB),       ~Sy_bit(V_NSB)        },
569  {"contentSB",Sy_bit(V_CONTENTSB), ~Sy_bit(V_CONTENTSB)  },
570  {"cancelunit",Sy_bit(V_CANCELUNIT),~Sy_bit(V_CANCELUNIT)},
571  {"modpsolve",Sy_bit(V_MODPSOLVSB),~Sy_bit(V_MODPSOLVSB)},
572  {"geometricSB",Sy_bit(V_UPTORADICAL),~Sy_bit(V_UPTORADICAL)},
573  {"findMonomials",Sy_bit(V_FINDMONOM),~Sy_bit(V_FINDMONOM)},
574  {"coefStrat",Sy_bit(V_COEFSTRAT), ~Sy_bit(V_COEFSTRAT)},
575  {"qringNF",  Sy_bit(V_QRING),     ~Sy_bit(V_QRING)},
576  {"warn",     Sy_bit(V_ALLWARN),   ~Sy_bit(V_ALLWARN)},
577  {"intersectSyz",Sy_bit(V_INTERSECT_SYZ), ~Sy_bit(V_INTERSECT_SYZ)},
578  {"intersectElim",Sy_bit(V_INTERSECT_ELIM), ~Sy_bit(V_INTERSECT_ELIM)},
579/*special for "none" and also end marker for showOption:*/
580  {"ne",         0,          0 }
581};
582
583BOOLEAN setOption(leftv res, leftv v)
584{
585  const char *n;
586  do
587  {
588    if (v->Typ()==STRING_CMD)
589    {
590      n=(const char *)v->CopyD(STRING_CMD);
591    }
592    else
593    {
594      if (v->name==NULL)
595        return TRUE;
596      if (v->rtyp==0)
597      {
598        n=v->name;
599        v->name=NULL;
600      }
601      else
602      {
603        n=omStrDup(v->name);
604      }
605    }
606
607    int i;
608
609    if(strcmp(n,"get")==0)
610    {
611      intvec *w=new intvec(2);
612      (*w)[0]=si_opt_1;
613      (*w)[1]=si_opt_2;
614      res->rtyp=INTVEC_CMD;
615      res->data=(void *)w;
616      goto okay;
617    }
618    if(strcmp(n,"set")==0)
619    {
620      if((v->next!=NULL)
621      &&(v->next->Typ()==INTVEC_CMD))
622      {
623        v=v->next;
624        intvec *w=(intvec*)v->Data();
625        si_opt_1=(*w)[0];
626        si_opt_2=(*w)[1];
627#if 0
628        if (TEST_OPT_INTSTRATEGY && (currRing!=NULL)
629        && rField_has_simple_inverse()
630        && !rField_is_Ring(currRing)
631        ) {
632          si_opt_1 &=~Sy_bit(OPT_INTSTRATEGY);
633        }
634#endif
635        goto okay;
636      }
637    }
638    if(strcmp(n,"none")==0)
639    {
640      si_opt_1=0;
641      si_opt_2=0;
642      goto okay;
643    }
644    for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++)
645    {
646      if (strcmp(n,optionStruct[i].name)==0)
647      {
648        if (optionStruct[i].setval & validOpts)
649        {
650          si_opt_1 |= optionStruct[i].setval;
651          // optOldStd disables redthrough
652          if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD))
653            si_opt_1 &= ~Sy_bit(OPT_REDTHROUGH);
654        }
655        else
656          Warn("cannot set option");
657#if 0
658        if (TEST_OPT_INTSTRATEGY && (currRing!=NULL)
659        && rField_has_simple_inverse()
660        && !rField_is_Ring(currRing)
661        ) {
662          test &=~Sy_bit(OPT_INTSTRATEGY);
663        }
664#endif
665        goto okay;
666      }
667      else if ((strncmp(n,"no",2)==0)
668      && (strcmp(n+2,optionStruct[i].name)==0))
669      {
670        if (optionStruct[i].setval & validOpts)
671        {
672          si_opt_1 &= optionStruct[i].resetval;
673        }
674        else
675          Warn("cannot clear option");
676        goto okay;
677      }
678    }
679    for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++)
680    {
681      if (strcmp(n,verboseStruct[i].name)==0)
682      {
683        si_opt_2 |= verboseStruct[i].setval;
684        #ifdef YYDEBUG
685        #if YYDEBUG
686        /*debugging the bison grammar --> grammar.cc*/
687        extern int    yydebug;
688        if (BVERBOSE(V_YACC)) yydebug=1;
689        else                  yydebug=0;
690        #endif
691        #endif
692        goto okay;
693      }
694      else if ((strncmp(n,"no",2)==0)
695      && (strcmp(n+2,verboseStruct[i].name)==0))
696      {
697        si_opt_2 &= verboseStruct[i].resetval;
698        #ifdef YYDEBUG
699        #if YYDEBUG
700        /*debugging the bison grammar --> grammar.cc*/
701        extern int    yydebug;
702        if (BVERBOSE(V_YACC)) yydebug=1;
703        else                  yydebug=0;
704        #endif
705        #endif
706        goto okay;
707      }
708    }
709    Werror("unknown option `%s`",n);
710  okay:
711    if (currRing != NULL)
712      currRing->options = si_opt_1 & TEST_RINGDEP_OPTS;
713    omFree((ADDRESS)n);
714    v=v->next;
715  } while (v!=NULL);
716
717   // set global variable to show memory usage
718  extern int om_sing_opt_show_mem;
719  if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1;
720  else om_sing_opt_show_mem = 0;
721
722  return FALSE;
723}
724
725char * showOption()
726{
727  int i;
728  BITSET tmp;
729
730  StringSetS("//options:");
731  if ((si_opt_1!=0)||(si_opt_2!=0))
732  {
733    tmp=si_opt_1;
734    if(tmp)
735    {
736      for (i=0; optionStruct[i].setval!=0; i++)
737      {
738        if (optionStruct[i].setval & tmp)
739        {
740          StringAppend(" %s",optionStruct[i].name);
741          tmp &=optionStruct[i].resetval;
742        }
743      }
744      for (i=0; i<32; i++)
745      {
746        if (tmp & Sy_bit(i)) StringAppend(" %d",i);
747      }
748    }
749    tmp=si_opt_2;
750    if (tmp)
751    {
752      for (i=0; verboseStruct[i].setval!=0; i++)
753      {
754        if (verboseStruct[i].setval & tmp)
755        {
756          StringAppend(" %s",verboseStruct[i].name);
757          tmp &=verboseStruct[i].resetval;
758        }
759      }
760      for (i=1; i<32; i++)
761      {
762        if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
763      }
764    }
765    return StringEndS();
766  }
767  StringAppendS(" none");
768  return StringEndS();
769}
770
771/* version strings */
772#ifdef HAVE_FLINT
773extern "C"
774{
775#ifndef __GMP_BITS_PER_MP_LIMB
776#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
777#endif
778#include <flint/flint.h>
779}
780#endif
781
782#ifndef MAKE_DISTRIBUTION
783const char *singular_date=__DATE__ " " __TIME__;
784#endif
785
786char * versionString(/*const bool bShowDetails = false*/ )
787{
788  StringSetS("");
789  StringAppend("Singular for %s version %s (%d, %d bit) %s #%s",
790               S_UNAME, VERSION, // SINGULAR_VERSION,
791               SINGULAR_VERSION, sizeof(void*)*8,
792#ifdef MAKE_DISTRIBUTION
793               VERSION_DATE, GIT_VERSION);
794#else
795               singular_date, GIT_VERSION);
796#endif
797  StringAppendS("\nwith\n\t");
798
799#if defined(mpir_version)
800              StringAppend("MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
801#elif defined(gmp_version)
802              // #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR)
803              //              StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR);
804              StringAppend("GMP(%s),", gmp_version);
805#endif
806#ifdef HAVE_NTL
807#include <NTL/version.h>
808              StringAppend("NTL(%s),",NTL_VERSION);
809#endif
810
811#ifdef HAVE_FLINT
812              StringAppend("FLINT(%s),",version);
813#endif
814              StringAppend("factory(%s),\n\t", factoryVersion);
815#if defined(HAVE_DYN_RL)
816              if (fe_fgets_stdin==fe_fgets_dummy)
817                StringAppendS("no input,");
818              else if (fe_fgets_stdin==fe_fgets)
819                StringAppendS("fgets,");
820              if (fe_fgets_stdin==fe_fgets_stdin_drl)
821                StringAppend("dynamic readline%d),",RL_VERSION_MAJOR);
822              #ifdef HAVE_FEREAD
823              else if (fe_fgets_stdin==fe_fgets_stdin_emu)
824                StringAppendS("emulated readline,");
825              #endif
826              else
827                StringAppendS("unknown fgets method,");
828#else
829  #if defined(HAVE_READLINE) && !defined(FEREAD)
830              StringAppend("static readline(%d),",RL_VERSION_MAJOR);
831  #else
832    #ifdef HAVE_FEREAD
833              StringAppendS("emulated readline,");
834    #else
835              StringAppendS("fgets,");
836    #endif
837  #endif
838#endif
839#ifdef HAVE_PLURAL
840              StringAppendS("Plural,");
841#endif
842#ifdef HAVE_DBM
843              StringAppendS("DBM,\n\t");
844#else
845              StringAppendS("\n\t");
846#endif
847#ifdef HAVE_DYNAMIC_LOADING
848              StringAppendS("dynamic modules,");
849#endif
850              if (p_procs_dynamic) StringAppendS("dynamic p_Procs,");
851#if YYDEBUG
852              StringAppendS("YYDEBUG=1,");
853#endif
854#ifdef HAVE_ASSUME
855             StringAppendS("ASSUME,");
856#endif
857#ifdef MDEBUG
858              StringAppend("MDEBUG=%d,",MDEBUG);
859#endif
860#ifdef OM_CHECK
861              StringAppend("OM_CHECK=%d,",OM_CHECK);
862#endif
863#ifdef OM_TRACK
864              StringAppend("OM_TRACK=%d,",OM_TRACK);
865#endif
866#ifdef OM_NDEBUG
867              StringAppendS("OM_NDEBUG,");
868#endif
869#ifdef SING_NDEBUG
870              StringAppendS("SING_NDEBUG,");
871#endif
872#ifdef PDEBUG
873              StringAppendS("PDEBUG,");
874#endif
875#ifdef KDEBUG
876              StringAppendS("KDEBUG,");
877#endif
878#ifdef __OPTIMIZE__
879              StringAppendS("CC:OPTIMIZE,");
880#endif
881#ifdef __OPTIMIZE_SIZE__
882              StringAppendS("CC:OPTIMIZE_SIZE,");
883#endif
884#ifdef __NO_INLINE__
885              StringAppendS("CC:NO_INLINE,");
886#endif
887#ifdef HAVE_EIGENVAL
888              StringAppendS("eigenvalues,");
889#endif
890#ifdef HAVE_GMS
891              StringAppendS("Gauss-Manin system,");
892#endif
893#ifdef HAVE_RATGRING
894              StringAppendS("ratGB,");
895#endif
896              StringAppend("random=%d\n",siRandomStart);
897
898#define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
899              StringAppendS("built-in modules: {");
900              SI_FOREACH_BUILTIN(SI_SHOW_BUILTIN_MODULE)
901              StringAppendS("}\n");
902#undef SI_SHOW_BUILTIN_MODULE
903
904              StringAppend("AC_CONFIGURE_ARGS = %s,\n"
905                           "CC = %s,FLAGS : %s,\n"
906                           "CXX = %s,FLAGS : %s,\n"
907                           "DEFS : %s,CPPFLAGS : %s,\n"
908                           "LDFLAGS : %s,LIBS : %s "
909#ifdef __GNUC__
910              "(ver: " __VERSION__ ")"
911#endif
912              "\n",AC_CONFIGURE_ARGS, CC,CFLAGS, CXX,CXXFLAGS,  DEFS,CPPFLAGS,  LDFLAGS,LIBS);
913              feStringAppendResources(0);
914              feStringAppendBrowsers(0);
915              StringAppendS("\n");
916              return StringEndS();
917}
918
919#ifdef PDEBUG
920#if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
921void p_SetRingOfLeftv(leftv l, ring r)
922{
923  switch(l->rtyp)
924  {
925    case INT_CMD:
926    case BIGINT_CMD:
927    case IDHDL:
928    case DEF_CMD:
929      break;
930    case POLY_CMD:
931    case VECTOR_CMD:
932    {
933      poly p=(poly)l->data;
934      while(p!=NULL) { p_SetRingOfLm(p,r); pIter(p); }
935      break;
936    }
937    case IDEAL_CMD:
938    case MODUL_CMD:
939    case MATRIX_CMD:
940    {
941      ideal I=(ideal)l->data;
942      int i;
943      for(i=IDELEMS(I)-1;i>=0;i--)
944      {
945        poly p=I->m[i];
946        while(p!=NULL) { p_SetRingOfLm(p,r); pIter(p); }
947      }
948      break;
949    }
950    case COMMAND:
951    {
952      command d=(command)l->data;
953      p_SetRingOfLeftv(&d->arg1, r);
954      if (d->argc>1) p_SetRingOfLeftv(&d->arg2, r);
955      if (d->argc>2) p_SetRingOfLeftv(&d->arg3, r);
956      break;
957    }
958    default:
959     printf("type %d not yet implementd in p_SetRingOfLeftv\n",l->rtyp);
960     break;
961  }
962}
963#endif
964#endif
965
966#if 0 /* debug only */
967void listall(int showproc)
968{
969      idhdl hh=basePack->idroot;
970      PrintS("====== Top ==============\n");
971      while (hh!=NULL)
972      {
973        if (showproc || (IDTYP(hh)!=PROC_CMD))
974        {
975          if (IDDATA(hh)==(void *)currRing) PrintS("(R)");
976          else if (IDDATA(hh)==(void *)currPack) PrintS("(P)");
977          else PrintS("   ");
978          Print("::%s, typ %s level %d data %lx",
979                 IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),(long)IDDATA(hh));
980          if (IDTYP(hh)==RING_CMD)
981            Print(" ref: %d\n",IDRING(hh)->ref);
982          else
983            PrintLn();
984        }
985        hh=IDNEXT(hh);
986      }
987      hh=basePack->idroot;
988      while (hh!=NULL)
989      {
990        if (IDDATA(hh)==(void *)basePack)
991          Print("(T)::%s, typ %s level %d data %lx\n",
992          IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),(long)IDDATA(hh));
993        else
994        if ((IDTYP(hh)==RING_CMD)
995        || (IDTYP(hh)==PACKAGE_CMD))
996        {
997          Print("====== %s ==============\n",IDID(hh));
998          idhdl h2=IDRING(hh)->idroot;
999          while (h2!=NULL)
1000          {
1001            if (showproc || (IDTYP(h2)!=PROC_CMD))
1002            {
1003              if ((IDDATA(h2)==(void *)currRing)
1004              && (IDTYP(h2)==RING_CMD))
1005                PrintS("(R)");
1006              else if (IDDATA(h2)==(void *)currPack) PrintS("(P)");
1007              else PrintS("   ");
1008              Print("%s::%s, typ %s level %d data %lx\n",
1009              IDID(hh),IDID(h2),Tok2Cmdname(IDTYP(h2)),IDLEV(h2),(long)IDDATA(h2));
1010            }
1011            h2=IDNEXT(h2);
1012          }
1013        }
1014        hh=IDNEXT(hh);
1015      }
1016      Print("currRing:%lx, currPack:%lx,basePack:%lx\n",(long)currRing,(long)currPack,(long)basePack);
1017      iiCheckPack(currPack);
1018}
1019#endif
1020
1021#ifndef SING_NDEBUG
1022void checkall()
1023{
1024      idhdl hh=basePack->idroot;
1025      while (hh!=NULL)
1026      {
1027        omCheckAddr(hh);
1028        omCheckAddr((ADDRESS)IDID(hh));
1029        if (RingDependend(IDTYP(hh)))
1030        {
1031          Print("%s typ %d in Top (should be in ring)\n",IDID(hh),IDTYP(hh));
1032        }
1033        hh=IDNEXT(hh);
1034      }
1035      hh=basePack->idroot;
1036      while (hh!=NULL)
1037      {
1038        if (IDTYP(hh)==PACKAGE_CMD)
1039        {
1040          idhdl h2=NULL;
1041          if (IDPACKAGE(hh)!=NULL)
1042            h2=IDPACKAGE(hh)->idroot;
1043          if (IDPACKAGE(hh)!=basePack)
1044          {
1045            while (h2!=NULL)
1046            {
1047              omCheckAddr(h2);
1048              omCheckAddr((ADDRESS)IDID(h2));
1049              if (RingDependend(IDTYP(h2)))
1050              {
1051                Print("%s typ %d in %s (should be in ring)\n",IDID(h2),IDTYP(h2),IDID(hh));
1052              }
1053              h2=IDNEXT(h2);
1054            }
1055          }
1056        }
1057        hh=IDNEXT(hh);
1058      }
1059}
1060#endif
1061
1062#include <sys/types.h>
1063#include <sys/stat.h>
1064#include <unistd.h>
1065
1066extern "C"
1067int singular_fstat(int fd, struct stat *buf)
1068{
1069  return si_fstat(fd,buf);
1070}
1071
1072/*2
1073* the global exit routine of Singular
1074*/
1075extern "C" {
1076/* Note: We cannot use a mutex here because mutexes are not async-safe, but
1077 * m2_end is called by sig_term_hdl(). Anyway, the race condition in the first
1078 * few lines of m2_end() should not matter.
1079 */
1080volatile BOOLEAN m2_end_called = FALSE;
1081
1082void m2_end(int i)
1083{
1084  if (!m2_end_called)
1085  {
1086    extern FILE* File_Profiling;
1087    if (File_Profiling!=NULL) { fclose(File_Profiling); File_Profiling=NULL; }
1088    m2_end_called = TRUE;
1089#ifdef HAVE_SIMPLEIPC
1090    for (int j = SIPC_MAX_SEMAPHORES-1; j >= 0; j--)
1091    {
1092      if (semaphore[j] != NULL)
1093      {
1094        while (sem_acquired[j] > 0)
1095        {
1096#if PORTABLE_SEMAPHORES
1097          sem_post(semaphore[j]->sig);
1098#else
1099          sem_post(semaphore[j]);
1100#endif
1101          sem_acquired[j]--;
1102        }
1103      }
1104    }
1105#endif   // HAVE_SIMPLEIPC
1106    fe_reset_input_mode();
1107    monitor(NULL,0);
1108#ifdef PAGE_TEST
1109    mmEndStat();
1110#endif
1111    fe_reset_input_mode();
1112    if (ssiToBeClosed_inactive)
1113    {
1114      link_list hh=ssiToBeClosed;
1115      while(hh!=NULL)
1116      {
1117        //Print("close %s\n",hh->l->name);
1118        slPrepClose(hh->l);
1119        hh=(link_list)hh->next;
1120      }
1121      ssiToBeClosed_inactive=FALSE;
1122
1123      idhdl h = currPack->idroot;
1124      while(h != NULL)
1125      {
1126        if(IDTYP(h) == LINK_CMD)
1127        {
1128          idhdl hh=h->next;
1129          //Print("kill %s\n",IDID(h));
1130          killhdl(h, currPack);
1131          h = hh;
1132        }
1133        else
1134        {
1135          h = h->next;
1136        }
1137      }
1138      hh=ssiToBeClosed;
1139      while(hh!=NULL)
1140      {
1141        //Print("close %s\n",hh->l->name);
1142        slClose(hh->l);
1143        hh=ssiToBeClosed;
1144      }
1145    }
1146    if (!singular_in_batchmode)
1147    {
1148      if (i<=0)
1149      {
1150        //extern long all_farey;
1151        //extern long farey_cnt;
1152        //if (all_farey!=0L) printf("farey:%ld, cnt=%ld\n",all_farey,farey_cnt);
1153        if (TEST_V_QUIET)
1154        {
1155          if (i==0)
1156            printf("Auf Wiedersehen.\n");
1157          else
1158            printf("\n$Bye.\n");
1159        }
1160        //#ifdef sun
1161        //  #ifndef __svr4__
1162        //    _cleanup();
1163        //    _exit(0);
1164        //  #endif
1165        //#endif
1166        i=0;
1167      }
1168      else
1169      {
1170        printf("\nhalt %d\n",i);
1171      }
1172    }
1173    exit(i);
1174  }
1175}
1176}
1177
1178extern "C"
1179{
1180  void omSingOutOfMemoryFunc()
1181  {
1182    fprintf(stderr, "\nSingular error: no more memory\n");
1183    omPrintStats(stderr);
1184    m2_end(14);
1185    /* should never get here */
1186    exit(1);
1187  }
1188}
1189
1190#ifdef SINGULAR_4_2
1191static n_coeffType n_pAE=n_unknown;
1192static BOOLEAN ii_pAE_init(leftv res,leftv a)
1193{
1194  if (a->Typ()!=INT_CMD)
1195  {
1196    WerrorS("`int` expected");
1197    return TRUE;
1198  }
1199  else
1200  {
1201    res->rtyp=CRING_CMD;
1202    res->data=(void*)nInitChar(n_pAE,(void*)a->Data());
1203    return FALSE;
1204  }
1205}
1206#endif
1207#ifdef HAVE_FLINT
1208static n_coeffType n_FlintZn=n_unknown;
1209static BOOLEAN ii_FlintZn_init(leftv res,leftv a)
1210{
1211  if ((a->Typ()!=INT_CMD)
1212  ||(a->next==NULL)
1213  ||(a->next->Typ()!=STRING_CMD))
1214  {
1215    WerrorS("`int`i,`string` expected");
1216    return TRUE;
1217  }
1218  else
1219  {
1220    flintZn_struct p;
1221    p.ch=(int)(long)a->Data();
1222    p.name=(char*)a->next->Data();
1223    res->rtyp=CRING_CMD;
1224    res->data=(void*)nInitChar(n_FlintZn,(void*)&p);
1225    return FALSE;
1226  }
1227}
1228#endif
1229/*2
1230* initialize components of Singular
1231*/
1232void siInit(char *name)
1233{
1234// factory default settings: -----------------------------------------------
1235  On(SW_USE_EZGCD);
1236  On(SW_USE_CHINREM_GCD);
1237  //On(SW_USE_FF_MOD_GCD);
1238  On(SW_USE_EZGCD_P);
1239  On(SW_USE_QGCD);
1240  Off(SW_USE_NTL_SORT); // may be changed by an command line option
1241  factoryError=WerrorS;
1242
1243// memory initialization: -----------------------------------------------
1244    om_Opts.OutOfMemoryFunc = omSingOutOfMemoryFunc;
1245#ifndef OM_NDEBUG
1246#ifndef __OPTIMIZE__
1247    om_Opts.ErrorHook = dErrorBreak;
1248#else
1249    om_Opts.Keep = 0; /* !OM_NDEBUG, __OPTIMIZE__*/
1250#endif
1251#else
1252    om_Opts.Keep = 0; /* OM_NDEBUG */
1253#endif
1254    omInitInfo();
1255
1256// options ---------------------------------------------------------------
1257  si_opt_1=0;
1258// interpreter tables etc.: -----------------------------------------------
1259  memset(&sLastPrinted,0,sizeof(sleftv));
1260  sLastPrinted.rtyp=NONE;
1261
1262  extern int iiInitArithmetic(); iiInitArithmetic(); // iparith.cc
1263
1264  basePack=(package)omAlloc0(sizeof(*basePack));
1265  currPack=basePack;
1266  idhdl h;
1267  h=enterid("Top", 0, PACKAGE_CMD, &IDROOT, TRUE);
1268  IDPACKAGE(h)=basePack;
1269  IDPACKAGE(h)->language = LANG_TOP;
1270  currPackHdl=h;
1271  basePackHdl=h;
1272
1273  coeffs_BIGINT = nInitChar(n_Q,(void*)1);
1274
1275#if 1
1276   // def HAVE_POLYEXTENSIONS
1277  if(TRUE)
1278  {
1279    n_coeffType type;
1280    #ifdef SINGULAR_4_2
1281    type = nRegister(n_polyExt, n2pInitChar);
1282    assume(type == n_polyExt);
1283    #endif
1284
1285    type = nRegister(n_algExt, naInitChar);
1286    assume(type == n_algExt);
1287
1288    type = nRegister(n_transExt, ntInitChar);
1289    assume(type == n_transExt);
1290
1291    (void)type;
1292  }
1293#endif
1294
1295// random generator: -----------------------------------------------
1296  int t=initTimer();
1297  if (t==0) t=1;
1298  initRTimer();
1299  siSeed=t;
1300  factoryseed(t);
1301  siRandomStart=t;
1302  feOptSpec[FE_OPT_RANDOM].value = (void*) ((long)siRandomStart);
1303
1304// ressource table: ----------------------------------------------------
1305  // Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
1306  // hack such that all shared' libs in the bindir are loaded correctly
1307  feInitResources(name);
1308
1309// singular links: --------------------------------------------------
1310  slStandardInit();
1311  myynest=0;
1312// semapohore 0 -----------------------------------------------------
1313  int cpus=2;
1314  int cpu_n;
1315  #ifdef _SC_NPROCESSORS_ONLN
1316  if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1317  #elif defined(_SC_NPROCESSORS_CONF)
1318  if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
1319  #endif
1320  feSetOptValue(FE_OPT_CPUS, cpus);
1321
1322// default coeffs
1323  {
1324    idhdl h;
1325    h=enterid(omStrDup("QQ"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1326    IDDATA(h)=(char*)nInitChar(n_Q,NULL);
1327    h=enterid(omStrDup("ZZ"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1328    IDDATA(h)=(char*)nInitChar(n_Z,NULL);
1329    //h=enterid(omStrDup("RR"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1330    //IDDATA(h)=(char*)nInitChar(n_R,NULL);
1331    //h=enterid(omStrDup("CC"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1332    //IDDATA(h)=(char*)nInitChar(n_long_C,NULL);
1333    n_coeffType t;
1334#ifdef SINGULAR_4_2
1335    t=nRegister(n_unknown,n_AEInitChar);
1336    if (t!=n_unknown)
1337    {
1338      h=enterid(omStrDup("AE"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1339      IDDATA(h)=(char*)nInitChar(t,NULL);
1340    }
1341    t=nRegister(n_unknown,n_QAEInitChar);
1342    if (t!=n_unknown)
1343    {
1344      h=enterid(omStrDup("QAE"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1345      IDDATA(h)=(char*)nInitChar(t,NULL);
1346    }
1347    n_pAE=nRegister(n_unknown,n_pAEInitChar);
1348    if (n_pAE!=n_unknown)
1349    {
1350      iiAddCproc("kernel","pAE",FALSE,ii_pAE_init);
1351    }
1352#endif
1353    #ifdef HAVE_FLINT
1354    t=nRegister(n_unknown,flintQ_InitChar);
1355    if (t!=n_unknown)
1356    {
1357      h=enterid(omStrDup("flint_poly_Q"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1358      IDDATA(h)=(char*)nInitChar(t,NULL);
1359    }
1360    n_FlintZn=nRegister(n_unknown,flintZn_InitChar);
1361    if (n_FlintZn!=n_unknown)
1362    {
1363      iiAddCproc("kernel","flintZ",FALSE,ii_FlintZn_init);
1364    }
1365    #endif
1366  }
1367// setting routines for PLURAL QRINGS:
1368// allowing to use libpolys without libSingular(kStd)
1369#ifdef HAVE_PLURAL
1370  nc_NF=k_NF;
1371  gnc_gr_bba=k_gnc_gr_bba;
1372  gnc_gr_mora=k_gnc_gr_mora;
1373  sca_bba=k_sca_bba;
1374  sca_mora=k_sca_mora;
1375  sca_gr_bba=k_sca_gr_bba;
1376#endif
1377// loading standard.lib -----------------------------------------------
1378  if (! feOptValue(FE_OPT_NO_STDLIB))
1379  {
1380    BITSET save1,save2;
1381    SI_SAVE_OPT(save1,save2);
1382    si_opt_2 &= ~Sy_bit(V_LOAD_LIB);
1383    iiLibCmd(omStrDup("standard.lib"), TRUE,TRUE,TRUE);
1384    SI_RESTORE_OPT(save1,save2);
1385  }
1386  errorreported = 0;
1387}
Note: See TracBrowser for help on using the repository browser.