Hi Andreas, John,

[John Vandenberg]
> > The attached patch fixes the problem.
> 
> > Sun awk does not like ~ syntax.  Also, the commands
> > need to be reordered otherwise /^$/ causes it to
> > bail out too early.

[Andreas Grünbacher]
> I don't understand the reorder issue, and neither the $ in /^[a-z]+:[ $\t]/.

Neither do I.

While checking the original code and John's replacement proposal, I
found that the original code doesn't seem to work for me:

        /^$/    { exit (!mh || not_mh) }
        END     { exit (!mh || not_mh) }
        { if ($0 ~ /^[a-z]+:[ \t]/i)
            mh = 1
          else
            not_mh = 1
        }

The "i" modifier after the regular expression doesn't work as expected,
and seems to confuse gawk (3.1.5). In fact there is no way I could get
the code snippet above to exit with success (0). Replacing
/^[a-z]+:[ \t]/i with /^[A-Za-z]+:[ \t]/ made it work somewhat. But
even then I'm not sure it does what we want it to do. Isn't a line like:
Reply-To: [EMAIL PROTECTED]
supposed to match the regular expression? It doesn't at the moment,
because we don't allow dashes.

So now I wonder, does the original code actually work for anyone?

John, are you sure that the ~ construct, and not that trailing i, was
confusing Sun's awk? According to my awk reference, ~ is a pretty
standard construct.

Anyway, this code seems to be overly complicated in the first place.
What about this instead:

        /^$/    { exit }
        END     { exit (not_mh) }
        !/^[A-Za-z-]+:[ \t]/    { not_mh=1 ; exit }

Works for me and should be totally portable. John, can you please test
with Sun's /usr/xpg4/bin/awk for confirmation?

Note that the attached patch breaks the test suite. My analysis is that
the old awk code didn't work, and this hid a different bug in mail.in,
which we will now have to hunt for.

Thanks,
-- 
Jean Delvare
Index: quilt/mail.in
===================================================================
RCS file: /cvsroot/quilt/quilt/quilt/mail.in,v
retrieving revision 1.20
diff -u -r1.20 mail.in
--- quilt/mail.in       1 Feb 2006 12:50:31 -0000       1.20
+++ quilt/mail.in       3 Feb 2006 08:41:54 -0000
@@ -223,13 +223,10 @@
                if [ [EMAIL PROTECTED] -eq 0 ]
                then
                        if echo "$header" | awk '
-                               /^$/    { exit (!mh || not_mh) }
-                               END     { exit (!mh || not_mh) }
-                               { if ($0 ~ /^[a-z]+:[ \t]/i)
-                                   mh = 1
-                                 else
-                                   not_mh = 1
-                               }'
+                               /^$/    { exit }
+                               END     { exit (not_mh) }
+                               !/^[A-Za-z-]+:[ \t]/ { not_mh=1 ; exit }
+                               '
                        then
                                return 1
                        fi
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to