Skip to content

Commit bc95ba0

Browse files
authored
clib init can't always determine the current directory name (#240)
* clib init can't always determine the current directory name * clib init can't always determine the current directory name
1 parent 151a61b commit bc95ba0

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/clib-init.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,8 @@ static void setopt_manifest_file(command_t *self) {
5454
static char *find_basepath() {
5555
char cwd[4096] = {0};
5656
getcwd(cwd, 4096);
57-
char *walk = cwd + strlen(cwd);
58-
while (*(--walk) != '/')
59-
;
60-
char *basepath = malloc((size_t)(walk - cwd));
61-
strncpy(basepath, walk + 1, (size_t)(walk - cwd));
62-
return basepath;
57+
58+
return strdup(strrchr(cwd, '/') + 1);
6359
}
6460

6561
static void getinput(char *buffer, size_t s) {

0 commit comments

Comments
 (0)