aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/build.c b/build.c
index 621daa7..16b53e2 100644
--- a/build.c
+++ b/build.c
@@ -272,11 +272,14 @@ dirname(char *file)
if(!(dir = malloc(strlen(file)+1)))
err(1, "malloc");
+ dir[0] = 0;
for(i = strlen(file); i >= 0; i--)
- if(file[i] == '/') break;
- for(dir[i--] = 0; i >= 0; i--)
- dir[i] = file[i];
+ if(file[i] == '/'){
+ for(dir[i--] = 0; i >= 0; i--)
+ dir[i] = file[i];
+ break;
+ }
return dir[0] ? dir : ".";
}