Просмотр исходного кода

* Ported [2691] to 1.2.9

svn: 2692
Bryan Drewery 20 лет назад
Родитель
Сommit
417a6d1450
1 измененных файлов с 5 добавлено и 5 удалено
  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);
 }