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
-
f544c481
by Raymond Toy at 2025-11-13T08:09:02-08:00
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:
| ... | ... | @@ -365,9 +365,9 @@ os_support_sse2() |
| 365 | 365 | |
| 366 | 366 | /*
|
| 367 | 367 | * Return a new string containing the path to an OS-dependent location
|
| 368 | - * where temporary files/directories can be stored. If NULL is
|
|
| 369 | - * returned, such a location could not be found or some other error
|
|
| 370 | - * happened.
|
|
| 368 | + * where temporary files/directories can be stored. The string must
|
|
| 369 | + * end with a slash. If NULL is returned, such a location could not
|
|
| 370 | + * be found or some other error happened.
|
|
| 371 | 371 | *
|
| 372 | 372 | * Caller must call free() on the string returned.
|
| 373 | 373 | */
|
| ... | ... | @@ -378,11 +378,21 @@ os_temporary_directory(void) |
| 378 | 378 | * If the TMP envvar is set, use that as the temporary directory.
|
| 379 | 379 | * Otherwise, just assume "/tmp" will work.
|
| 380 | 380 | */
|
| 381 | - char *tmp_path = getenv("TMP");
|
|
| 381 | + char *tmp;
|
|
| 382 | + size_t len;
|
|
| 383 | + char *result;
|
|
| 382 | 384 | |
| 383 | - if (tmp_path == NULL) {
|
|
| 384 | - tmp_path = "/tmp";
|
|
| 385 | + tmp = getenv("TMP");
|
|
| 386 | + if (tmp == NULL) {
|
|
| 387 | + return strdup("/tmp/");
|
|
| 385 | 388 | }
|
| 386 | - |
|
| 387 | - return strdup(tmp_path);
|
|
| 389 | + len = strlen(tmp);
|
|
| 390 | + if (tmp[len] == '/') {
|
|
| 391 | + return strdup(tmp);
|
|
| 392 | + }
|
|
| 393 | + result = malloc(len + 2);
|
|
| 394 | + if (result) {
|
|
| 395 | + sprintf(result, "%s/", tmp);
|
|
| 396 | + }
|
|
| 397 | + return result;
|
|
| 388 | 398 | } |
| ... | ... | @@ -631,9 +631,9 @@ os_support_sse2(void) |
| 631 | 631 | |
| 632 | 632 | /*
|
| 633 | 633 | * Return a new string containing the path to an OS-dependent location
|
| 634 | - * where temporary files/directories can be stored. If NULL is
|
|
| 635 | - * returned, such a location could not be found or some other error
|
|
| 636 | - * happened.
|
|
| 634 | + * where temporary files/directories can be stored. The string must
|
|
| 635 | + * end with a slash. If NULL is returned, such a location could not
|
|
| 636 | + * be found or some other error happened.
|
|
| 637 | 637 | *
|
| 638 | 638 | * Caller must call free() on the string returned.
|
| 639 | 639 | */
|
| ... | ... | @@ -662,4 +662,3 @@ os_temporary_directory(void) |
| 662 | 662 | }
|
| 663 | 663 | return result;
|
| 664 | 664 | } |
| 665 | -} |
| ... | ... | @@ -430,9 +430,9 @@ os_support_sse2() |
| 430 | 430 | |
| 431 | 431 | /*
|
| 432 | 432 | * Return a new string containing the path to an OS-dependent location
|
| 433 | - * where temporary files/directories can be stored. If NULL is
|
|
| 434 | - * returned, such a location could not be found or some other error
|
|
| 435 | - * happened.
|
|
| 433 | + * where temporary files/directories can be stored. The string must
|
|
| 434 | + * end with a slash. If NULL is returned, such a location could not
|
|
| 435 | + * be found or some other error happened.
|
|
| 436 | 436 | *
|
| 437 | 437 | * Caller must call free() on the string returned.
|
| 438 | 438 | */
|
| ... | ... | @@ -443,11 +443,21 @@ os_temporary_directory(void) |
| 443 | 443 | * If the TMP envvar is set, use that as the temporary directory.
|
| 444 | 444 | * Otherwise, just assume "/tmp" will work.
|
| 445 | 445 | */
|
| 446 | - char *tmp_path = getenv("TMP");
|
|
| 446 | + char *tmp;
|
|
| 447 | + size_t len;
|
|
| 448 | + char *result;
|
|
| 447 | 449 | |
| 448 | - if (tmp_path == NULL) {
|
|
| 449 | - tmp_path = "/tmp";
|
|
| 450 | + tmp = getenv("TMP");
|
|
| 451 | + if (tmp == NULL) {
|
|
| 452 | + return strdup("/tmp/");
|
|
| 450 | 453 | }
|
| 451 | - |
|
| 452 | - return strdup(tmp_path);
|
|
| 454 | + len = strlen(tmp);
|
|
| 455 | + if (tmp[len] == '/') {
|
|
| 456 | + return strdup(tmp);
|
|
| 457 | + }
|
|
| 458 | + result = malloc(len + 2);
|
|
| 459 | + if (result) {
|
|
| 460 | + sprintf(result, "%s/", tmp);
|
|
| 461 | + }
|
|
| 462 | + return result;
|
|
| 453 | 463 | } |
| ... | ... | @@ -193,9 +193,9 @@ os_install_interrupt_handlers(void) |
| 193 | 193 | |
| 194 | 194 | /*
|
| 195 | 195 | * Return a new string containing the path to an OS-dependent location
|
| 196 | - * where temporary files/directories can be stored. If NULL is
|
|
| 197 | - * returned, such a location could not be found or some other error
|
|
| 198 | - * happened.
|
|
| 196 | + * where temporary files/directories can be stored. The string must
|
|
| 197 | + * end with a slash. If NULL is returned, such a location could not
|
|
| 198 | + * be found or some other error happened.
|
|
| 199 | 199 | *
|
| 200 | 200 | * Caller must call free() on the string returned.
|
| 201 | 201 | */
|
| ... | ... | @@ -206,11 +206,21 @@ os_temporary_directory(void) |
| 206 | 206 | * If the TMP envvar is set, use that as the temporary directory.
|
| 207 | 207 | * Otherwise, just assume "/tmp" will work.
|
| 208 | 208 | */
|
| 209 | - char *tmp_path = getenv("TMP");
|
|
| 209 | + char *tmp;
|
|
| 210 | + size_t len;
|
|
| 211 | + char *result;
|
|
| 210 | 212 | |
| 211 | - if (tmp_path == NULL) {
|
|
| 212 | - tmp_path = "/tmp";
|
|
| 213 | + tmp = getenv("TMP");
|
|
| 214 | + if (tmp == NULL) {
|
|
| 215 | + return strdup("/tmp/");
|
|
| 213 | 216 | }
|
| 214 | - |
|
| 215 | - return strdup(tmp_path);
|
|
| 217 | + len = strlen(tmp);
|
|
| 218 | + if (tmp[len] == '/') {
|
|
| 219 | + return strdup(tmp);
|
|
| 220 | + }
|
|
| 221 | + result = malloc(len + 2);
|
|
| 222 | + if (result) {
|
|
| 223 | + sprintf(result, "%s/", tmp);
|
|
| 224 | + }
|
|
| 225 | + return result;
|
|
| 216 | 226 | } |
| ... | ... | @@ -646,9 +646,9 @@ os_support_sse2() |
| 646 | 646 | |
| 647 | 647 | /*
|
| 648 | 648 | * Return a new string containing the path to an OS-dependent location
|
| 649 | - * where temporary files/directories can be stored. If NULL is
|
|
| 650 | - * returned, such a location could not be found or some other error
|
|
| 651 | - * happened.
|
|
| 649 | + * where temporary files/directories can be stored. The string must
|
|
| 650 | + * end with a slash. If NULL is returned, such a location could not
|
|
| 651 | + * be found or some other error happened.
|
|
| 652 | 652 | *
|
| 653 | 653 | * Caller must call free() on the string returned.
|
| 654 | 654 | */
|
| ... | ... | @@ -659,11 +659,21 @@ os_temporary_directory(void) |
| 659 | 659 | * If the TMP envvar is set, use that as the temporary directory.
|
| 660 | 660 | * Otherwise, just assume "/tmp" will work.
|
| 661 | 661 | */
|
| 662 | - char *tmp_path = getenv("TMP");
|
|
| 662 | + char *tmp;
|
|
| 663 | + size_t len;
|
|
| 664 | + char *result;
|
|
| 663 | 665 | |
| 664 | - if (tmp_path == NULL) {
|
|
| 665 | - tmp_path = "/tmp";
|
|
| 666 | + tmp = getenv("TMP");
|
|
| 667 | + if (tmp == NULL) {
|
|
| 668 | + return strdup("/tmp/");
|
|
| 666 | 669 | }
|
| 667 | - |
|
| 668 | - return strdup(tmp_path);
|
|
| 670 | + len = strlen(tmp);
|
|
| 671 | + if (tmp[len] == '/') {
|
|
| 672 | + return strdup(tmp);
|
|
| 673 | + }
|
|
| 674 | + result = malloc(len + 2);
|
|
| 675 | + if (result) {
|
|
| 676 | + sprintf(result, "%s/", tmp);
|
|
| 677 | + }
|
|
| 678 | + return result;
|
|
| 669 | 679 | } |