aboutsummaryrefslogtreecommitdiff
path: root/bb.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-06-08 20:54:25 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-06-08 20:54:25 -0700
commitf2151f7835df7f7e33c0ce566edcf7b62324ceb2 (patch)
tree46b0425bb0b1186176f8ecb11f623a591dc4976f /bb.c
parent5d660e2378fc0bd6b16e50d9f2371724fb7918c4 (diff)
parent257f8ee0d0a4eeba24e638c74a2ce475c518f3f6 (diff)
Merge branch 'master' of bitbucket.org:spilt/bb
Diffstat (limited to 'bb.c')
-rw-r--r--bb.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/bb.c b/bb.c
index a9059a9..5a38693 100644
--- a/bb.c
+++ b/bb.c
@@ -744,7 +744,7 @@ entry_t* load_entry(bb_t *bb, const char *path)
strcpy(pbuf, bb->path);
strcat(pbuf, path);
}
- if (pbuf[strlen(pbuf)-1] == '/')
+ if (pbuf[strlen(pbuf)-1] == '/' && pbuf[1])
pbuf[strlen(pbuf)-1] = '\0';
// Check for pre-existing:
@@ -768,9 +768,13 @@ entry_t* load_entry(bb_t *bb, const char *path)
char *end = stpcpy(entry->fullname, pbuf);
if (linkpathlen >= 0)
entry->linkname = strcpy(end + 1, linkbuf);
- entry->name = strrchr(entry->fullname, '/');
- if (!entry->name) err("No slash found in '%s'", entry->fullname);
- ++entry->name;
+ if (strcmp(entry->fullname, "/") == 0) {
+ entry->name = entry->fullname;
+ } else {
+ entry->name = strrchr(entry->fullname, '/');
+ if (!entry->name) err("No slash found in '%s' from '%s'", entry->fullname, path);
+ ++entry->name;
+ }
if (S_ISLNK(filestat.st_mode))
entry->linkedmode = linkedstat.st_mode;
entry->info = filestat;