On Jun 17 23:30:44, marc.espie.open...@gmail.com wrote:
> On Sat, Jun 17, 2023 at 10:42:39AM +0200, Jan Stary wrote:
> > $ diffpp /tmp/foo                                             
> > Assigning non-zero to $[ is no longer possible at /usr/local/bin/diffpp 
> > line 72.
> > 
> > Apparently, the diffpp(1) of print/enscript
> > has been broken for years and nobody noticed.
> > Is anyone using that?
> > 
> >     Jan
> 
> Alternately, you could fix it.
> There are exactly 4 array dereferences that follow $[
> Mechanically substracting 1 in each location does the trick

Thanks for the patch.
While this fixes the syntax error,
diffpp still doesn't seem to work:

$ diffpp file.c < file.c.diff

just sits there (yes, it is the new one).
ktrace until I kill it ends with 


 60815 perl     GIO   fd 3 read 358 bytes
       "/* Structures can be passed as arguments
         * and returned from functions. Unions too. */
        
        #include <stdio.h>
        
        struct s {
                signed i;
                float f;
        };
        
        struct s
        f(struct s y)
        {
                struct s x;
                x.i = y.i + 1;
                x.f = y.f * 2;
                return x;
        }
        
        int
        main(int argc, char** argv)
        {
                struct s X, Y;
                Y.i = 1;
                Y.f = 3.1415;
                X = f(Y);
                printf("%d %f\\n", X.i, X.f);
                return 0;
        }
       "
 60815 perl     RET   read 358/0x166
 60815 perl     CALL  read(3,0x8e9d7eef000,0x2000)
 60815 perl     RET   read 0
 60815 perl     CALL  kbind(0x71ae6bce2098,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2188,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2158,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2158,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2118,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  close(3)
 60815 perl     RET   close 0
 60815 perl     CALL  read(0,0x8ea989ee000,0x2000)
 60815 perl     GIO   fd 0 read 331 bytes
       "--- struct.c.orig       Mon Jun 19 15:06:55 2023
        +++ struct.c    Mon Jun 19 15:07:20 2023
        @@ -4,7 +4,7 @@
         #include <stdio.h>
         
         struct s {
        -       int i;
        +       signed i;
                float f;
         };
         
        @@ -22,7 +22,7 @@ main(int argc, char** argv)
         {
                struct s X, Y;
                Y.i = 1;
        -       Y.f = 3.14;
        +       Y.f = 3.1415;
                X = f(Y);
                printf("%d %f\\n", X.i, X.f);
                return 0;
       "
 60815 perl     RET   read 331/0x14b
 60815 perl     CALL  read(0,0x8ea989ee000,0x2000)
 60815 perl     RET   read 0
 60815 perl     CALL  kbind(0x71ae6bce2168,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce20e8,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2168,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2148,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2148,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2198,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2168,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2178,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2178,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     CALL  kbind(0x71ae6bce2128,24,0x45177899858a9b3a)
 60815 perl     RET   kbind 0
 60815 perl     PSIG  SIGINT SIG_DFL

So it reads the named orig file, it reads the diff from stdin,
and then seems to do nothing.

        Jan


> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/print/enscript/Makefile,v
> retrieving revision 1.38
> diff -u -p -r1.38 Makefile
> --- Makefile  11 Mar 2022 19:50:59 -0000      1.38
> +++ Makefile  17 Jun 2023 21:30:21 -0000
> @@ -2,7 +2,7 @@ COMMENT=              convert ASCII files to PostScr
>  
>  DISTNAME=            enscript-1.6.6
>  CATEGORIES=          print
> -REVISION=            2
> +REVISION=            3
>  
>  HOMEPAGE=            https://www.gnu.org/software/enscript/
>  
> Index: patches/patch-scripts_diffpp_in
> ===================================================================
> RCS file: patches/patch-scripts_diffpp_in
> diff -N patches/patch-scripts_diffpp_in
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-scripts_diffpp_in   17 Jun 2023 21:30:21 -0000
> @@ -0,0 +1,47 @@
> +Index: scripts/diffpp.in
> +--- scripts/diffpp.in.orig
> ++++ scripts/diffpp.in
> +@@ -69,7 +69,6 @@ if ($file eq "--version") {
> + open(FP, $file) || die "$program: couldn't open file `$file' for input: 
> $!\n";
> + @orig_file = <FP>;
> + close(FP);
> +-$[ = 1;
> + $orig_line_num = 1;
> + $orig_num_lines = @orig_file;
> + 
> +@@ -79,7 +78,7 @@ $diff_line_num = 1;
> + $diff_num_lines = @diffs;
> + 
> + while ($diff_line_num <= $diff_num_lines) {
> +-    $_ = $diffs[$diff_line_num];
> ++    $_ = $diffs[$diff_line_num-1];
> +     if (/a/) {
> +     do_add($_);
> +     } elsif (/d/) {
> +@@ -90,7 +89,7 @@ while ($diff_line_num <= $diff_num_lines) {
> + }
> + 
> + while ($orig_line_num <= $orig_num_lines) {
> +-    print $orig_file[$orig_line_num++];
> ++    print $orig_file[$orig_line_num++-1];
> + }
> + 
> + # Handle new/added lines
> +@@ -175,7 +174,7 @@ sub skip_to_line {
> +     ($line) = @_;
> + 
> +     while ($orig_line_num <= $line) {
> +-    print $orig_file[$orig_line_num];
> ++    print $orig_file[$orig_line_num-1];
> +     $orig_line_num++;
> +     }
> + }
> +@@ -185,7 +184,7 @@ sub mark_to_line {
> + 
> +     $diff_line_num++;               # skip over diff command
> +     while ($num_lines > 0) {
> +-    $diff_line = substr($diffs[$diff_line_num++],3);
> ++    $diff_line = substr($diffs[$diff_line_num++-1],3);
> +     print "\000ps{gsave -5 0 rmoveto ($marker) show grestore}";
> +     print $diff_line;
> +     $num_lines--;
> 

Reply via email to