Changeset c06a32 in git
- Timestamp:
- Sep 20, 1999, 8:03:51 PM (24 years ago)
- Branches:
- (u'spielwiese', 'd1ba061a762c62d3a25159d8da8b6e17332291fa')
- Children:
- 70883173be34d0af981d9af508ccbb1e77912676
- Parents:
- aef7ccb547c93eee9ab75ef2c46ce9149f6dd9ca
- Location:
- Singular
- Files:
-
- 4 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/Makefile.in
raef7ccb rc06a32 66 66 ### 67 67 68 # normal C++ source files 68 69 CXXSOURCES=grammar.cc scanner.cc algmap.cc attrib.cc binom.cc clapconv.cc \ 69 clapmem.cc clapsing.cc c laptmpl.cc cntrlc.cc\70 extra.cc febase.cc feread.cc fehelp.cc feResource.cc fe CmdLineOptions.cc\70 clapmem.cc clapsing.cc cntrlc.cc\ 71 extra.cc febase.cc feread.cc fehelp.cc feResource.cc feOpt.cc\ 71 72 ffields.cc hdegree.cc hilb.cc hutil.cc \ 72 ideals.cc intvec.cc iparith.cc\73 ideals.cc intvec.cc \ 73 74 ipassign.cc ipconv.cc ipid.cc iplib.cc \ 74 75 ipprint.cc ipshell.cc khstd.cc kstdfac.cc \ … … 82 83 sing_dld.cc sing_dbm.cc spolys.cc spolys0.cc \ 83 84 subexpr.cc syz.cc syz0.cc syz1.cc \ 84 t esths.cc timer.cc weight.cc \85 mpsr_Put.cc mpsr_PutPoly.cc mpsr_ Tok.cc mpsr_GetPoly.cc \85 timer.cc weight.cc \ 86 mpsr_Put.cc mpsr_PutPoly.cc mpsr_GetPoly.cc \ 86 87 mpsr_Get.cc mpsr_GetMisc.cc mpsr_Error.cc \ 87 88 GMPrat.cc multicnt.cc npolygon.cc semic.cc spectrum.cc splist.cc \ … … 90 91 mpr_inout.cc mpr_base.cc mpr_numeric.cc 91 92 92 CSOURCES=gmalloc.c mmalloc.c mmheap.c mmpage.c mmcheck.c mmisc.c mmtables.c \ 93 mmbt.c weight0.c find_exec.c getopt.c fereadl.c page.c 94 95 SOURCES=${CSOURCES} ${CXXSOURCES} grammar.y scanner.l libparse.l spSpolyLoop.pl generate.pl 93 # normal C source files 94 CSOURCES=mmalloc.c mmheap.c mmpage.c mmcheck.c mmisc.c mmtables.c \ 95 mmbt.c weight0.c find_exec.c fegetopt.c fereadl.c page.c 96 97 # special source files (need extra compiling and/or linking) 98 ESOURCES=iparith.cc gmalloc.c tesths.cc mpsr_Tok.cc claptmpl.cc 99 100 SOURCES=${CSOURCES} ${CXXSOURCES} ${ESOURCES} \ 101 grammar.y scanner.l libparse.l spSpolyLoop.pl generate.pl 96 102 97 103 HEADERS=algmap.h hutil.h lists.h stairc.h attrib.h ideals.h \ … … 107 113 kstdfac.h mpsr_Get.h spolys.h \ 108 114 kutil.h mpsr_Put.h spolys0.h sing_dld.h\ 109 ndbm.h spSpolyLoop.h polys-impl.h polys-comp.h getopt.hlibparse.h \115 ndbm.h spSpolyLoop.h polys-impl.h polys-comp.h libparse.h \ 110 116 GMPrat.h multicnt.h npolygon.h semic.h spectrum.h splist.h multicnt.h \ 111 117 pcv.h mod_raw.h kbuckets.h kbPolyProcs.h \ 112 mpr_global.h mpr_inout.h mpr_base.h mpr_numeric.h 113 114 INCS=febase.inc polys.inc iparith.inc mpsr_Tok.inc spSpolyLoop.inc 118 mpr_global.h mpr_inout.h mpr_base.h mpr_numeric.h \ 119 feOpt.h fegetopt.h 120 121 INCS=febase.inc polys.inc iparith.inc mpsr_Tok.inc spSpolyLoop.inc feOpt.inc 115 122 116 123 TESTS=${testdir}/comparecheck ${testdir}/fac_test.in ${testdir}/fac_test.out\ … … 123 130 ${INCS} 124 131 125 OBJS=grammar.o scanner.o matpol.o binom.o mpr_complex.o gnumpfl.o gnumpc.o \ 126 febase.o feread.o fehelp.o feResource.o timer.o intvec.o attrib.o lists.o\ 127 longrat.o longrat0.o misc.o ring.o numbers.o maps.o\ 128 hilb.o comm.o kstd1.o kstd2.o kutil.o khstd.o kstdfac.o modulop.o spolys.o\ 129 ideals.o subexpr.o hdegree.o hutil.o ffields.o shortfl.o \ 130 longalg.o spolys0.o syz.o syz0.o syz1.o weight.o weight0.o \ 131 ipid.o ipshell.o iplib.o ipassign.o ipconv.o ipprint.o\ 132 polys.o polys0.o polys1.o polys-impl.o extra.o sparsmat.o\ 133 mminit.o mmtables.o mmalloc.o mmheap.o mmpage.o page.o \ 134 mmisc.o mmcheck.o mmbt.o sing_dld.o sing_dbm.o silink.o \ 135 sing_mp.o fglm.o fglmzero.o fglmvec.o fglmhom.o fglmgauss.o cntrlc.o \ 136 algmap.o clapconv.o clapmem.o clapsing.o claptmpl.o\ 137 mpsr_Error.o mpsr_Put.o mpsr_PutPoly.o mpsr_GetPoly.o \ 138 mpsr_Get.o mpsr_GetMisc.o ndbm.o spSpolyLoop.o libparse.o \ 139 find_exec.o getopt.o fereadl.o mod_raw.o sdb.o \ 140 GMPrat.o multicnt.o npolygon.o semic.o spectrum.o splist.o \ 141 pcv.o kbuckets.o kbPolyProcs.o \ 142 mpr_inout.o mpr_base.o mpr_numeric.o 132 OBJS := $(CXXSOURCES:.cc=.o) $(CSOURCES:.c=.o) 143 133 144 134 # Singular libraries which go into distribution … … 179 169 180 170 Singular: mod2.h Makefile version.h scanner.cc gmalloc.o \ 181 ${OBJS} iparith.o mpsr_Tok.o tesths.cc libparse.cc 182 ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXTEMPLFLAGS} ${DEFS} -o Singular \ 183 tesths.cc iparith.o mpsr_Tok.o ${OBJS} ${LDFLAGS} ${LIBS} \ 184 ${LD_DYN_FLAGS} gmalloc.o ${LD_LIBC} 171 ${OBJS} iparith.o tesths.cc libparse.cc claptmpl.o 172 ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXTEMPLFLAGS} ${DEFS} \ 173 -o Singular \ 174 tesths.cc iparith.o mpsr_Tok.o claptmpl.o\ 175 ${OBJS} ${LDFLAGS} ${LIBS} ${LD_DYN_FLAGS} \ 176 gmalloc.o ${LD_LIBC} 185 177 186 178 Singular-static: mod2.h Makefile version.h scanner.cc gmalloc.o \ 187 ${OBJS} iparith.o mpsr_Tok.o tesths.cc 179 ${OBJS} iparith.o mpsr_Tok.o tesths.cc claptmpl.o 188 180 ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXTEMPLFLAGS} ${DEFS} \ 189 -o Singular-static \190 tesths.cc iparith.o mpsr_Tok.o\191 ${OBJS} ${STATIC_LDFLAGS} ${LDFLAGS} ${LIBS} ${LD_DYN_FLAGS} \192 gmalloc.o ${LD_LIBC}181 -o Singular-static \ 182 tesths.cc iparith.o mpsr_Tok.o claptmpl.o\ 183 ${OBJS} ${STATIC_LDFLAGS} ${LDFLAGS} ${LIBS} ${LD_DYN_FLAGS} \ 184 gmalloc.o ${LD_LIBC} 193 185 194 186 iparith.o mpsr_Tok.o : iparith.inc mpsr_Tok.inc … … 197 189 ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${DEFS} -c $< 198 190 199 iparith.inc mpsr_Tok.inc: gmalloc.o iparith.cc ipconv.cc tok.h mpsr_Tok.cc grammar.h mod2.h 191 iparith.inc mpsr_Tok.inc: gmalloc.o claptmpl.o iparith.cc \ 192 ipconv.cc tok.h mpsr_Tok.cc grammar.h mod2.h 200 193 ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXTEMPLFLAGS} ${DEFS} -DGENTABLE \ 201 -o gentable iparith.cc tesths.cc mpsr_Tok.cc \194 -o gentable claptmpl.o iparith.cc tesths.cc mpsr_Tok.cc \ 202 195 ${OBJS} ${LDFLAGS} ${LIBS} gmalloc.o ${LD_LIBC} 203 196 ./gentable … … 215 208 version.h: ${SOURCES} ${HEADERS} Makefile.in mod2.h.in \ 216 209 configure.in 217 echo "#define SINGULAR_VERSION_ID " `date '+%Y%m%d%H'`>version.h210 echo unsigned long feVersionId = `date '+%Y%m%d%H'`\; >version.h 218 211 219 212 kbPolyProcs.cc kbPolyProcs.dd : kbPolyProcs.pin … … 235 228 ${PERL5} spSpolyLoop.pl > spSpolyLoop.inc 236 229 237 libparse: libparse_main.o utils.o getopt.o 238 ${CXX} -o libparse libparse_main.o utils.o getopt.o 230 231 libparse: libparse_main.o utils.o fegetopt.o 232 ${CXX} -o libparse libparse_main.o utils.o fegetopt.o 239 233 240 234 libparse_main.o: libparse.cc … … 248 242 ${LEX} -I -Pyylp -olibparse.cc libparse.l 249 243 250 ESingular: getopt.o feResource.cc mod2.h feCmdLineOptions.cc version.h emacs.cc 251 ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${DEFS} -o ESingular emacs.cc getopt.o ${LDFLAGS} ${LIBS} 244 ESingular: fegetopt.o feResource.cc mod2.h feOpt.cc version.h emacs.cc \ 245 feOptES.inc 246 ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${DEFS} -o ESingular emacs.cc fegetopt.o ${LDFLAGS} ${LIBS} 247 248 feOpt.h: feOpt.inc feOptES.inc 249 250 feOpt.inc: feOpt.cc 251 $(CXX) -DGENERATE_OPTION_INDEX feOpt.cc 252 ./a.out 253 rm a.out 254 255 feOptES.inc: feOpt.cc 256 $(CXX) -DGENERATE_OPTION_INDEX -DESINGULAR feOpt.cc 257 ./a.out 258 rm a.out 252 259 253 260 src: scanner.cc grammar.h grammar.cc libparse.cc spSpolyLoop.inc … … 302 309 303 310 clean: 304 -rm -f Singular Singularg Singularp Singularb libparse \311 -rm -f Singular Singularg Singularp Singularb libparse feOpt*.inc\ 305 312 *.o *.og core *.op *.ob 306 313 … … 327 334 328 335 Singular-bindist: ${OBJS} Makefile 329 echo "#define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h 330 echo "#define MAKE_DISTRIBUTION " >> version.h 336 echo "#define MAKE_DISTRIBUTION " > distrib.h 331 337 ${MAKE} Singular ESingular 332 338 strip Singular ESingular 333 339 ${INSTALL} -s Singular Singular-bindist 334 340 ${INSTALL} -s ESingular ESingular-bindist 335 echo "# define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h341 echo "#undef MAKE_DISTRIBUTION " > distrib.h 336 342 337 343 Singular-static-bindist: ${OBJS} Makefile 338 echo "#define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h 339 echo "#define MAKE_DISTRIBUTION " >> version.h 344 echo "#define MAKE_DISTRIBUTION " > distrib.h 340 345 ${MAKE} Singular-static ESingular 341 346 strip Singular-static ESingular 342 347 mv Singular-static Singular-static-bindist 343 348 ${INSTALL} -s ESingular ESingular-bindist 344 echo "# define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h349 echo "#undef MAKE_DISTRIBUTION " > distrib.h 345 350 346 351 tar: … … 380 385 ## 381 386 382 OBJG1= grammar.og scanner.og matpol.og binom.og gnumpfl.og mpr_complex.og \ 383 febase.og feread.og fehelp.og feResource.og timer.og intvec.og attrib.og lists.og \ 384 gnumpc.og longrat.og longrat0.og misc.og ring.og numbers.og maps.og\ 385 hilb.og comm.og kstd1.og kstd2.og kutil.og khstd.og kstdfac.og modulop.og \ 386 spolys.og ideals.og subexpr.og hdegree.og hutil.og ffields.og shortfl.og \ 387 longalg.og spolys0.og syz.og syz0.og syz1.og weight.og \ 388 ipid.og ipshell.og iplib.og ipassign.og ipconv.og ipprint.og\ 389 polys.og polys0.og polys1.og polys-impl.og extra.og\ 390 mminit.og sing_dld.og sing_dbm.og silink.og sparsmat.og\ 391 sing_mp.og fglm.og fglmzero.og fglmvec.og fglmgauss.og fglmhom.og\ 392 algmap.og clapconv.og clapmem.og clapsing.og cntrlc.og sdb.og\ 393 mpsr_Error.og mpsr_Put.og mpsr_PutPoly.og mpsr_GetPoly.og \ 394 mpsr_Get.og mpsr_GetMisc.og \ 395 ndbm.og spSpolyLoop.og libparse.og mod_raw.og \ 396 GMPrat.og multicnt.og npolygon.og semic.og spectrum.og splist.og \ 397 mpr_inout.og mpr_base.og mpr_numeric.og \ 398 pcv.og kbuckets.og kbPolyProcs.og 399 400 OBJG2= mmalloc.og mmheap.og mmpage.og mmcheck.og mmbt.og page.og \ 401 mmisc.og mmtables.og weight0.og find_exec.og getopt.og fereadl.og 402 403 404 OBJG=$(OBJG1) $(OBJG2) claptmpl.og 387 OBJG1 := $(CXXSOURCES:.cc=.og) 388 OBJG2 := $(CSOURCES:.c=.og) 389 390 391 OBJG=$(OBJG1) $(OBJG2) 405 392 406 393 ## … … 410 397 claptmpl.og: claptmpl.cc mod2.h 411 398 $(CXXG) ${CXXFLAGSG} ${CPPFLAGS} ${DEFSG} -c $< -o $@ 412 $(OBJG1): %.og: %.cc 399 400 $(OBJG1) : %.og: %.cc 413 401 $(CXXG) ${CXXFLAGSG} ${CXXTEMPLFLAGSG} ${CPPFLAGS} ${DEFSG} -c $< -o $@ 414 402 … … 416 404 $(CCG) ${CFLAGSG} ${CPPFLAGS} ${DEFSG} -c $< -o $@ 417 405 418 Singularg: scanner.cc gmalloc.og $(OBJG) iparith.og mpsr_Tok.og tesths.cc version.h406 Singularg: scanner.cc gmalloc.og $(OBJG) iparith.og mpsr_Tok.og claptmpl.og tesths.cc version.h 419 407 $(CXXG) ${CXXFLAGSG} ${CXXTEMPLFLAGSG} ${CPPFLAGS} ${DEFSG} -o Singularg \ 420 tesths.cc iparith.og mpsr_Tok.og $(OBJG) ${LDFLAGS} ${LIBS} \408 tesths.cc iparith.og mpsr_Tok.og claptmpl.og $(OBJG) ${LDFLAGS} ${LIBS} \ 421 409 ${LD_DYN_FLAGS} gmalloc.og 422 410 -
Singular/cntrlc.cc
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: cntrlc.cc,v 1.2 4 1999-08-25 16:02:42 SingularExp $ */4 /* $Id: cntrlc.cc,v 1.25 1999-09-20 18:03:43 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT - interupt handling … … 12 12 #include <stdlib.h> 13 13 #include <signal.h> 14 #include "version.h"15 14 #include "mod2.h" 16 15 #include "tok.h" … … 109 108 void sigsegv_handler(int sig, sigcontext s) 110 109 { 111 fprintf(stderr,"Singular : signal %d (v: %d/% d):\n",sig,SINGULAR_VERSION,SINGULAR_VERSION_ID);110 fprintf(stderr,"Singular : signal %d (v: %d/%lu):\n",sig,SINGULAR_VERSION,feVersionId); 112 111 if (sig!=SIGINT) 113 112 { … … 215 214 void sigsegv_handler(int sig, int code, struct sigcontext *scp, char *addr) 216 215 { 217 fprintf(stderr,"Singular : signal %d, code %d (v: %d/% d):\n",218 sig,code,SINGULAR_VERSION, SINGULAR_VERSION_ID);216 fprintf(stderr,"Singular : signal %d, code %d (v: %d/%lu):\n", 217 sig,code,SINGULAR_VERSION,feVersionId); 219 218 if ((sig!=SIGINT)&&(sig!=SIGABRT)) 220 219 { … … 259 258 void sigsegv_handler(int sig) 260 259 { 261 fprintf(stderr,"Singular : signal %d (v: %d/% d):\n",262 sig,SINGULAR_VERSION, SINGULAR_VERSION_ID);260 fprintf(stderr,"Singular : signal %d (v: %d/%lu):\n", 261 sig,SINGULAR_VERSION,feVersionId); 263 262 if (sig!=SIGINT) 264 263 { -
Singular/emacs.cc
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: emacs.cc,v 1. 7 1999-09-07 08:36:09 SingularExp $ */4 /* $Id: emacs.cc,v 1.8 1999-09-20 18:03:43 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: Esingular main file … … 50 50 Warn("Bug occured at %s:%d ", file, line); 51 51 Warn("Message: %s ", msg); 52 Warn("Version: " S_UNAME S_VERSION1 " (% d) " __DATE__ __TIME__,53 SINGULAR_VERSION_ID);52 Warn("Version: " S_UNAME S_VERSION1 " (%lu) " __DATE__ __TIME__, 53 feVersionId); 54 54 } 55 55 … … 63 63 } 64 64 #include "feResource.cc" 65 #include "feCmdLineOptions.cc" 65 #include "feOpt.cc" 66 67 void mainUsage() 68 { 69 fprintf(stderr, "Use `%s --help' for a complete list of options\n", feArgv0); 70 } 66 71 67 72 int main(int argc, char** argv) … … 83 88 int optc, option_index; 84 89 85 while ((optc = getopt_long(argc, argv, SHORT_OPTS_STRING,86 longopts, &option_index))90 while ((optc = fe_getopt_long_only(argc, argv, SHORT_OPTS_STRING, 91 feOptSpec, &option_index)) 87 92 != EOF) 88 93 { … … 90 95 { 91 96 case 'h': 92 mainHelp(argv[0]);97 feOptHelp(feArgv0); 93 98 exit(0); 94 99 95 100 case '?': 96 101 case ':': 97 mainUsage(argv[0]); 102 case '\0': 103 mainUsage(); 98 104 exit(1); 99 105 100 106 case LONG_OPTION_RETURN: 101 if (strcmp(longopts[option_index].name, LON_EMACS) == 0) 107 { 108 switch(option_index) 102 109 { 103 emacs = optarg; 104 } 105 else if (strcmp(longopts[option_index].name, LON_EMACS_DIR) == 0) 106 { 107 emacs_dir = optarg; 108 } 109 else if (strcmp(longopts[option_index].name, LON_EMACS_LOAD) == 0) 110 { 111 emacs_load = optarg; 112 } 113 else if (strcmp(longopts[option_index].name, LON_SINGULAR) == 0) 114 { 115 singular = optarg; 116 } 117 else if (strcmp(longopts[option_index].name, LON_NO_EMACS_CALL) == 0) 118 { 119 no_emacs_call = 1; 120 } 121 else 122 { 123 break; 110 case FE_OPT_EMACS: 111 emacs = fe_optarg; 112 break; 113 114 case FE_OPT_EMACS_DIR: 115 emacs_dir = fe_optarg; 116 break; 117 118 case FE_OPT_EMACS_LOAD: 119 emacs_load = fe_optarg; 120 break; 121 122 case FE_OPT_SINGULAR: 123 singular = fe_optarg; 124 break; 125 126 case FE_OPT_NO_EMACS_CALL: 127 no_emacs_call = 1; 128 break; 129 130 default: 131 goto NEXT; 124 132 } 125 133 // delete options from option-list 126 if ( optind > 2 && *argv[optind-1] != '-' &&127 optarg != NULL && longopts[option_index].has_arg)134 if (fe_optind > 2 && *argv[fe_optind-1] != '-' && 135 fe_optarg != NULL && feOptSpec[option_index].has_arg) 128 136 { 129 argv[ optind-2] = NULL;137 argv[fe_optind-2] = NULL; 130 138 } 131 argv[optind-1] = NULL; 132 } 133 } 139 argv[fe_optind-1] = NULL; 140 } 141 } 142 NEXT:{} 143 } 134 144 135 145 // make sure emacs, singular, emacs_dir, emacs_load are set … … 139 149 fprintf(stderr, "Error: Can't find emacs executable. \nExpected it at %s\n. Specify alternative with --emacs option,\n or set EMACS environment variable.\n", 140 150 feResourceDefault("emacs")); 141 mainUsage( argv[0]);151 mainUsage(); 142 152 exit(1); 143 153 } … … 148 158 fprintf(stderr, "Error: Can't find singular executable.\nExpected it at %s\nSpecify with --singular option,\n or set SINGULAR_EMACS environment variable.\n", 149 159 feResourceDefault("SingularEmacs")); 150 mainUsage( argv[0]);160 mainUsage(); 151 161 exit(1); 152 162 } … … 157 167 fprintf(stderr, "Error: Can't find emacs directory for Singular lisp files. \nExpected it at %s\nSpecify with --emacs_dir option,\n or set SINGULAR_EMACS_DIR environment variable.\n", 158 168 feResourceDefault("EmacsDir")); 159 mainUsage( argv[0]);169 mainUsage(); 160 170 exit(1); 161 171 } … … 182 192 fprintf(stderr, "Error: Can't find emacs load file for Singular mode. \nExpected it at %s\nSpecify with --emacs_load option,\n or set SINGULAR_EMACS_LOAD environment variable,\n or put file '.emacs-singular' in your home directory.\n", 183 193 feResourceDefault("EmacsLoad")); 184 mainUsage( argv[0]);194 mainUsage(); 185 195 exit(1); 186 196 } … … 232 242 { 233 243 fprintf(stderr, "Error: Executation of\n%s\n"); 234 mainUsage( argv[0]);244 mainUsage(); 235 245 exit(1); 236 246 } -
Singular/extra.cc
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: extra.cc,v 1.10 3 1999-08-20 16:06:49 SingularExp $ */4 /* $Id: extra.cc,v 1.104 1999-09-20 18:03:43 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: general interface to internals of Singular ("system" command) … … 49 49 #include "syz.h" 50 50 #include "sdb.h" 51 #include "feOpt.h" 52 #include "distrib.h" 51 53 52 54 // Define to enable many more system commands … … 237 239 res->rtyp = STRING_CMD; 238 240 char* b = StringSetS(""); 239 feStringAppendBrowsers( 1);241 feStringAppendBrowsers(0); 240 242 res->data = mstrdup(b); 241 243 return FALSE; … … 316 318 if (strstr(sys_cmd, "--") == sys_cmd) 317 319 { 318 BOOLEAN mainGetSingOptionValue(const char* name, char** result); 319 char* val; 320 321 if (h != NULL) 322 { 323 if (strcmp(sys_cmd, "--browser") == 0) 324 { 325 if (h->Typ() == STRING_CMD) 326 { 327 if (strcmp(feHelpBrowser((char*) h->Data(), 1), 328 (char*) h->Data()) != 0) 329 { 330 Werror("Can not set HelpBrowser to '%s'", (char*) h->Data()); 331 return TRUE; 332 } 333 } 320 if (strcmp(sys_cmd, "--") == 0) 321 { 322 fePrintOptValues(); 323 return FALSE; 324 } 325 326 feOptIndex opt = feGetOptIndex(&sys_cmd[2]); 327 if (opt == FE_OPT_UNDEF) 328 { 329 Werror("Unknown option %s", sys_cmd); 330 Werror("Use 'system(\"--\");' for listing of available options"); 331 return TRUE; 332 } 333 334 if (h == NULL) 335 { 336 if (feOptSpec[opt].type == feOptString) 337 { 338 res->rtyp = STRING_CMD; 339 if (feOptSpec[opt].value != NULL) 340 res->data = mstrdup((char*) feOptSpec[opt].value); 334 341 else 335 { 336 Werror("Need string to set HelpBrowser"); 337 return TRUE; 338 } 342 res->data = mstrdup(""); 339 343 } 340 344 else 341 345 { 342 Werror("Can not set value of option %s", sys_cmd); 346 res->rtyp = INT_CMD; 347 res->data = feOptSpec[opt].value; 348 } 349 return FALSE; 350 } 351 352 if (h->Typ() != STRING_CMD && 353 h->Typ() != INT_CMD) 354 { 355 Werror("Need string or int argument to set option value"); 356 return TRUE; 357 } 358 char* errormsg; 359 if (h->Typ() == INT_CMD) 360 { 361 if (feOptSpec[opt].type == feOptString) 362 { 363 Werror("Need string argument to set value of option %s", sys_cmd); 343 364 return TRUE; 344 365 } 345 } 346 347 if (mainGetSingOptionValue(&(sys_cmd)[2], &val)) 348 { 349 if ((unsigned int) val > 1) 350 { 351 res->rtyp=STRING_CMD; 352 if (strcmp(sys_cmd, "--browser") == 0 && 353 (val == NULL || *val == '\0')) 354 res->data = (void*) mstrdup(feHelpBrowser()); 355 else 356 res->data = (void*) mstrdup( val ); 357 } 358 else 359 { 360 res->rtyp=INT_CMD; 361 res->data=(void *)val; 362 } 363 return FALSE; 364 } 365 else 366 { 367 Werror("Unknown option %s\n", sys_cmd); 368 return TRUE; 369 } 366 errormsg = feSetOptValue(opt, (int) h->Data()); 367 if (errormsg != NULL) 368 Werror("Option '--%s=%d' %s", sys_cmd, (int) h->Data(), errormsg); 369 } 370 else 371 { 372 errormsg = feSetOptValue(opt, (char*) h->Data()); 373 if (errormsg != NULL) 374 Werror("Option '--%s=%s' %s", sys_cmd, (char*) h->Data(), errormsg); 375 } 376 if (errormsg != NULL) return TRUE; 377 return FALSE; 370 378 } 371 379 else … … 1005 1013 } 1006 1014 else 1007 /*==================== print all option values =================*/1008 #ifndef NDEBUG1009 if (strcmp(sys_cmd, "options") == 0)1010 {1011 void mainOptionValues();1012 mainOptionValues();1013 return FALSE;1014 }1015 else1016 #endif1017 1015 /*==================== GF =================*/ 1018 1016 #if 0 -
Singular/feResource.cc
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: feResource.cc,v 1.1 0 1999-08-25 16:02:46 SingularExp $ */4 /* $Id: feResource.cc,v 1.11 1999-09-20 18:03:45 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: management of resources … … 9 9 #include <unistd.h> 10 10 11 #include "version.h"12 11 #include "mod2.h" 13 #include " version.h"12 #include "distrib.h" 14 13 #ifndef ESINGULAR 15 14 #include "mmemory.h" … … 99 98 * 100 99 *****************************************************************/ 101 staticchar* feArgv0;100 char* feArgv0; 102 101 #define MAXRESOURCELEN 5*MAXPATHLEN 103 102 char fePathSep = … … 194 193 } 195 194 #ifdef RESOURCE_DEBUG 196 printf("feInitResources: entering with argv0=%s=\n", argv0);195 printf("feInitResources: entering with argv0=%s=\n", feArgv0); 197 196 #endif 198 197 // init some Resources -
Singular/febase.cc
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: febase.cc,v 1.8 1 1999-08-25 16:02:46 SingularExp $ */4 /* $Id: febase.cc,v 1.82 1999-09-20 18:03:46 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: i/o system 7 7 */ 8 8 9 #include "version.h"10 9 #include "mod2.h" 11 10 … … 362 361 Warn("Bug occured at %s:%d", file, line); 363 362 Warn("Message: %s", msg); 364 Warn("Version: " S_UNAME S_VERSION1 " (% d) " __DATE__ __TIME__,365 SINGULAR_VERSION_ID);363 Warn("Version: " S_UNAME S_VERSION1 " (%lu) " __DATE__ __TIME__, 364 feVersionId); 366 365 } 367 366 -
Singular/febase.h
raef7ccb rc06a32 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: febase.h,v 1.3 6 1999-08-25 16:02:46 SingularExp $ */6 /* $Id: febase.h,v 1.37 1999-09-20 18:03:47 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT: basic i/o … … 148 148 // display general help, otherwise 149 149 void feHelp(char* str = NULL); 150 // if browser != NULL or OptionValue("browser") != NULL150 // if browser != NULL or feOpt("browser") != NULL 151 151 // set HelpBrowser to browser 152 152 // otherwise, if browser was already set, leave as is, 153 153 // if not, choose first available browser 154 154 // return string identifying current browser 155 // keeps OptionValue("browser") up-to-date155 // keeps feOpt("browser") up-to-date 156 156 // Optional warn argument is as in feResource 157 157 char* feHelpBrowser(char* browser = NULL, int warn = -1); 158 158 void feStringAppendBrowsers(int warn = -1); 159 159 160 /***************************************************************** 161 * 162 * version Id 163 * 164 *****************************************************************/ 165 extern unsigned long feVersionId; 166 167 /***************************************************************** 168 * 169 * File Stuff 170 * 171 *****************************************************************/ 160 172 FILE * feFopen(char *path, char *mode, char *where=NULL, int useWerror=FALSE); 161 173 #ifndef __MWERKS__ -
Singular/fehelp.cc
raef7ccb rc06a32 21 21 #include "ipshell.h" 22 22 #include "libparse.h" 23 #include "feOpt.h" 23 24 24 25 /***************************************************************** … … 149 150 Warn("No help for topic '%s' (not even for '*%s*')", str, str); 150 151 WarnS("Try '?;' for general help"); 151 WarnS("or '?Index;' for all available help topics ");152 WarnS("or '?Index;' for all available help topics."); 152 153 return; 153 154 } … … 182 183 { 183 184 int i = 0; 184 extern void mainSetSingOptionValue(const char* name, char* value);185 char* mainGetSingOptionValue(const char* name);186 187 // if no argument, see what we have as value to the option188 if (which == NULL || *which == '\0')189 which = mainGetSingOptionValue("browser");190 185 191 186 // if no argument, choose first available help browser 192 187 if (which == NULL || *which == '\0') 193 188 { 194 // unles one is already set 195 if (heCurrentHelpBrowser != NULL) goto Finish; 196 189 // return, if already set 190 if (heCurrentHelpBrowser != NULL) 191 return heCurrentHelpBrowser->browser; 192 193 // First, try emacs, if emacs-option is set 194 if (feOptValue(FE_OPT_EMACS) != NULL) 195 { 196 while (heHelpBrowsers[i].browser != NULL) 197 { 198 if (strcmp(heHelpBrowsers[i].browser, "emacs") == 0 && 199 (heHelpBrowsers[i].init_proc(0))) 200 { 201 heCurrentHelpBrowser = &(heHelpBrowsers[i]); 202 goto Finish; 203 } 204 i++; 205 } 206 i=0; 207 } 197 208 while (heHelpBrowsers[i].browser != NULL) 198 209 { … … 200 211 { 201 212 heCurrentHelpBrowser = &(heHelpBrowsers[i]); 202 return heCurrentHelpBrowser->browser;213 goto Finish; 203 214 } 204 215 i++; … … 215 226 if (heHelpBrowsers[i].browser == NULL) 216 227 { 217 if (warn) Warn("No help browser '%s' available ", which);228 if (warn) Warn("No help browser '%s' available.", which); 218 229 } 219 230 else … … 230 241 if (heCurrentHelpBrowser == NULL) 231 242 { 232 // choose first available help browser233 mainSetSingOptionValue("browser", "");234 243 feHelpBrowser(); 235 244 assume(heCurrentHelpBrowser != NULL); 236 245 if (warn) 237 Warn("Setting help browser to '%s' ", heCurrentHelpBrowser->browser);246 Warn("Setting help browser to '%s'.", heCurrentHelpBrowser->browser); 238 247 return heCurrentHelpBrowser->browser; 239 248 } … … 242 251 // or, leave as is 243 252 if (warn) 244 Warn("Help browser stays at '%s'", heCurrentHelpBrowser->browser); 253 Warn("Help browser stays at '%s'.", heCurrentHelpBrowser->browser); 254 return heCurrentHelpBrowser->browser; 245 255 } 246 256 247 257 Finish: 248 mainSetSingOptionValue("browser", heCurrentHelpBrowser->browser); 258 // update value of Browser Option 259 if (feOptSpec[FE_OPT_BROWSER].value == NULL || 260 strcmp((char*) feOptSpec[FE_OPT_BROWSER].value, 261 heCurrentHelpBrowser->browser) != 0) 262 { 263 if (feOptSpec[FE_OPT_BROWSER].value == NULL) 264 FreeL(feOptSpec[FE_OPT_BROWSER].value); 265 feOptSpec[FE_OPT_BROWSER].value 266 = (void*) mstrdup(heCurrentHelpBrowser->browser); 267 } 249 268 return heCurrentHelpBrowser->browser; 250 269 } … … 642 661 return; 643 662 644 if (heCurrentHelpBrowser == NULL) feHelpBrowser( );663 if (heCurrentHelpBrowser == NULL) feHelpBrowser(NULL, 0); 645 664 assume(heCurrentHelpBrowser != NULL); 646 665 if (! feHelpCalled) … … 722 741 { 723 742 if (warn) WarnS("no local HtmlDir found"); 724 if (warn) Warn("using %s instead", feResource('u' /*"ManualUrl"*/, warn)); 743 return FALSE; 744 // if (warn) Warn("using %s instead", feResource('u' /*"ManualUrl"*/, warn)); 725 745 } 726 746 return TRUE; -
Singular/feread.cc
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: feread.cc,v 1.2 2 1999-08-25 16:02:47 SingularExp $ */4 /* $Id: feread.cc,v 1.23 1999-09-20 18:03:48 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: input from ttys, simulating fgets … … 8 8 9 9 10 #include "version.h"11 10 #include "mod2.h" 12 11 #include "tok.h" -
Singular/find_exec.c
raef7ccb rc06a32 64 64 { 65 65 if (((name[0] == '.') && (name[1] == '/')) || 66 ((name[0] == '.') && (name[1] == '.') && (name[2] == '/')) )67 {68 strcpy (tbuf, (name[1] == '.' ? ".." : "."));66 ((name[0] == '.') && (name[1] == '.') && (name[2] == '/')) || 67 strchr(name, '/') != NULL) 68 { 69 69 70 70 #ifdef HAVE_GETCWD … … 77 77 strcat (tbuf, "/"); 78 78 strcat (tbuf, name); 79 return copy_of (tbuf);80 }81 79 if (! access(name, X_OK)) 80 return copy_of (tbuf); 81 } 82 82 83 83 search = getenv("PATH"); -
Singular/getopt.h
raef7ccb rc06a32 16 16 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 17 17 18 /* obachman: adapted to Singular by adding prefix fe_ to global variables 19 */ 18 20 #ifndef _GETOPT_H 19 21 #define _GETOPT_H 1 … … 29 31 each non-option ARGV-element is returned here. */ 30 32 31 extern char * optarg;33 extern char *fe_optarg; 32 34 33 35 /* Index in ARGV of the next element to be scanned. … … 43 45 how much of ARGV has been scanned so far. */ 44 46 45 extern int optind;47 extern int fe_optind; 46 48 47 49 /* Callers store zero here to inhibit the error message `getopt' prints 48 50 for unrecognized options. */ 49 51 50 extern int opterr;52 extern int fe_opterr; 51 53 52 54 /* Set to an option character which was unrecognized. */ 53 55 54 extern int optopt;56 extern int fe_optopt; 55 57 56 58 /* Describe the long-named options requested by the application. … … 75 77 returns the contents of the `val' field. */ 76 78 77 struct option 79 typedef enum {feOptBool=0, feOptInt, feOptString} feOptType; 80 struct fe_option 78 81 { 79 82 #if __STDC__ … … 87 90 int *flag; 88 91 int val; 92 /* Stuff added for Singular */ 93 const char* arg_name;// name of argument, for display in help 94 const char* help; // (short) help string 95 feOptType type; // type of argument, if has_arg > 0 96 void* value; // (default) value of option 97 int set; // only relevant for strings: 0 if not set, 1 if set 89 98 }; 90 99 91 100 /* Names for the values of the `has_arg' field of `struct option'. */ 92 101 93 #define no_argument 102 #define no_argument 0 94 103 #define required_argument 1 95 104 #define optional_argument 2 … … 100 109 differences in the consts, in stdlib.h. To avoid compilation 101 110 errors, only prototype getopt for the GNU C library. */ 102 extern int getopt (int argc, char *const *argv, const char *shortopts);111 extern int fe_getopt (int argc, char *const *argv, const char *shortopts); 103 112 #endif /* not __GNU_LIBRARY__ */ 104 extern int getopt_long (int argc, char *const *argv, const char *shortopts,105 const struct option *longopts, int *longind);106 extern int getopt_long_only (int argc, char *const *argv,113 extern int fe_getopt_long (int argc, char *const *argv, const char *shortopts, 114 const struct fe_option *longopts, int *longind); 115 extern int fe_getopt_long_only (int argc, char *const *argv, 107 116 const char *shortopts, 108 const struct option *longopts, int *longind);117 const struct fe_option *longopts, int *longind); 109 118 110 119 /* Internal only. Users should not call this directly. */ 111 extern int _ getopt_internal (int argc, char *const *argv,120 extern int _fe_getopt_internal (int argc, char *const *argv, 112 121 const char *shortopts, 113 const struct option *longopts, int *longind,122 const struct fe_option *longopts, int *longind, 114 123 int long_only); 115 124 #else /* not __STDC__ */ 116 extern int getopt ();117 extern int getopt_long ();118 extern int getopt_long_only ();125 extern int fe_getopt (); 126 extern int fe_getopt_long (); 127 extern int fe_getopt_long_only (); 119 128 120 extern int _ getopt_internal ();129 extern int _fe_getopt_internal (); 121 130 #endif /* not __STDC__ */ 122 131 -
Singular/ipshell.h
raef7ccb rc06a32 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: ipshell.h,v 1. 19 1999-07-28 17:51:07 SingularExp $ */6 /* $Id: ipshell.h,v 1.20 1999-09-20 18:03:49 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 24 24 extern int myynest; 25 25 extern char * currid; 26 extern char * thisfile;26 extern char * feArgv0; 27 27 extern int iiRETURNEXPR_len; 28 28 extern sleftv *iiRETURNEXPR; -
Singular/kbPolyProcs.cc
raef7ccb rc06a32 373 373 374 374 // set characterisic 375 if (r ->ch > 1) ch = chMODP;375 if (rField_is_Zp(r)) ch = chMODP; 376 376 377 377 // set Ordering Type -
Singular/misc.cc
raef7ccb rc06a32 14 14 #include <limits.h> 15 15 16 #include "version.h"17 16 #include "mod2.h" 18 17 #include "tok.h" -
Singular/mmisc.c
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mmisc.c,v 1. 9 1999-08-18 09:18:28obachman Exp $ */4 /* $Id: mmisc.c,v 1.10 1999-09-20 18:03:50 obachman Exp $ */ 5 5 6 6 /* … … 13 13 #include "mmpage.h" 14 14 #include "febase.h" 15 #include "distrib.h" 16 15 17 #ifdef MTRACK 16 18 #include "mmbt.h" -
Singular/sing_mp.cc
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: sing_mp.cc,v 1.2 6 1999-08-13 11:21:44 SingularExp $ */4 /* $Id: sing_mp.cc,v 1.27 1999-09-20 18:03:50 obachman Exp $ */ 5 5 6 6 /* … … 22 22 #include "ipid.h" 23 23 #include "silink.h" 24 #include "feOpt.h" 24 25 25 26 static int Batch_ReadEval(si_link silink); … … 164 165 * 165 166 ***************************************************************/ 166 extern BOOLEAN mainGetSingOptionValue(const char* name, char** val);167 168 167 169 168 static MP_Link_pt slOpenMPConnect(int n_argc, char **n_argv) … … 175 174 char *host = IMP_GetCmdlineArg(n_argc, n_argv, "--MPhost"); 176 175 177 if (port == NULL) mainGetSingOptionValue("--MPport", &port);178 if (host == NULL) mainGetSingOptionValue("--MPhost", &host);176 if (port == NULL) port = (char*) feOptValue(FE_OPT_MP_PORT); 177 if (host == NULL) host = (char*) feOptValue(FE_OPT_MP_HOST); 179 178 180 179 if (port != NULL) … … 194 193 char *port = IMP_GetCmdlineArg(n_argc, n_argv, "--MPport"); 195 194 196 if (port == NULL) mainGetSingOptionValue("--MPport", &port);195 if (port == NULL) port = (char*) feOptValue(FE_OPT_MP_HOST); 197 196 198 197 if (port != NULL) argv[5] = port; -
Singular/tesths.cc
raef7ccb rc06a32 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: tesths.cc,v 1. 69 1999-08-25 15:26:02obachman Exp $ */4 /* $Id: tesths.cc,v 1.70 1999-09-20 18:03:51 obachman Exp $ */ 5 5 6 6 /* … … 15 15 #include <time.h> 16 16 #include <errno.h> 17 #include "version.h"18 17 #include "mod2.h" 19 18 #include "tok.h" … … 27 26 #include "timer.h" 28 27 #include "sdb.h" 28 #include "fegetopt.h" 29 #include "feOpt.h" 30 #include "distrib.h" 31 #include "version.h" 32 29 33 #ifdef HAVE_FACTORY 30 34 #define SI_DONT_HAVE_GLOBAL_VARS … … 32 36 #endif 33 37 34 #include "feCmdLineOptions.cc"35 38 /*0 implementation*/ 36 39 int main( /* main entry to Singular */ … … 38 41 char** argv) /* parameter array */ 39 42 { 40 char * thisfile;41 /* initialize components */42 siRandomStart=inits();43 43 #ifdef INIT_BUG 44 44 jjInitTab1(); … … 54 54 ttGen2(); 55 55 #else 56 thisfile = argv[0]; 57 BOOLEAN load_std_lib=TRUE; 58 BOOLEAN load_rc = TRUE; 59 char* execute_string = NULL; 56 /* initialize components */ 57 siRandomStart=inits(); 58 feOptSpec[FE_OPT_RANDOM].value = (void*) siRandomStart; 60 59 int optc, option_index; 60 char* errormsg; 61 61 62 62 // do this first, because -v might print version path 63 feInitResources( thisfile);63 feInitResources(argv[0]); 64 64 65 65 // parse command line options 66 while((optc = getopt_long(argc, argv, 67 SHORT_OPTS_STRING, longopts, &option_index)) 66 while((optc = fe_getopt_long_only(argc, argv, 67 SHORT_OPTS_STRING, feOptSpec, &option_index)) 68 // "", feOptSpec, &option_index)) 68 69 != EOF) 69 70 { 70 switch(optc) 71 { 72 73 case 'b': 74 #ifdef HAVE_MPSR 75 fe_fgets_stdin=fe_fgets_dummy; 76 mainSetSingOptionValue(LON_BATCH, (char*) 1); 77 break; 78 #else 79 printf("%s: Option `-b' not supported in this configuration\n", argv[0]); 80 mainUsage(argv[0]); 81 exit(1); 82 #endif 83 case 'h': 84 mainHelp(argv[0]); 85 exit(0); 86 87 case 'q': 88 verbose &= ~(Sy_bit(0)|Sy_bit(V_LOAD_LIB)); 89 mainSetSingOptionValue(LON_QUIET, (char*) 1); 90 break; 91 92 case 't': 93 #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) 94 fe_fgets_stdin=fe_fgets; 95 #endif 96 mainSetSingOptionValue(LON_NO_TTY, (char*) 1); 97 break; 98 99 case 'd': 100 sdb_flags = 1; 101 break; 102 103 case 'v': 104 printf("Singular for %s version %s (%d) %s %s\n", 105 S_UNAME, S_VERSION1, 106 SINGULAR_VERSION_ID,__DATE__,__TIME__); 107 printf("with\n"); 108 printf(versionString()); 109 printf("\n\n"); 110 mainSetSingOptionValue(LON_VERSION, (char*) 1); 111 break; 112 113 case 'x': 114 #ifdef HAVE_TCL 115 tclmode = TRUE; 116 fe_fgets_stdin=fe_fgets_tcl; 117 mainSetSingOptionValue(LON_TCLMODE, (char*) 1); 118 verbose|=Sy_bit(V_SHOW_MEM); 119 break; 120 #else 121 printf("%s: Option `-x' not supported in this configuration\n", argv[0]); 122 mainUsage(argv[0]); 123 exit(1); 124 #endif 125 126 case 'e': 127 if (optarg != NULL) 128 { 129 errno = 0; 130 si_echo = strtol(optarg, NULL, 10); 131 if (errno) 132 { 133 printf("%s: `%s' invalid integer argument for option `--%s'\n", argv[0], optarg, LON_ECHO); 134 mainUsage(argv[0]); 135 exit(1); 136 } 137 if (si_echo < 0 || si_echo > 9) 138 { 139 printf("%s: `%s' argument for option `--%s' is not in valid range 0..9\n", 140 argv[0], optarg, LON_ECHO); 141 mainUsage(argv[0]); 142 exit(1); 143 } 144 mainSetSingOptionValue(LON_ECHO, optarg); 145 } 146 else 147 { 148 si_echo = 1; 149 mainSetSingOptionValue(LON_ECHO, "1"); 150 } 151 break; 152 153 case 'c': 154 execute_string = optarg; 155 mainSetSingOptionValue(LON_EXECUTE, optarg); 156 break; 157 158 case 'r': 159 errno = 0; 160 siRandomStart = strtol(optarg, NULL, 10); 161 if (errno || siRandomStart == 0) 162 { 163 printf("%s: `%s' invalid integer argument for option `--%s'\n", argv[0], optarg, LON_RANDOM); 164 mainUsage(argv[0]); 165 exit(1); 166 } 167 #ifdef buildin_rand 168 siSeed=siRandomStart; 169 #else 170 srand((unsigned int)siRandomStart); 171 #endif 172 #ifdef HAVE_FACTORY 173 factoryseed(siRandomStart); 174 #endif 175 mainSetSingOptionValue(LON_RANDOM, optarg); 176 break; 177 178 case 'u': 179 mainSetSingOptionValue(LON_USER_OPTION, optarg); 180 break; 181 182 case LONG_OPTION_RETURN: 183 if (strcmp(longopts[option_index].name, LON_NO_STDLIB) == 0) 184 { 185 load_std_lib = FALSE; 186 mainSetSingOptionValue(LON_NO_STDLIB, (char*) 1); 187 } 188 else if (strcmp(longopts[option_index].name, LON_BROWSER) == 0) 189 { 190 mainSetSingOptionValue(LON_BROWSER, optarg); 191 } 192 else if (strcmp(longopts[option_index].name, LON_EMACS) == 0) 193 { 194 mainSetSingOptionValue(LON_EMACS, (char*) 1); 195 // print EmacsDir and InfoFile so that Emacs 196 // mode can pcik it up 197 Warn("EmacsDir: %s", (feResource('e' /*"EmacsDir"*/) != NULL ? 198 feResource('e' /*"EmacsDir"*/) : "")); 199 Warn("InfoFile: %s", (feResource('i' /*"InfoFile"*/) != NULL ? 200 feResource('i' /*"InfoFile"*/) : "")); 201 } 202 else if (strcmp(longopts[option_index].name, LON_NO_RC) == 0) 203 { 204 load_rc = FALSE; 205 mainSetSingOptionValue(LON_NO_RC, (char*) 1); 206 } 207 else if (strcmp(longopts[option_index].name, LON_NO_WARN) == 0) 208 { 209 feWarn = FALSE; 210 mainSetSingOptionValue(LON_NO_WARN, (char*) 1); 211 } 212 else if (strcmp(longopts[option_index].name, LON_NO_OUT) == 0) 213 { 214 feOut = FALSE; 215 mainSetSingOptionValue(LON_NO_OUT, (char*) 1); 216 } 217 else if (strcmp(longopts[option_index].name, LON_MIN_TIME) == 0) 218 { 219 double mintime = atof(optarg); 220 if (mintime <= 0) 221 { 222 printf("%s: `%s' invalid float argument for option `--%s'\n", 223 argv[0], optarg, LON_MIN_TIME); 224 mainUsage(argv[0]); 225 exit(1); 226 } 227 SetMinDisplayTime(mintime); 228 mainSetSingOptionValue(LON_MIN_TIME, optarg); 229 } 230 #ifdef HAVE_MPSR 231 else if (strcmp(longopts[option_index].name, LON_MP_PORT) == 0) 232 { 233 mainSetSingOptionValue(LON_MP_PORT, optarg); 234 } 235 else if (strcmp(longopts[option_index].name, LON_MP_HOST) == 0) 236 { 237 mainSetSingOptionValue(LON_MP_HOST, optarg); 238 } 239 #endif 240 else if (strcmp(longopts[option_index].name, LON_TICKS_PER_SEC) == 0) 241 { 242 int ticks = atoi(optarg); 243 if (ticks <= 0) 244 { 245 printf("%s: `%s' invalid integer argument for option `--%s'\n", 246 argv[0], optarg, LON_TICKS_PER_SEC); 247 mainUsage(argv[0]); 248 exit(1); 249 } 250 SetTimerResolution(ticks); 251 mainSetSingOptionValue(LON_TICKS_PER_SEC, optarg); 252 } 253 else 254 // undocumented options 255 #ifdef HAVE_MPSR 256 if (strcmp(longopts[option_index].name, LON_MP_MODE) == 0 || 257 strcmp(longopts[option_index].name, LON_MP_TRANSP) == 0) 258 { 259 /* ignore */ 260 } 261 else 262 #endif 263 assume(0); 264 break; 265 266 default: 267 // Error message already emmited by getopt_long 268 mainUsage(argv[0]); 269 exit(1); 270 } 271 } 71 if (optc == '?' || optc == 0) 72 { 73 fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0); 74 exit(1); 75 } 76 77 if (optc != LONG_OPTION_RETURN) 78 option_index = feGetOptIndex(optc); 79 80 assume(option_index > 0 && option_index < (int) FE_OPT_UNDEF); 81 82 if (fe_optarg == NULL && 83 (feOptSpec[option_index].type == feOptBool || 84 feOptSpec[option_index].has_arg == optional_argument)) 85 errormsg = feSetOptValue((feOptIndex) option_index, (int) 1); 86 else 87 errormsg = feSetOptValue((feOptIndex) option_index, fe_optarg); 88 89 if (errormsg) 90 { 91 if (fe_optarg == NULL) 92 fprintf(stderr, "Error: Option '--%s' %s\n", 93 feOptSpec[option_index].name, errormsg); 94 else 95 fprintf(stderr, "Error: Option '--%s=%s' %s\n", 96 feOptSpec[option_index].name, fe_optarg, errormsg); 97 fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0); 98 exit(1); 99 } 100 if (optc == 'h') exit(0); 101 } 102 272 103 /* say hello */ 273 104 { … … 307 138 } 308 139 slStandardInit(); 309 dlInit( thisfile);140 dlInit(feArgv0); 310 141 myynest=0; 311 if ( load_std_lib)142 if (! feOptValue(FE_OPT_NO_STDLIB)) 312 143 { 313 144 int vv=verbose; … … 327 158 328 159 // Last thing to do is to execute given scripts 329 if ( optind < argc)160 if (fe_optind < argc) 330 161 { 331 162 int i = argc - 1; 332 while (i >= optind)163 while (i >= fe_optind) 333 164 { 334 165 newFile(argv[i]); … … 342 173 343 174 // before scripts, we execute -c, if it was given 344 // now execute -c, if it was given 345 if (execute_string != NULL) 346 newBuffer(mstrdup(execute_string), BT_execute); 175 if (feOptValue(FE_OPT_EXECUTE) != NULL) 176 newBuffer(mstrdup((char*) feOptValue(FE_OPT_EXECUTE)), BT_execute); 347 177 348 178 // first thing, however, is to load .singularrc 349 if ( load_rc)179 if (! feOptValue(FE_OPT_NO_RC)) 350 180 { 351 181 FILE * rc=myfopen(".singularrc","r"); … … 378 208 #ifdef HAVE_MPSR 379 209 extern int Batch_do(const char* port, const char* host); 380 return Batch_do( mainGetSingOptionValue(LON_MP_PORT),381 mainGetSingOptionValue(LON_MP_HOST));210 return Batch_do((char*) feOptValue(FE_OPT_MP_PORT), 211 (char*) feOptValue(FE_OPT_MP_HOST)); 382 212 #else 383 213 assume(0); … … 391 221 return 0; 392 222 } 223 -
Singular/utils.cc
raef7ccb rc06a32 3 3 #include <stdlib.h> 4 4 #include <ctype.h> 5 #include " getopt.h"5 #include "fegetopt.h" 6 6 #include "utils.h" 7 7 #ifdef __MWERKS__ 8 8 #define __GNU_LIBRARY__ 9 #include " getopt.h"9 #include "fegetopt.h" 10 10 #endif 11 11 … … 38 38 char c; 39 39 40 while((c= getopt(argc, argv, "ihd:sf:"))>=0) {40 while((c=fe_getopt(argc, argv, "ihd:sf:"))>=0) { 41 41 switch(c) { 42 42 case 'd': 43 43 lpverbose = 1; 44 if(isdigit(argv[ optind-1][0])) sscanf(optarg, "%d", &lpverbose);45 else optind--;46 break; 47 case 'f': lib_file = argv[ optind-1];44 if(isdigit(argv[fe_optind-1][0])) sscanf(optarg, "%d", &lpverbose); 45 else fe_optind--; 46 break; 47 case 'f': lib_file = argv[fe_optind-1]; 48 48 break; 49 49 case 's': … … 57 57 break; 58 58 59 case -1 : printf("no such option:%s\n", argv[ optind]);59 case -1 : printf("no such option:%s\n", argv[fe_optind]); 60 60 usage(argv[0]); 61 61 break; 62 default: printf("no such option.%x, %c %s\n", c&0xff, c, argv[ optind]);62 default: printf("no such option.%x, %c %s\n", c&0xff, c, argv[fe_optind]); 63 63 usage(argv[0]); 64 64 } … … 73 73 printf("$library = \"%s\";\n", lib_file); 74 74 } else { 75 while(argc> optind && yylpin==NULL) {76 yylpin = fopen( argv[ optind], "rb" );75 while(argc>fe_optind && yylpin==NULL) { 76 yylpin = fopen( argv[fe_optind], "rb" ); 77 77 if(yylpin!=NULL) 78 78 { 79 lib_file = argv[ optind];79 lib_file = argv[fe_optind]; 80 80 if (! texinfo_out) 81 printf("Checking library '%s'\n", argv[ optind]);81 printf("Checking library '%s'\n", argv[fe_optind]); 82 82 else 83 83 printf("$library = \"%s\";\n", lib_file); 84 84 } 85 else optind++;85 else fe_optind++; 86 86 } 87 87 }
Note: See TracChangeset
for help on using the changeset viewer.