bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make patch behave more gracefully on patch lines with single space


From: J. Scott Berg
Subject: Make patch behave more gracefully on patch lines with single space
Date: Mon, 27 Nov 2006 18:19:43 -0500
User-agent: Mail/News 1.5.0.7 (X11/20061030)

I downloaded some patches that got munged so that lines that should have consisted solely of two spaces instead had a single space. The resulting patch fails to apply and produces a funky .rej file in the process. Two text files and a patch to convert one to the other, with the double space turned into a single one, are attached. Using -l doesn't help.

I'm attaching my fix for this: looks like an error in the original handling of this, but I'm also removing the requirement that canonicalize be true, since we're not talking about a difference in the amount of space in the code being patched, but in the metadata in the patch itself. buf seems to be preallocated to a large chunk of memory, so there should be no overrun issues here.
Line 1

Line 2

Line 3

Line 4

Line 5

Line 6
Line 1

Line 2

Line 3

Line 3a
Line 3b
Line 3c
Line 4

Line 5

Line 6
*** test0.txt   2006-11-27 17:49:11.000000000 -0500
--- test1.txt   2006-11-27 17:49:39.000000000 -0500
***************
*** 4,9 ****
--- 4,12 ----
  
  Line 3
 
+ Line 3a
+ Line 3b
+ Line 3c
  Line 4
  
  Line 5
--- pch.c.orig  2006-11-27 12:21:03.000000000 -0500
+++ pch.c       2006-11-27 18:00:45.000000000 -0500
@@ -1115,8 +1115,8 @@
            case ' ':
                s = buf + 1;
                chars_read--;
-               if (*s == '\n' && canonicalize) {
-                   strcpy (s, "\n");
+               if (*s == '\n') {
+                   strcpy (s, " \n");
                    chars_read = 2;
                }
                if (*s == ' ' || *s == '\t') {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]