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

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

Re: Bug in gawk when both RS="" and file contains only empty lines


From: Michel Jouvin
Subject: Re: Bug in gawk when both RS="" and file contains only empty lines
Date: Wed, 25 Jul 2001 09:50:35 +0100

Aharon,

Thanks a lot for the patch. It works for me.

Michel

On Tue, 24 Jul 2001 03:36:57 +0300 Aharon Robbins <address@hidden> 
wrote:

> Greetings.  Re this:
> 
> > From: Michel Jouvin <address@hidden>
> > Date: Thu, 19 Jul 2001 15:30:34 +0100
> > To: address@hidden
> > Subject: Bug in gawk when both RS="" and file contains only empty lines
> > Cc: address@hidden
> >
> > I have a problem with gawk on Linux RH 6.2. The problem exists both 
> > with the original version (3.0.4) and 3.1 I installed.
> >
> > I use gawk with the following parameters :
> >
> >     gawk 'BEGIN {RS=""} {print "Next record :", $0}' input_file
> >
> > This command prints all the lines of the input file as records (FS=\n 
> > implied. the problem remains the same with an explicit FS=\n). This 
> > works perfectly as long as the file is empty or conatins one non empty 
> > line.
> >
> > But if it happens that input_file is made only of empty lines (one or 
> > several, it doesn't matter but lines should not contain even a space), 
> > gawk never exits.
> >
> > I don't reproduce this behaviour with awk (non Gnu) on other platforms 
> > (like Tru64 awk for example) where awk just exits as if the file was 
> > empty.
> >
> > Thanks in advance for any help.
> >
> > Michel
> 
> It's a bug.  Here is an unofficial patch.
> 
> Thanks for the bug report.
> 
> Arnold
> 
> *** ../gawk-3.1.0/io.c        Tue Apr 24 07:35:35 2001
> --- io.c      Mon Jul 23 20:24:47 2001
> ***************
> *** 2286,2291 ****
> --- 2286,2297 ----
>                                */
>                               while (*start == '\n' && start < iop->end)
>                                       start++;
> +                             /* if file is nothing but newlines, no record 
> found */
> +                             if (iop->cnt == EOF && start >= iop->end) {
> +                                     *out = NULL;
> +                                     set_RT_to_null();
> +                                     return EOF;
> +                             }
>                               goto again;
>                       }
>                       bp = start + RESTART(rsre, start);

     *************************************************************
     * Michel Jouvin                 Email : address@hidden *
     * LAL / CNRS                    Fax : +33 1 69079404        *
     * B.P. 34                                                   *
     * 91898 Orsay Cedex                                         *
     * France                                                    *
     *************************************************************





reply via email to

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