]> Sergey Matveev's repositories - nnn.git/commitdiff
If you call makepath() with an absolute name it returns a copy of it
authorlostd <lostd@2f30.org>
Thu, 23 Oct 2014 14:53:26 +0000 (17:53 +0300)
committerlostd <lostd@2f30.org>
Thu, 23 Oct 2014 14:53:26 +0000 (17:53 +0300)
noice.c

diff --git a/noice.c b/noice.c
index c3d3728f0fcdaf34b5d3007ff24845fd23bb6c68..6b372fd2dfe9665742581d30ad2aedd1a95bd277 100644 (file)
--- 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;
 }