=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/parse/glob.c,v retrieving revision 1.28 retrieving revision 1.38 diff -u -p -r1.28 -r1.38 --- OpenXM_contrib2/asir2000/parse/glob.c 2002/09/11 08:57:21 1.28 +++ OpenXM_contrib2/asir2000/parse/glob.c 2003/10/19 02:54:41 1.38 @@ -45,13 +45,13 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/parse/glob.c,v 1.27 2002/07/26 00:33:03 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/parse/glob.c,v 1.37 2003/09/12 01:12:41 noro Exp $ */ #include "ca.h" #include "al.h" #include "parse.h" #include "ox.h" -#if PARI +#if defined(PARI) #include "genpari.h" #endif #if !defined(VISUAL) && !defined(_PA_RISC1_1) && !defined(linux) && !defined(SYSV) && !defined(__CYGWIN__) @@ -61,6 +61,10 @@ #if defined(VISUAL) #include #include +#else +#include +#include +#include #endif #if defined(SYSV) && !defined(_IBMR2) @@ -85,7 +89,7 @@ char *asir_pager; NODE usrf,sysf,noargsysf,ubinf,parif; NODE ONENODE; -int main_parser, ox_do_copy, ox_do_count, ox_count_length; +int main_parser, allow_create_var, ox_do_copy, ox_do_count, ox_count_length; int ox_file_io, ox_need_conv; char *ox_copy_bptr; char *parse_strp; @@ -124,29 +128,26 @@ struct oVS oGPVS,oAPVS,oEPVS; VS GPVS = &oGPVS; VS APVS = &oAPVS; VS EPVS = &oEPVS; -VS CPVS; +VS CPVS,MPVS; +NODE MODULE_LIST; +MODULE CUR_MODULE; +char *CUR_FUNC; + struct oF oF_TRUE,oF_FALSE; F F_TRUE = &oF_TRUE; F F_FALSE = &oF_FALSE; -#if defined(__SVR4) && defined(sun) -char cppname[BUFSIZ] = "/usr/ccs/lib/cpp "; -#else -#if defined(__FreeBSD__) || defined(__NetBSD__) || (defined(__MACH__) && defined(__ppc__)) || defined(__CYGWIN__) -char cppname[BUFSIZ] = "/usr/bin/cpp "; -#else #if defined(VISUAL) char cppname[BUFSIZ] = "c:\\asir\\stdlib\\cpp "; #else char cppname[BUFSIZ] = "/lib/cpp "; #endif -#endif -#endif char asirname[BUFSIZ]; char displayname[BUFSIZ]; int Verbose; +int do_quiet; void glob_init() { int i; @@ -211,7 +212,7 @@ void asir_terminate(int status) LONGJMP(exec_env,status); } else { tty_reset(); -#if MPI +#if defined(MPI) if ( !mpi_myid ) close_allconnections(); mpi_finalize(); @@ -253,14 +254,56 @@ void sprompt(char *ptr) sprintf(ptr,"[%d] ",APVS->n); } +#if !defined(VISUAL) +static int which(char *prog, char *path, char *buf, size_t size) +{ + char *tok; + char delim[] = ":"; + char *path2 = malloc(strlen(path)+1); + char *name = malloc(size); + int proglen = strlen(prog)+3; /* "/" + prog + " \0" */ + + if (!name || !path2) { + return 0; + } + strcpy(path2, path); + tok = strtok(path2, delim); + while (tok != NULL) { + if (size >= strlen(tok)) { + sprintf(name, "%s/%s", tok, prog); + if (access(name, X_OK&R_OK) == 0) { + strcpy(buf, name); + strcat(buf, " "); + free(path2); free(name); + return 1; + } + tok = strtok(NULL, delim); + } + } + free(path2); free(name); + return 0; +} +#endif + +void cppname_init() +{ +#if !defined(VISUAL) + if (access(cppname, X_OK&R_OK) != 0) { + which("cpp", "/lib:/usr/ccs/lib:/usr/bin", cppname, BUFSIZ) || + which("cpp", getenv("PATH"), cppname, BUFSIZ); + } +#endif +} + FILE *in_fp; void process_args(int ac,char **av) { do_asirrc = 1; -#if !MPI +#if !defined(MPI) do_message = 1; #endif + do_quiet = 0; while ( ac > 0 ) { if ( !strcmp(*av,"-heap") && (ac >= 2) ) { void GC_expand_hp(int); @@ -279,6 +322,7 @@ void process_args(int ac,char **av) } else if ( !strcmp(*av,"-cpp") && (ac >= 2) ) { strcpy(cppname,*(av+1)); av += 2; ac -= 2; } else if ( !strcmp(*av,"-f") && (ac >= 2) ) { + do_quiet = 1; in_fp = fopen(*(av+1),"r"); if ( !in_fp ) { fprintf(stderr,"%s does not exist!",*(av+1)); @@ -286,6 +330,8 @@ void process_args(int ac,char **av) } do_file = 1; av += 2; ac -= 2; + } else if ( !strcmp(*av,"-quiet") ) { + do_quiet = 1; av++; ac--; } else if ( !strcmp(*av,"-norc") ) { do_asirrc = 0; av++; ac--; } else if ( !strcmp(*av,"-nomessage") ) { @@ -306,7 +352,7 @@ void process_args(int ac,char **av) } else if ( !strcmp(*av,"-fep") ) { do_fep = 1; av++; ac--; #endif -#if PARI +#if defined(PARI) } else if ( !strcmp(*av,"-paristack") ) { extern int paristack; @@ -390,7 +436,7 @@ void resetenv(char *s) w_noflush_stderr(0); #endif asir_out = stdout; -#if PARI +#if defined(PARI) pari_outfile = stdout; #endif /* restore states */ @@ -590,7 +636,7 @@ SNODE error_snode; void error(char *s) { - SNODE *snp; + SNODE *snp=0; #if !defined(VISUAL) if ( timer_is_set ) @@ -599,7 +645,7 @@ void error(char *s) fprintf(stderr,"%s\n",s); set_lasterror(s); if ( CPVS != GPVS ) { - if ( CPVS->usrf && CPVS->usrf && CPVS->usrf->f.usrf ) + if ( CPVS && CPVS->usrf && CPVS->usrf->f.usrf ) searchsn(&BDY(CPVS->usrf->f.usrf),evalstatline,&snp); if ( snp ) error_snode = *snp; @@ -667,9 +713,15 @@ void copyright() { get_asir_version(), get_asir_distribution()); #endif printf("Copyright (C) 1994-2000, all rights reserved, FUJITSU LABORATORIES LIMITED.\n"); - printf("Copyright 2000,2001, Risa/Asir committers, http://www.openxm.org/.\n"); + printf("Copyright 2000-2003, Risa/Asir committers, http://www.openxm.org/.\n"); printf("GC 6.1(alpha5) copyright 2001, H-J. Boehm, A. J. Demers, Xerox, SGI, HP.\n"); +#if PARI +#if 0 printf("PARI 2.2.4, copyright (C) 2002 The PARI Group.\n"); +#endif + printf("PARI 2.0.17, copyright 1989-1999, C. Batut, K. Belabas, D. Bernardi,\n"); + printf(" H. Cohen and M. Olivier.\n"); +#endif }