On 07/20/2011 03:39 PM, John Spencer wrote:
> the attached patch fails to generate the proper pathname with -p1
> 
> with -p1 it translates libssh-0.5.0//include/libssh/libssh.h to
> //include/libssh/libssh.h
> and
> libssh-0.5.0/include/libssh/libssh.h to /include/libssh/libssh.h
> 
> both should obviously translate to include/libssh/libssh.h without
> leading slashes.
> 
> used busybox was 1.18.4
> used libssh was 0.5.0
> 
> thanks

The attached patch should fix it. :)

Rob
Make -p count "path components" not slashes, so broken /blah//thing paths work.

diff --git a/editors/patch.c b/editors/patch.c
index 1f2a49b..b1f51cf 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -482,11 +482,11 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
 
 				// handle -p path truncation.
 				for (i=0, s = name; *s;) {
+					char *temp = name;
+
 					if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i) break;
-					if (*(s++)=='/') {
-						name = s;
-						i++;
-					}
+					while (*(s++)=='/') name = s;
+					if (temp != name) i++;
 				}
 
 				if (empty) {
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to