Raymond Toy pushed to branch issue-437-find-self at cmucl / cmucl Commits: 1fa4a75e by Raymond Toy at 2025-11-06T05:21:08-08:00 Apply 5 suggestion(s) to 1 file(s) Co-authored-by: Carl Shapiro <cshapiro@panix.com> - - - - - 1 changed file: - src/lisp/lisp.c Changes: ===================================== src/lisp/lisp.c ===================================== @@ -137,18 +137,13 @@ static const char * default_cmucllib(const char *argv0arg) { int total_len; + int path_len; int cwd_len; char **ptr; - char *defpath; - char *cwd; - char *newpath = malloc(PATH_MAX); - - if (!newpath) { - perror("Failed to malloc space for newpath"); - exit(1); - } + char *path; + char *slash; - cwd = realpath(argv0arg, newpath); + cwd = realpath(argv0arg, NULL); if (debug_lisp_search) { fprintf(stderr, "Realpath of %s = %s\n", argv0arg, newpath); @@ -163,14 +158,11 @@ default_cmucllib(const char *argv0arg) * Delete the binary name from the full path, leaving just the * full directory to the executable. */ - cwd = strrchr(newpath, '/'); - if (cwd) { - cwd[1] = '\0'; + slash = strrchr(cwd, '/'); + if (slash) { + slash[1] = '\0'; } - /* cwd is the path directory of the executable */ - cwd = newpath; - if (debug_lisp_search) { fprintf(stderr, "Executable path %s\n", cwd); } @@ -231,7 +223,7 @@ default_cmucllib(const char *argv0arg) abort(); } - free(newpath); + free(cwd); return (const char *) defpath; } View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/1fa4a75e585f4a6250c2ee5b... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/1fa4a75e585f4a6250c2ee5b... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)