diff options
| -rw-r--r-- | stdlib/paths.c | 8 | ||||
| -rw-r--r-- | stdlib/stdlib.c | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/stdlib/paths.c b/stdlib/paths.c index 8acc34ff..e8a1e1f6 100644 --- a/stdlib/paths.c +++ b/stdlib/paths.c @@ -439,9 +439,11 @@ public Text_t Path$write_unique_bytes(Path_t path, Array_t bytes) char buf[PATH_MAX] = {}; strcpy(buf, path_str); - int64_t suffixlen = 0; - (void)Text$find(path, Pattern("{0+!X}{end}"), I(1), &suffixlen); - if (suffixlen < 0) suffixlen = 0; + // Count the number of trailing characters leading up to the last "X" + // (e.g. "foo_XXXXXX.tmp" would yield suffixlen = 4) + size_t suffixlen = 0; + while (suffixlen < len && buf[len - 1 - suffixlen] != 'X') + ++suffixlen; int fd = mkstemps(buf, suffixlen); if (fd == -1) diff --git a/stdlib/stdlib.c b/stdlib/stdlib.c index 34acc828..d90f5748 100644 --- a/stdlib/stdlib.c +++ b/stdlib/stdlib.c @@ -441,7 +441,7 @@ public void end_test(const void *expr, const TypeInfo_t *type, const char *expec Text_t expr_plain = USE_COLOR ? generic_as_text(expr, false, type) : expr_text; bool success = Text$equal(&expr_plain, &expected_text); if (!success) { - Int_t colon = Text$find(expected_text, Text(":"), I_small(1), NULL); + Int_t colon = Text$find(expected_text, Text(":"), I_small(1)); if (colon.small != I_small(0).small) { Text_t with_type = Text$concat(expr_plain, Text(" : "), type_name); success = Text$equal(&with_type, &expected_text); |
