summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'path.c')
-rw-r--r--path.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/path.c b/path.c
index 79c5c104c3..6b7be5b869 100644
--- a/path.c
+++ b/path.c
@@ -484,18 +484,12 @@ int normalize_path_copy(char *dst, const char *src)
* dst0..dst is prefix portion, and dst[-1] is '/';
* go up one level.
*/
- dst -= 2; /* go past trailing '/' if any */
- if (dst < dst0)
+ dst--; /* go to trailing '/' */
+ if (dst <= dst0)
return -1;
- while (1) {
- if (dst <= dst0)
- break;
- c = *dst--;
- if (c == '/') { /* MinGW: cannot be '\\' anymore */
- dst += 2;
- break;
- }
- }
+ /* Windows: dst[-1] cannot be backslash anymore */
+ while (dst0 < dst && dst[-1] != '/')
+ dst--;
}
*dst = '\0';
return 0;