If you call makepath() with an absolute name it returns a copy of it

This commit is contained in:
lostd 2014-10-23 17:53:26 +03:00
parent 9407399230
commit 4b1b156a3b
1 changed files with 10 additions and 5 deletions

15
noice.c
View File

@ -490,11 +490,16 @@ makepath(char *dir, char *name)
{
char *path;
/* Handle root case */
if (strcmp(dir, "/") == 0)
asprintf(&path, "/%s", name);
else
asprintf(&path, "%s/%s", dir, name);
/* Handle absolute path */
if (name[0] == '/') {
path = xstrdup(name);
} else {
/* Handle root case */
if (strcmp(dir, "/") == 0)
asprintf(&path, "/%s", name);
else
asprintf(&path, "%s/%s", dir, name);
}
return path;
}