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

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

Re: Infinite loop in sub/gsub


From: Aharon Robbins
Subject: Re: Infinite loop in sub/gsub
Date: Sun, 6 Oct 2002 16:29:03 +0300

Greetings.  Re this:

> Date: Sun, 6 Oct 2002 08:36:54 -0400
> Subject: Infinite loop in sub/gsub
> From: address@hidden
> To: address@hidden
>
> This command line:
>
> echo "''Italics with an apostrophe'' embedded''"|gawk -f test.awk
>
> where test.awk contains this instruction:
>
> /''/  { sub(/''(.?[^']+)*''/, "<em>&</em>"); }
>
> puts gawk 3.11 into an infinite loop. Whereas, this command works:
>
> echo "''Italics with an apostrophe' embedded''"|gawk -f test.awk
>
> Platform: Mac OS X 10.1.5/Darwin Kernel Version 5.5: Thu May 30 14:51:26 
> PDT 2002; root:xnu/xnu-201.42.3.obj~1/RELEASE_PPC

This is a bug who-knows-where in the guts of the regex.[ch] library.
Unfortunately, I treat that as a black box, and have no idea how to
fix it.

Fortunately though, my development version has a shiny, brand spanking
new implementation of regex.[ch], and the bug doesn't show up using this
version.  (I verified this by dropping the new regex into the 3.1.1 gawk.):

        $ cat /tmp/data1
        ''Italics with an apostrophe'' embedded''
        $ cat /tmp/prog.awk
        /''/  { sub(/''(.?[^']+)*''/, "<em>&</em>"); print }
        $ ./gawk -f /tmp/prog.awk /tmp/data1
        <em>''Italics with an apostrophe''</em> embedded''

This new code will be part of 3.1.2.  I don't have a schedule for it yet,
but if you're desperate, I can point you at a test release.

OR, you can pull the new regex code out of the glibc CVS archive from
sources.redhat.com, and drop it into gawk 3.1.1 yourself.  Just remove
regex.c and regex.h, replace them with:

        regcomp.c
        regex.c
        regex.h
        regex_internal.c
        regex_internal.h
        regexec.c

from the glibc archive and type `make'.

Best wishes,

Arnold




reply via email to

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