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

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

gawk multi-byte support bugs, assertion bug and fix.


From: Lee Haywood
Subject: gawk multi-byte support bugs, assertion bug and fix.
Date: Thu, 27 Apr 2006 20:59:03 +0100

Firstly, I have been getting the following error from version 3.1.5.

    awk: node.c:515: unref: Assertion `(tmp->flags & 4096) != 0' failed.

In mk_number() in node.c the MBS_SUPPORT code is inside the GAWKDEBUG
section - moving it outside explicitly clears the string values, which
prevents the assertion error from occurring.  The corrected version is
shown at the end of this message.

As an aside, I also noticed that n->wstptr is not cleared by
set_field() and set_record() in field.c when the flags are set to
exclude WSTRCUR.  However, I do not have a test case to show if
changing them makes any difference.

A second problem also occurs when gawk 3.1.5 is compiled with
multi-byte character support (MBS_SUPPORT).  The following code should
change the index of the substring "bc" from 2 to 3, but it gets
reported as 2 in both cases - which is obviously disastrous.

    awk 'BEGIN {
            Value = "abc"

            print "Before <" Value "> ",
                  index( Value, "bc" )

            sub( /bc/, "bbc", Value )

            print "After  <" Value ">",
                  index( Value, "bc" )
        }'

Compiling with MBS_SUPPORT undefined makes these problems go away.

/* mk_number --- allocate a node with defined number */

NODE *
mk_number(AWKNUM x, unsigned int flags)
{
        register NODE *r;

        getnode(r);
        r->type = Node_val;
        r->numbr = x;
        r->flags = flags;
#if defined MBS_SUPPORT
        r->wstptr = NULL;
        r->wstlen = 0;
#endif /* MBS_SUPPORT */
#ifdef GAWKDEBUG
        r->stref = 1;
        r->stptr = NULL;
        r->stlen = 0;
#if defined MBS_SUPPORT
        r->flags &= ~WSTRCUR;
#endif /* MBS_SUPPORT */
#endif /* GAWKDEBUG */
        return r;
}

Thanks.

--
Lee Haywood.


reply via email to

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