aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/patch.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/toys/patch.c b/toys/patch.c
index 851f4eb6..38c71941 100644
--- a/toys/patch.c
+++ b/toys/patch.c
@@ -354,12 +354,12 @@ void patch_main(void)
}
// handle -p path truncation.
- for (i=0, s = name; *s;) {
+ for (i = 0, s = name; *s;) {
if ((toys.optflags & FLAG_PATHLEN) && TT.prefix == i) break;
- if (*(s++)=='/') {
- name = s;
- i++;
- }
+ if (*s++ != '/') continue;
+ while (*s == '/') s++;
+ name = s;
+ i++;
}
if (del) {