diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-27 20:44:23 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-27 20:44:23 -0400 |
| commit | 7b55f180e2080d1fe628049cda2e0e9ffcaa8532 (patch) | |
| tree | b7f9f12d23fd7939ba6e195d53e1f4f44f16b374 /src/stdlib/files.c | |
| parent | 1147241f1890835ec66f02a505059d6fd17f6755 (diff) | |
Phase out strchrnul
Diffstat (limited to 'src/stdlib/files.c')
| -rw-r--r-- | src/stdlib/files.c | 6 |
1 files changed, 3 insertions, 3 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); |
