[Top][All Lists]

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

Re: awk -v BINMODE=rw # \r is getting removed

From: Andrew J. Schorr
Subject: Re: awk -v BINMODE=rw # \r is getting removed
Date: Sat, 23 Aug 2008 18:18:52 -0400
User-agent: Mutt/

On Sat, Aug 23, 2008 at 12:32:18PM -0400, Andrew J. Schorr wrote:
> So I guess there's a bug in eval.c:set_BINMODE.  Note that an
> invalid value of BINMODE does not result in a warning message:
>    $ printf "HI\r\n"| awk -v BINMODE=fubar 1 | od -c
>    0000000   H   I  \n
>    0000003
> So it seems that the tests on BINMODE_node->var_value->flags
> are causing the string parsing code to be skipped.  I'm not
> exactly sure why...

FYI, I ran current savannah gawk under gdb, and this test is failing:

    if (! digits && (BINMODE_node->var_value->flags & MAYBE_NUM) == 0) {

so the code is jumping to:

    BINMODE = (int) force_number(BINMODE_node->var_value);

and BINMODE is getting set to zero.

The value of digits is 0, so the problem is with
BINMODE_node->var_value->flags.  That has the value:

(gdb) print BINMODE_node->sub.nodep.l.lptr->flags
$1 = 157

Since MAYBE_NUM is 128, and (157 & 128) is equal to 128,
the test is failing.

So either the flags are not being set correctly, or the test for MAYBE_NUM is
not appropriate.  I'm not sure what the proper patch is.  Removing the test for
'(flags & MAYBE_NUM) == 0' fixes the reported problem, but I don't know whether
that would break something subtle.


reply via email to

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