From d73c956d902fcef15ba5f8cda9becd431f042a07 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 26 Feb 2012 21:52:07 -0600 Subject: Teach patch -p that consecutive /// counts as one path component. --- toys/patch.c | 10 +++++----- 1 file 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) { -- cgit v1.2.3