bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: BEGINFILE / ENDFILE patch for gawk now available


From: Aharon Robbins
Subject: Re: BEGINFILE / ENDFILE patch for gawk now available
Date: Thu, 25 Dec 2008 09:03:25 +0200

In article <address@hidden>,
Aharon Robbins <address@hidden> wrote:
> As an experiment, I have made available a patch that implements two
> new special patterns, BEGINFILE and ENDFILE.

Steffen Schuler then wrote:
> Your patch for gawk-3.1.6 doesn't work for
> 
> gawk 'BEGINFILE { print FILENAME }' file
> 
> --> No output.
> 
> (gawk has to read the file at least partially (e.g. EOF), for BEGINFILE 
> having effect.)
> 
> But this is a feature and no bug.

It is a bug. The patch is attached. I will update the patch on the website.

Arnold
---------------------------------------
diff -ur gawk-BEGINFILE/ChangeLog gawk-BEGINFILE-2/ChangeLog
--- gawk-BEGINFILE/ChangeLog    Tue Sep 23 16:21:20 2008
+++ gawk-BEGINFILE-2/ChangeLog  Wed Dec 24 09:57:55 2008
@@ -1,3 +1,9 @@
+Wed Dec 24 09:57:00 2008  Arnold D. Robbins  <address@hidden>
+
+       * main.c (main): Check beginfile_block and endfile_block also
+       to be not NULL in order to call do_input. Thanks to Steffen
+       Schuler for pointing out the bug.
+
 Tue Sep 23 17:20:02 2008  Arnold D. Robbins  <address@hidden>
 
        * io.c (specfdopen, pidopen, useropen): Add `do_openhooks' flag and
diff -ur gawk-BEGINFILE/main.c gawk-BEGINFILE-2/main.c
--- gawk-BEGINFILE/main.c       Mon Sep 08 06:13:08 2008
+++ gawk-BEGINFILE-2/main.c     Wed Dec 24 09:56:06 2008
@@ -619,7 +619,8 @@
                (void) interpret(begin_block);
        }
        in_begin_rule = FALSE;
-       if (! exiting && (expression_value != NULL || end_block != NULL))
+       if (! exiting && (expression_value != NULL || end_block != NULL
+                       || beginfile_block != NULL || endfile_block != NULL))
                do_input();
        if (end_block != NULL) {
                in_end_rule = TRUE;
-- 
Aharon (Arnold) Robbins                                 arnold AT skeeve DOT com
P.O. Box 354            Home Phone: +972  8 979-0381
Nof Ayalon              Cell Phone: +972 50  729-7545
D.N. Shimshon 99785     ISRAEL




reply via email to

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