Changeset 12129


Ignore:
Timestamp:
May 26, 2009, 5:35:06 PM (10 years ago)
Author:
gb
Message:

Try to set the new KERNEL-PATH kernel global to the value of
real_executable_name; try harder to ensure that real_executable_name
and the image name are fully qualified and resolved pathnames.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r12095 r12129  
    153153extern LispObj nvalret;
    154154extern LispObj popj;
    155 #ifdef X86
    156 extern LispObj bad_funcall;
    157 #endif
    158155
    159156LispObj text_start = 0;
     
    951948
    952949#ifndef WINDOWS
     950
     951char *
     952ensure_real_path(char *path)
     953{
     954  char buf[PATH_MAX*2], *p, *q;
     955  int n;
     956
     957  p = realpath(path, buf);
     958 
     959  if (p == NULL) {
     960    return path;
     961  }
     962  n = strlen(p);
     963  q = malloc(n+1);
     964  strcpy(q,p);
     965  return q;
     966}
     967
    953968char *
    954969determine_executable_name(char *argv0)
     
    962977    memmove(p, exepath, len);
    963978    p[len]=0;
    964     return p;
     979    return ensure_real_path(p);
    965980  }
    966   return argv0;
     981  return ensure_real_path(argv0);
    967982#endif
    968983#ifdef LINUX
     
    979994#endif
    980995#ifdef FREEBSD
    981   return argv0;
     996  return ensure_real_path(argv0);
    982997#endif
    983998#ifdef SOLARIS
     
    9931008    return p;
    9941009  }
    995   return argv0;
    996 #endif
    997   return argv0;
     1010  return ensure_real_path(argv0);
     1011#endif
     1012  return ensure_real_path(argv0);
     1013}
     1014#endif
     1015
     1016#ifdef WINDOWS
     1017wchar_t *
     1018ensure_real_path(wchar_t *path)
     1019{
     1020  int bufsize = 256, n;
     1021
     1022  do {
     1023    wchar_t buf[bufsize];
     1024
     1025    n = GetFullPathnameW(path,bufsize,buf,NULL);
     1026    if (n == 0) {
     1027      return path;
     1028    }
     1029
     1030    if (n < bufsize) {
     1031      int i;
     1032      wchar *q = calloc(n+1,sizeof(wchar_t));
     1033
     1034      for (i = 0; i < n; i++) {
     1035        q[i] = buf[i];
     1036      }
     1037      return q;
     1038    }
     1039    bufsize = n+1;
     1040  }
    9981041}
    9991042#endif
     
    17931836  lisp_global(LEXPR_RETURN1V) = (LispObj)&popj;
    17941837  lisp_global(ALL_AREAS) = ptr_to_lispobj(all_areas);
    1795 #ifdef X86
    1796   lisp_global(BAD_FUNCALL) = ptr_to_lispobj(&bad_funcall);
    1797 #endif
    17981838  lisp_global(DEFAULT_ALLOCATION_QUANTUM) = log2_heap_segment_size << fixnumshift;
    17991839  lisp_global(STACK_SIZE) = thread_stack_size<<fixnumshift;
     
    18051845
    18061846#ifdef WINDOWS
    1807   lisp_global(IMAGE_NAME) = ptr_to_lispobj(utf_16_to_utf_8(image_name));
     1847  lisp_global(IMAGE_NAME) = ptr_to_lispobj(utf_16_to_utf_8(ensure_real_path(image_name)));
     1848  lisp_global(KERNEL_PATH) = ptr_to_lispobj(utf_16_to_utf_8(real_executable_name));
    18081849  lisp_global(ARGV) = ptr_to_lispobj(wide_argv_to_utf_8(utf_16_argv, argc));
    18091850#else
    1810   lisp_global(IMAGE_NAME) = ptr_to_lispobj(image_name);
     1851  lisp_global(IMAGE_NAME) = ptr_to_lispobj(ensure_real_path(image_name));
     1852  lisp_global(KERNEL_PATH) = ptr_to_lispobj(real_executable_name);
    18111853  lisp_global(ARGV) = ptr_to_lispobj(argv);
    18121854#endif
Note: See TracChangeset for help on using the changeset viewer.