From: "Paul Eggert" Date: Wed, 2 Jul 2003 15:22:09 -0700 Subject: Re: patch bug with carriage returns > From: Andreas Gruenbacher > Date: Mon, 30 Jun 2003 13:43:33 +0200 > unified diffs with CRLF line endings are not recognized correctly > anymore in 2.5.9. Here is a fix. Thanks for the bug report. Unfortunately that fix doesn't handle the case correctly where a Unix file contains a trailing CR in a header line that is output by "diff -p" (trailing CR and all). How about the following patch instead? --- patch-2.5.9.orig/pch.c 2003/05/20 14:03:17 1.44 +++ patch-2.5.9/pch.c 2003/07/02 22:19:21 1.45 @@ -1,6 +1,6 @@ /* reading patches */ -/* $Id: pch.c,v 1.44 2003/05/20 14:03:17 eggert Exp $ */ +/* $Id: pch.c,v 1.45 2003/07/02 22:19:21 eggert Exp $ */ /* Copyright (C) 1986, 1987, 1988 Larry Wall @@ -366,10 +366,16 @@ intuit_diff_type (void) if (!stars_last_line && strnEQ(s, "*** ", 4)) name[OLD] = fetchname (s+4, strippath, &p_timestamp[OLD]); else if (strnEQ(s, "+++ ", 4)) + { /* Swap with NEW below. */ name[OLD] = fetchname (s+4, strippath, &p_timestamp[OLD]); + p_strip_trailing_cr = strip_trailing_cr; + } else if (strnEQ(s, "Index:", 6)) + { name[INDEX] = fetchname (s+6, strippath, (time_t *) 0); + p_strip_trailing_cr = strip_trailing_cr; + } else if (strnEQ(s, "Prereq:", 7)) { for (t = s + 7; ISSPACE ((unsigned char) *t); t++) continue; @@ -409,6 +415,7 @@ intuit_diff_type (void) p_timestamp[NEW] = timestamp; p_rfc934_nesting = (t - s) >> 1; } + p_strip_trailing_cr = strip_trailing_cr; } } if ((diff_type == NO_DIFF || diff_type == ED_DIFF) && #--- patch-2.5.9.orig/pch.c 2003-06-30 13:28:39.000000000 +0200 #+++ patch-2.5.9/pch.c 2003-06-30 13:28:03.000000000 +0200 #@@ -440,6 +440,7 @@ # if (s[0] == '+' && s[1] == '0' && !ISDIGIT (s[2])) # p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW]; # p_indent = indent; #+ p_strip_trailing_cr = strip_trailing_cr; # p_start = this_line; # p_sline = p_input_line; # retval = UNI_DIFF;