aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/files.c6
-rw-r--r--src/stdlib/stdlib.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/stdlib/files.c b/src/stdlib/files.c
index cf777689..4420bd12 100644
--- a/src/stdlib/files.c
+++ b/src/stdlib/files.c
@@ -70,7 +70,7 @@ public char *file_base_name(const char *path)
const char *slash = strrchr(path, '/');
if (slash) path = slash + 1;
assert(!isdigit(*path));
- const char *end = strchrnul(path, '.');
+ const char *end = path + strcspn(path, ".");
size_t len = (size_t)(end - path);
char *buf = GC_MALLOC_ATOMIC(len+1);
strncpy(buf, path, len);
@@ -83,7 +83,7 @@ public char *file_base_id(const char *path)
const char *slash = strrchr(path, '/');
if (slash) path = slash + 1;
assert(!isdigit(*path));
- const char *end = strchrnul(path, '.');
+ const char *end = path + strcspn(path, ".");
size_t len = (size_t)(end - path);
char *buf = GC_MALLOC_ATOMIC(len+1);
strncpy(buf, path, len);
@@ -307,7 +307,7 @@ public int highlight_error(file_t *file, const char *start, const char *end, con
printed += fprintf(stderr, "\n");
- const char *eol = strchrnul(line, '\n');
+ const char *eol = line + strcspn(line, "\r\n");
if (print_carets && start >= line && start < eol && line <= start) {
for (int num = 0; num < digits; num++)
printed += fputc(' ', stderr);
diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c
index 53eeb1dc..4a1f7dd8 100644
--- a/src/stdlib/stdlib.c
+++ b/src/stdlib/stdlib.c
@@ -479,7 +479,7 @@ public void print_stack_trace(FILE *out, int start, int stop)
char **strings = strings = backtrace_symbols(stack, size);
for (int64_t i = start; i < size - stop; i++) {
char *filename = strings[i];
- char *paren = strchrnul(strings[i], '(');
+ char *paren = strings[i] + strcspn(strings[i], "(");
char *addr_end = paren + 1 + strcspn(paren + 1, ")");
ptrdiff_t offset = strtol(paren + 1, &addr_end, 16) - 1;
const char *cmd = heap_strf("addr2line -e %.*s -is +0x%x", strcspn(filename, "("), filename, offset);