diff options
-rw-r--r-- | build.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 : "."; } |