Raymond Toy pushed to branch issue-373-handle-temp-files at cmucl / cmucl Commits: 196dd6cf by Raymond Toy at 2025-11-13T08:08:42-08:00 Fixed typo and remove extra closing brace - - - - - f544c481 by Raymond Toy at 2025-11-13T08:09:02-08:00 Update these files to match Linux These OSes use the same method as used on Linux to get the temp directory so update them to match what Linux is doing now. - - - - - 5 changed files: - src/lisp/FreeBSD-os.c - src/lisp/Linux-os.c - src/lisp/NetBSD-os.c - src/lisp/OpenBSD-os.c - src/lisp/solaris-os.c Changes: ===================================== src/lisp/FreeBSD-os.c ===================================== @@ -365,9 +365,9 @@ os_support_sse2() /* * Return a new string containing the path to an OS-dependent location - * where temporary files/directories can be stored. If NULL is - * returned, such a location could not be found or some other error - * happened. + * where temporary files/directories can be stored. The string must + * end with a slash. If NULL is returned, such a location could not + * be found or some other error happened. * * Caller must call free() on the string returned. */ @@ -378,11 +378,21 @@ os_temporary_directory(void) * If the TMP envvar is set, use that as the temporary directory. * Otherwise, just assume "/tmp" will work. */ - char *tmp_path = getenv("TMP"); + char *tmp; + size_t len; + char *result; - if (tmp_path == NULL) { - tmp_path = "/tmp"; + tmp = getenv("TMP"); + if (tmp == NULL) { + return strdup("/tmp/"); } - - return strdup(tmp_path); + len = strlen(tmp); + if (tmp[len] == '/') { + return strdup(tmp); + } + result = malloc(len + 2); + if (result) { + sprintf(result, "%s/", tmp); + } + return result; } ===================================== src/lisp/Linux-os.c ===================================== @@ -631,9 +631,9 @@ os_support_sse2(void) /* * Return a new string containing the path to an OS-dependent location - * where temporary files/directories can be stored. If NULL is - * returned, such a location could not be found or some other error - * happened. + * where temporary files/directories can be stored. The string must + * end with a slash. If NULL is returned, such a location could not + * be found or some other error happened. * * Caller must call free() on the string returned. */ @@ -662,4 +662,3 @@ os_temporary_directory(void) } return result; } -} ===================================== src/lisp/NetBSD-os.c ===================================== @@ -430,9 +430,9 @@ os_support_sse2() /* * Return a new string containing the path to an OS-dependent location - * where temporary files/directories can be stored. If NULL is - * returned, such a location could not be found or some other error - * happened. + * where temporary files/directories can be stored. The string must + * end with a slash. If NULL is returned, such a location could not + * be found or some other error happened. * * Caller must call free() on the string returned. */ @@ -443,11 +443,21 @@ os_temporary_directory(void) * If the TMP envvar is set, use that as the temporary directory. * Otherwise, just assume "/tmp" will work. */ - char *tmp_path = getenv("TMP"); + char *tmp; + size_t len; + char *result; - if (tmp_path == NULL) { - tmp_path = "/tmp"; + tmp = getenv("TMP"); + if (tmp == NULL) { + return strdup("/tmp/"); } - - return strdup(tmp_path); + len = strlen(tmp); + if (tmp[len] == '/') { + return strdup(tmp); + } + result = malloc(len + 2); + if (result) { + sprintf(result, "%s/", tmp); + } + return result; } ===================================== src/lisp/OpenBSD-os.c ===================================== @@ -193,9 +193,9 @@ os_install_interrupt_handlers(void) /* * Return a new string containing the path to an OS-dependent location - * where temporary files/directories can be stored. If NULL is - * returned, such a location could not be found or some other error - * happened. + * where temporary files/directories can be stored. The string must + * end with a slash. If NULL is returned, such a location could not + * be found or some other error happened. * * Caller must call free() on the string returned. */ @@ -206,11 +206,21 @@ os_temporary_directory(void) * If the TMP envvar is set, use that as the temporary directory. * Otherwise, just assume "/tmp" will work. */ - char *tmp_path = getenv("TMP"); + char *tmp; + size_t len; + char *result; - if (tmp_path == NULL) { - tmp_path = "/tmp"; + tmp = getenv("TMP"); + if (tmp == NULL) { + return strdup("/tmp/"); } - - return strdup(tmp_path); + len = strlen(tmp); + if (tmp[len] == '/') { + return strdup(tmp); + } + result = malloc(len + 2); + if (result) { + sprintf(result, "%s/", tmp); + } + return result; } ===================================== src/lisp/solaris-os.c ===================================== @@ -646,9 +646,9 @@ os_support_sse2() /* * Return a new string containing the path to an OS-dependent location - * where temporary files/directories can be stored. If NULL is - * returned, such a location could not be found or some other error - * happened. + * where temporary files/directories can be stored. The string must + * end with a slash. If NULL is returned, such a location could not + * be found or some other error happened. * * Caller must call free() on the string returned. */ @@ -659,11 +659,21 @@ os_temporary_directory(void) * If the TMP envvar is set, use that as the temporary directory. * Otherwise, just assume "/tmp" will work. */ - char *tmp_path = getenv("TMP"); + char *tmp; + size_t len; + char *result; - if (tmp_path == NULL) { - tmp_path = "/tmp"; + tmp = getenv("TMP"); + if (tmp == NULL) { + return strdup("/tmp/"); } - - return strdup(tmp_path); + len = strlen(tmp); + if (tmp[len] == '/') { + return strdup(tmp); + } + result = malloc(len + 2); + if (result) { + sprintf(result, "%s/", tmp); + } + return result; } View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/19dec394ac637e3090500a6... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/19dec394ac637e3090500a6... You're receiving this email because of your account on gitlab.common-lisp.net.