Parcourir la source

* Ported [2691] to 1.2.9

svn: 2692
Bryan Drewery il y a 20 ans
Parent
commit
417a6d1450
1 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 5 5
      src/shell.c

+ 5 - 5
src/shell.c

@@ -845,10 +845,11 @@ void mkdir_p(const char *dir) {
   char *p = NULL, *path = NULL;
 
   path = p = strdup(dir);
-  p = strchr(p + 1, '/');
 
-  while (p) {
-    *p = '\0';
+  do {
+    p = strchr(p + 1, '/');
+    if (p)
+      *p = '\0';
     if (can_stat(path) && !is_dir(path))
       unlink(path);
     if (!can_stat(path)) {
@@ -859,8 +860,7 @@ void mkdir_p(const char *dir) {
     }
     if (p)
       *p = '/';
-    p = strchr(p + 1, '/');
-  }
+  } while(p);
   free(path);
 }