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

Commits:

1 changed file:

Changes:

  • src/lisp/lisp.c
    ... ... @@ -133,20 +133,20 @@ int debug_lisp_search = FALSE;
    133 133
      *
    
    134 134
      * The caller must free the returned string.
    
    135 135
      */
    
    136
    -static const char *
    
    136
    +static char *
    
    137 137
     default_cmucllib(const char *argv0arg)
    
    138 138
     {
    
    139
    -    int total_len;
    
    140
    -    int path_len;
    
    139
    +    char *cwd;
    
    141 140
         int cwd_len;
    
    142 141
         char **ptr;
    
    143 142
         char *path;
    
    143
    +    int path_len;
    
    144 144
         char *slash;
    
    145 145
     
    
    146 146
         cwd = realpath(argv0arg, NULL);
    
    147 147
     
    
    148 148
         if (debug_lisp_search) {
    
    149
    -	fprintf(stderr, "Realpath of %s = %s\n", argv0arg, newpath);
    
    149
    +	fprintf(stderr, "Realpath of %s = %s\n", argv0arg, cwd);
    
    150 150
         }
    
    151 151
     
    
    152 152
         if (!cwd) {
    
    ... ... @@ -175,7 +175,7 @@ default_cmucllib(const char *argv0arg)
    175 175
     
    
    176 176
         /* First figure out how much space we need */
    
    177 177
     
    
    178
    -    total_len = 0;
    
    178
    +    path_len = 0;
    
    179 179
         cwd_len = strlen(cwd);
    
    180 180
     
    
    181 181
         ptr = cmucllib_search_list;
    
    ... ... @@ -185,19 +185,19 @@ default_cmucllib(const char *argv0arg)
    185 185
     	 * Plus 2 for the ":" and "/" we need to add and the cwd that
    
    186 186
     	 * might be added.
    
    187 187
     	 */
    
    188
    -	total_len += strlen(*ptr) + cwd_len + 2;
    
    188
    +	path_len += strlen(*ptr) + cwd_len + 2;
    
    189 189
     	++ptr;
    
    190 190
         }
    
    191 191
     
    
    192 192
         /* Create the colon separated list of directories */
    
    193 193
     
    
    194
    -    defpath = malloc(total_len + 1);
    
    195
    -    if (!defpath) {
    
    194
    +    path = malloc(path_len + 1);
    
    195
    +    if (!path) {
    
    196 196
     	perror("Failed to malloc space for cmucllib");
    
    197 197
     	exit(1);
    
    198 198
         }
    
    199 199
         
    
    200
    -    *defpath = '\0';
    
    200
    +    *path = '\0';
    
    201 201
     
    
    202 202
         ptr = cmucllib_search_list;
    
    203 203
         while (*ptr != NULL) {
    
    ... ... @@ -206,25 +206,25 @@ default_cmucllib(const char *argv0arg)
    206 206
     	 * make the path absolute.
    
    207 207
     	 */
    
    208 208
     	if (*ptr[0] != '/') {
    
    209
    -	    strcat(defpath, cwd);
    
    209
    +	    strcat(path, cwd);
    
    210 210
     	}
    
    211 211
     
    
    212
    -	strcat(defpath, *ptr);
    
    212
    +	strcat(path, *ptr);
    
    213 213
     
    
    214 214
     	/* Add a colon if we're not at the last entry of the search list */
    
    215 215
     	if (ptr[1] != NULL) {
    
    216
    -	    strcat(defpath, ":");
    
    216
    +	    strcat(path, ":");
    
    217 217
     	}
    
    218 218
     
    
    219 219
     	++ptr;
    
    220 220
         }
    
    221 221
     
    
    222
    -    if (strlen(defpath) > total_len) {
    
    222
    +    if (strlen(path) > path_len) {
    
    223 223
     	abort();
    
    224 224
         }
    
    225 225
     
    
    226 226
         free(cwd);
    
    227
    -    return (const char *) defpath;
    
    227
    +    return path;
    
    228 228
     }
    
    229 229
     
    
    230 230
     /*