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

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

Re: conversion error


From: Aharon Robbins
Subject: Re: conversion error
Date: Tue, 04 Jul 2006 22:46:47 +0300

Greetings. Re this:

> Date: Tue, 04 Jul 2006 21:06:14 +0200 (MEST)
> From: Heiner Marxen <address@hidden>
> Subject: conversion error
> To: address@hidden
>
> Hello,
>
> The following awk script fails for gawk 3.1.4 and 3.1.5.
> Older versions did not do this, but I cannot say, how old they were.
>
> BEGIN {
>     if( 0 ) {         #ok
>       t = "8"
>     }else {           #fails
>       t = ""
>       t = t "8"
>     }
>     printf("8  = %d\n", 0+t)  # ok without this line
>     t = t "8"                 # does not invalidate numeric interpretation
>     printf("88 = %s\n", 0+t)
>     ## The above prints "88 = 8" with gawk 3.1.4 and 3.1.5
> }
>
> The following one-liner already exhibits the bug:
>
> gawk 'BEGIN{t=""; t=t "8";printf("8=%d\n", 0+t);t=t "8";printf("88=%s\n", 
> 0+t)}'
>
>
> Preliminary observation: under somewhat strange conditions a variable
> does retain its numeric interpretation although something is appended to it.
> -- 
> Heiner Marxen                         http://www.drb.insel.de/~heiner/

This is an excellent bug report and test case. Much thanks. The following
patch fixes the problem.

Arnold
----------------------------------------------------
Tue Jul  4 22:43:05 2006  Arnold D. Robbins  <address@hidden>

        * eval.c (interpret): Node_assign_concat case: Turn off NUMBER and 
NUMCUR
        flags in result.  Sheesh. Thanks to <address@hidden> for finding
        the problem.

--- ../gawk-3.1.5/eval.c        2005-07-26 21:07:43.000000000 +0300
+++ eval.c      2006-07-04 22:41:25.000000000 +0300
@@ -1186,6 +1187,7 @@
                        unref(*lhs);
                        *lhs = make_str_node(nval, l->stlen + r->stlen, 
ALREADY_MALLOCED);
                }
+               (*lhs)->flags &= ~(NUMCUR|NUMBER);
                free_temp(r);
 
                if (after_assign)




reply via email to

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