noice

small file browser
git clone git://git.2f30.org/noice.git
Log | Files | Refs | README | LICENSE

commit 4b1b156a3b477f242f9cb0984558010c887a5c8a
parent 9407399230577243ee81a28af8d2c2744eb14ea7
Author: lostd <lostd@2f30.org>
Date:   Thu Oct 23 17:53:26 +0300

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

Diffstat:
noice.c | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/noice.c b/noice.c @@ -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; }