Raymond Toy pushed to branch issue-437-find-self at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/lisp/lisp.c
    ... ... @@ -137,18 +137,13 @@ static const char *
    137 137
     default_cmucllib(const char *argv0arg)
    
    138 138
     {
    
    139 139
         int total_len;
    
    140
    +    int path_len;
    
    140 141
         int cwd_len;
    
    141 142
         char **ptr;
    
    142
    -    char *defpath;
    
    143
    -    char *cwd;
    
    144
    -    char *newpath = malloc(PATH_MAX);
    
    145
    -
    
    146
    -    if (!newpath) {
    
    147
    -	perror("Failed to malloc space for newpath");
    
    148
    -	exit(1);
    
    149
    -    }
    
    143
    +    char *path;
    
    144
    +    char *slash;
    
    150 145
     
    
    151
    -    cwd = realpath(argv0arg, newpath);
    
    146
    +    cwd = realpath(argv0arg, NULL);
    
    152 147
     
    
    153 148
         if (debug_lisp_search) {
    
    154 149
     	fprintf(stderr, "Realpath of %s = %s\n", argv0arg, newpath);
    
    ... ... @@ -163,14 +158,11 @@ default_cmucllib(const char *argv0arg)
    163 158
          * Delete the binary name from the full path, leaving just the
    
    164 159
          * full directory to the executable.
    
    165 160
          */
    
    166
    -    cwd = strrchr(newpath, '/');
    
    167
    -    if (cwd) {
    
    168
    -	cwd[1] = '\0';
    
    161
    +    slash = strrchr(cwd, '/');
    
    162
    +    if (slash) {
    
    163
    +	slash[1] = '\0';
    
    169 164
         }
    
    170 165
     
    
    171
    -    /* cwd is the path directory of the executable */
    
    172
    -    cwd = newpath;
    
    173
    -
    
    174 166
         if (debug_lisp_search) {
    
    175 167
     	fprintf(stderr, "Executable path %s\n", cwd);
    
    176 168
         }
    
    ... ... @@ -231,7 +223,7 @@ default_cmucllib(const char *argv0arg)
    231 223
     	abort();
    
    232 224
         }
    
    233 225
     
    
    234
    -    free(newpath);
    
    226
    +    free(cwd);
    
    235 227
         return (const char *) defpath;
    
    236 228
     }
    
    237 229