Skip to content

Commit 2ac3e85

Browse files
committed
Fix make_normalpath() with trailing backslash
There was an ambiguous code there: - if the path had trailing backslash and existed => return "<path>\" - if the path didn't have trailing backslash and existed => return "<path>\" - if the path had trailing backslash and didn't exist => return "<path>\" - if the path didn't have trailing backslash and didn't exist => return "<path>" This can have two interpretations: - if the path doesn't exist, don't change its trailing backslash presence, otherwise always return with trailing backslash - no matter what, always return path with trailing backslash and the code is buggy I'm choosing the second one as it adds consistency and simplifies caller code. QED's (which is from the same author as CF-Lib) usage of this function seems to support this intent.
1 parent af02175 commit 2ac3e85

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fsnorm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ int make_normalpath(char *path)
9090
}
9191

9292
ret = path_exists(p);
93-
if (!ret)
94-
p[i] = '\0';
9593

94+
/* always return path with trailing backslash */
9695
strcpy(path, p);
9796
return ret;
9897
}

0 commit comments

Comments
 (0)