fix(cli-strutil): Increment basename pointer past /

This commit is contained in:
Rachel 2024-12-31 11:22:23 -08:00
parent a8359770b1
commit 8270f5b546
2 changed files with 5 additions and 1 deletions

View File

@ -207,7 +207,7 @@ static int pack(struct options *opts)
if (opts->naix) {
fnaix = fopen(naix, "w");
if (fnaix == NULL) {
FAIL("narc create: error while opening file “%s” for writing: %s\n", opts->output, strerror(errno));
FAIL("narc create: error while opening file “%s” for writing: %s\n", naix, strerror(errno));
}
fwrite(index->s, 1, index->len, fnaix);
fclose(fnaix);

View File

@ -46,6 +46,8 @@ char *basename_extend(const char *path, const char *ext)
char *p = strrchr(path, '/');
if (p == NULL) {
p = (char *)path;
} else {
p++;
}
char *buf = malloc(strlen(p) + strlen(ext) + 2);
@ -58,6 +60,8 @@ char *basename_stem_extend(const char *path, const char *ext)
char *p = strrchr(path, '/');
if (p == NULL) {
p = (char *)path;
} else {
p++;
}
char *s = strrchr(p, '.');