quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] gawk 3.0.6 doesn't support asort


From: Jean Delvare
Subject: [Quilt-dev] gawk 3.0.6 doesn't support asort
Date: Mon, 5 Sep 2005 23:00:51 +0200

Hi John,

I have been taking a look at your compat-gawk-3.0.6 patch today, after I
hit the problem of asort not being supported on an old Linux system (Red
Hat 8.)

http://zeroj.hda0.net/quilt-patches/compat-gawk-3.0.6.diff

I do not like the replacement code you proposed. Not only do I think
that invoking perl from quilt is a bad idea conceptually, but I also
don't like your perl code, which is not linear and as such brings a
significant slowdown on patches with a great number of files. Almost
each time you use "grep" in perl, you know you are doing something
wrong.

I have written a different replacement which continues to use awk
instead. I plan to commit it if nobody objects. It is appended to this
post, comments and testers welcome. Basically the idea is to sort the
list beforehand (using the sort Unix command), pass a sorted list to awk
and get the awk script to simply preserve this input order.

Also, your extension of the sort test looks interesting, so I plan to
commit it at the same time.

Thanks.

Index: scripts/patchfns.in
===================================================================
RCS file: /cvsroot/quilt/quilt/scripts/patchfns.in,v
retrieving revision 1.68
diff -u -r1.68 patchfns.in
--- scripts/patchfns.in 2 Sep 2005 17:32:17 -0000       1.68
+++ scripts/patchfns.in 5 Sep 2005 20:59:17 -0000
@@ -492,28 +492,22 @@
 {
        local patch=$1
 
-       (   files_in_patch $patch
+       (   files_in_patch $patch | sort
            echo "-"
            filenames_in_patch $patch
        ) | @AWK@ '
        $1 == "-" { out=1 ; next }
-       !out    { files[$0]=1 }
+       !out    { files[$0]=1
+                 new_files[++n]=$0 }
        out     { if ($0 in files && !($0 in printed)) {
                    print $0
                    printed[$0]=1
                  }
                }
        END     {
-                 i = 1
-                 for (file in files) {
-                   if (!(file in printed)) {
-                     new_files[i]=file
-                     i++
-                   }
-                 }
-                 n = asort(new_files)
                  for (i=1; i<=n; i++)
-                   print new_files[i]
+                   if (!(new_files[i] in printed))
+                     print new_files[i]
                }
        '
 }


-- 
Jean Delvare




reply via email to

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