[BACK]Return to load.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / parse

Diff for /OpenXM_contrib2/asir2000/parse/load.c between version 1.10 and 1.19

version 1.10, 2004/03/02 07:44:02 version 1.19, 2006/02/05 08:28:04
Line 45 
Line 45 
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  *   *
  * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.9 2001/12/25 02:39:06 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.18 2005/03/28 09:20:38 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
Line 79 
Line 79 
 #define MALLOC(x) GC_malloc((x)+4)  #define MALLOC(x) GC_malloc((x)+4)
 #endif  #endif
   
 char *ASIRLOADPATH[32];  char **ASIRLOADPATH;
   
 #if defined(VISUAL)  #if defined(VISUAL)
 #define ENVDELIM ';'  #define ENVDELIM ';'
Line 90  char *ASIRLOADPATH[32];
Line 90  char *ASIRLOADPATH[32];
 #endif  #endif
   
 #ifndef ASIR_LIBDIR  #ifndef ASIR_LIBDIR
 #define ASIR_LIBDIR "."  #define ASIR_LIBDIR "/usr/local/lib/asir"
 #endif  #endif
   #ifndef ASIR_CONTRIB_DIR
   #define ASIR_CONTRIB_DIR "/usr/local/lib/asir-contrib"
   #endif
   
 char *getenv();  char *getenv();
 void Pget_rootdir();  void Pget_rootdir();
 char *search_executable(char *name);  char *search_executable(char *name);
   
 extern char *asir_libdir;  extern char *asir_libdir;
   extern char *asir_contrib_dir;
 extern char *asir_pager;  extern char *asir_pager;
 extern int read_exec_file;  extern int read_exec_file;
 extern int main_parser;  extern int main_parser;
Line 106  extern JMP_BUF exec_env;
Line 110  extern JMP_BUF exec_env;
 char *search_executable(char *name)  char *search_executable(char *name)
 {  {
         char *c,*s,*ret;          char *c,*s,*ret;
         int len;          int len,nlen;
         char dir[BUFSIZ],path[BUFSIZ];          char dir[BUFSIZ],path[BUFSIZ];
         struct stat buf;          struct stat buf;
   
           nlen = strlen(name);
         for ( s = (char *)getenv("PATH"); s; ) {          for ( s = (char *)getenv("PATH"); s; ) {
                 c = (char *)index(s,':');                  c = (char *)index(s,':');
                 if ( c ) {                  len = c ? c-s : strlen(s);
                         len = c-s;                  if ( len >= BUFSIZ ) continue;
                         strncpy(dir,s,len); s = c+1; dir[len] = 0;                  strncpy(dir,s,len); dir[len] = 0;
                 } else {                  if ( c ) s = c+1;
                         strcpy(dir,s); s = 0;                  else s = 0;
                 }                  if ( len+nlen+1 >= BUFSIZ ) continue;
                 sprintf(path,"%s/%s",dir,name);                  sprintf(path,"%s/%s",dir,name);
                 if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR)                  if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR)
                         && !access(path,X_OK) ) {  #if !defined(VISUAL)
                           && !access(path,X_OK)
   #endif
                   ) {
                         len = strlen(path)+1;                          len = strlen(path)+1;
                         ret = (char *)MALLOC(len);                          ret = (char *)MALLOC(len);
                         strcpy(ret,path);                          strcpy(ret,path);
Line 152  void env_init() {
Line 160  void env_init() {
 #endif  #endif
                 }                  }
         }          }
   
           if ( !(asir_contrib_dir = getenv("ASIR_CONTRIB_DIR")) ) {
                   if ( oxhome = getenv("OpenXM_HOME") ) {
                           asir_contrib_dir = (char *)malloc(strlen(oxhome)+strlen("/lib/asir-contrib")+1);
                           sprintf(asir_contrib_dir,"%s/lib/asir-contrib",oxhome);
                   } else {
   #if defined(VISUAL)
                           get_rootdir(rootname,sizeof(rootname));
                           asir_contrib_dir = (char *)malloc(strlen(rootname)+strlen("/lib-asir-contrib")+1);
                           sprintf(asir_contrib_dir,"%s/lib-asir-contrib",rootname);
   #else
                           asir_contrib_dir = (char *)malloc(strlen(ASIR_CONTRIB_DIR)+1);
                           strcpy(asir_contrib_dir,ASIR_CONTRIB_DIR);
   #endif
                   }
           }
   
         if ( !(asir_pager = getenv("PAGER")) ) {          if ( !(asir_pager = getenv("PAGER")) ) {
                 japanese = 0;                  japanese = 0;
                 if ( (e = getenv("LANGUAGE")) && strstr(e,"ja") ) japanese = 1;                  if ( (e = getenv("LANGUAGE")) &&
                 else if ( (e = getenv("LC_ALL")) && strstr(e,"ja") ) japanese = 1;                          (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                 else if ( (e = getenv("LC_CTYPE")) && strstr(e,"ja") ) japanese = 1;                  else if ( (e = getenv("LC_ALL")) &&
                 else if ( (e = getenv("LANG")) && strstr(e,"ja") ) japanese = 1;                          (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                   else if ( (e = getenv("LC_CTYPE")) &&
                           (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                   else if ( (e = getenv("LANG")) &&
                           (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                 if ( japanese )                  if ( japanese )
                         asir_pager = search_executable("jless");                          asir_pager = search_executable("jless");
                 if ( !asir_pager ) {                  if ( !asir_pager ) {
Line 166  void env_init() {
Line 195  void env_init() {
                         strcpy(asir_pager,MORE);                          strcpy(asir_pager,MORE);
                 }                  }
         }          }
         if ( e = getenv("ASIRLOADPATH" ) )          if ( e = getenv("ASIRLOADPATH" ) ) {
                 for ( i = 0; ; i++, e = p+1 ) {                  for ( i = 0; ; i++, e = p+1 ) {
                         p = (char *)index(e,ENVDELIM);                          p = (char *)index(e,ENVDELIM);
                           if ( !p )
                                   break;
                   }
                   i += 4;
           ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*i);
                   for ( l = 0; l<i; l++) ASIRLOADPATH[l] = NULL;
                   e = getenv("ASIRLOADPATH");
                   for ( i = 0; ; i++, e = p+1 ) {
                           p = (char *)index(e,ENVDELIM);
                         l = p ? p-e : strlen(e); q = (char *)MALLOC(l+1);                          l = p ? p-e : strlen(e); q = (char *)MALLOC(l+1);
                         if ( l ) {                          if ( l ) {
                                 strncpy(q,e,l); q[l] = 0; ASIRLOADPATH[i] = q;                                  strncpy(q,e,l); q[l] = 0; ASIRLOADPATH[i] = q;
Line 176  void env_init() {
Line 214  void env_init() {
                         if ( !p )                          if ( !p )
                                 break;                                  break;
                 }                  }
       }else{
             ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*3);
             ASIRLOADPATH[0] = NULL;
           }
   
         for ( i = 0; ASIRLOADPATH[i]; i++ );          for ( i = 0; ASIRLOADPATH[i]; i++ );
         ASIRLOADPATH[i] = asir_libdir;          if (asir_contrib_dir) ASIRLOADPATH[i++] = asir_contrib_dir;
           if (asir_libdir) ASIRLOADPATH[i++] = asir_libdir;
           ASIRLOADPATH[i] = NULL;
 }  }
   
 void searchasirpath(char *name,char **pathp)  void searchasirpath(char *name,char **pathp)
Line 355  void load_and_execfile(char *name)
Line 400  void load_and_execfile(char *name)
         savepvs();          savepvs();
         save_asir_infile = asir_infile;          save_asir_infile = asir_infile;
         save_prresult = prresult;          save_prresult = prresult;
         fp = fopen(name,"rb");          asir_infile = 0;
         input_init(fp,name);          loadasirfile(name);
         if ( !SETJMP(exec_env) ) {          if ( !SETJMP(exec_env) ) {
                 /* XXX : information for asir_teriminate() */                  /* XXX : information for asir_teriminate() */
                 read_exec_file = 2;                  read_exec_file = 2;
                 read_eval_loop();                  read_eval_loop();
                 read_exec_file = 0;                  read_exec_file = 0;
         }          }
         fclose(fp);  
         restorepvs();          restorepvs();
         asir_infile = save_asir_infile;          asir_infile = save_asir_infile;
         prresult = save_prresult;          prresult = save_prresult;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.19

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>