|
From: | Gennady Yakovlev |
Subject: | Bug in 'patch' version 2.5.4 |
Date: | Fri, 7 Sep 2001 21:35:57 +0400 |
When patching with -D <define> option,
there is a bug in some cases.
For example, the old file is ex1.c (all files are
attached) and the new file is ex2.c.
$ diff -wU 5 ex1.c ex2.c > ex.c.txt
(attached)
Then
$ cp ex1.c ex.c
$ patch -lu -D USE2 -i ex.c.txt ex.c
(attached)
You can see the first #ifdef, while it should be
#ifndef.
I changed beginning of apply_hunk() function
in patch.c as follows:
I changed marked below if_defined to
not_defined.
while (old <= lastline) {
if (pch_char(old) == '-') { assert (outstate->after_newline); if (! copy_till (outstate, where + old - 1)) return FALSE; if (R_do_defines) { if (def_state == OUTSIDE) { fprintf (fp, outstate->after_newline + *****if_defined*****, R_do_defines); def_state = IN_IFNDEF; } Additionally, i had to add starting newline (\n)
symbol to initialization of "not_defined" variable.
Otherwise, patch outputs 'ifndef USE2' (without #).
static char const not_defined[] = "#ifndef %s\n"; to
static char const not_defined[] = "\n#ifndef %s\n"; Now it works.
I use cygwin on Windows and gcc 2.95.3-5. I took the 2.5.4 version from
your web-archive.
With best regards,
Gennady Yakovlev, ________________________ Paragon Software Group |
ex1.c
Description: Binary data
ex2.c
Description: Binary data
ex.c.txt
Description: Text document
ex.c
Description: Binary data
[Prev in Thread] | Current Thread | [Next in Thread] |