diff options
| author | 2014-10-23 17:53:26 +0300 | |
|---|---|---|
| committer | 2014-10-23 17:53:26 +0300 | |
| commit | 4b1b156a3b477f242f9cb0984558010c887a5c8a (patch) | |
| tree | b961159376c6c9d96edcfea3124c8038b076d6e5 | |
| parent | 9407399230577243ee81a28af8d2c2744eb14ea7 (diff) | |
| download | nnn-4b1b156a3b477f242f9cb0984558010c887a5c8a.tar.gz | |
If you call makepath() with an absolute name it returns a copy of it
| -rw-r--r-- | noice.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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; } |