Subject: Re: CVS commit: pkgsrc/math/tasp-vsipl
To: Roland Illig <rillig@NetBSD.org>
From: Krister Walfridsson <cato@df.lth.se>
List: pkgsrc-changes
Date: 03/12/2006 14:35:59
On Wed, 8 Mar 2006, Roland Illig wrote:

> Krister Walfridsson wrote:
>> Module Name:	pkgsrc
>> Committed By:	kristerw
>> Date:		Fri Mar  3 19:19:35 UTC 2006
>> 
>> Modified Files:
>> 	pkgsrc/math/tasp-vsipl: distinfo
>> 	pkgsrc/math/tasp-vsipl/patches: patch-ae
>> 
>> Log Message:
>> Regen hand-edited patch so that the MacOS X patch program can apply it.
>
> Under which circumstances is hand-editing needed for patch files? I'd like to 
> have pkglint check that automatically.

Well, hand-edited may be the wrong word -- I guess it is more often due
to pkgdiff.  What I meant is patches that has been modified after diff(1).
In this particular case it was a removal of an Id tag.

The MacOS X diff (which is GNU diff 2.8.1) has two bugs/limitations:
1. It needs the hunks in the diff to look as actual diff output.

    Consider the patch:

     --- a   2006-03-12 14:20:04.000000000 +0100
     +++ b   2006-03-12 14:20:12.000000000 +0100
     @@ -4,7 +4,7 @@
      d
      e
      f
     -f
     +g
      h
      i
      j

    Suppose that the first line was something that need to be removed
    (i.e. an Id tag), then you cannot do something like

      --- a   2006-03-12 14:20:04.000000000 +0100
      +++ b   2006-03-12 14:20:12.000000000 +0100
      @@ -5,6 +5,6 @@
       e
       f
      -f
      +g
       h
       i
       j

    since the MacOS X will barf on this asymmetric hunk.  You need instead
    to generate it as it would look by "diff -2":

      --- a   2006-03-12 14:20:04.000000000 +0100
      +++ b   2006-03-12 14:20:12.000000000 +0100
      @@ -5,5 +5,5 @@
       e
       f
      -f
      +g
       h
       i

    The MacOS X does however correctly handle asymmetric hunks at end
    of file.

2. It gets confused by DOS-style line-endings in @@-lines (that may
    exist due to the -p flag to diff).

    Consider the patch:

      --- hmac.c.orig 2006-03-12 14:26:01.000000000 +0100
      +++ hmac.c      2006-03-12 14:26:34.000000000 +0100
      @@ -293,11 +293,6 @@ main (int argc, char *argv[])
           int i;
           unsigned char digest[HASH_LENGTH];

      -#ifdef UNIT_TEST
      -    if (argc == 1)
      -       exit(HMAC_KAT(stdout));
      -#endif
      -
           if (argc < 3) {
              fprintf(stderr, "Usage:\n\t%s key data\n", argv[0]);
              exit(1);

    If the source file used DOS-style line endings, then our diff(1)
    will use such line-ending on the line:

      @@ -293,11 +293,6 @@ main (int argc, char *argv[])

    and that need to be changed to a plain '\n' in order for the MacOS X
    patch(1) to accept the patch.

    /Krister