[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk long lines bug?
From: |
dslate |
Subject: |
Re: gawk long lines bug? |
Date: |
18 Feb 2002 15:23:20 -0000 |
Reply-To: address@hidden
To: address@hidden address@hidden address@hidden address@hidden address@hidden
Subject: Re: gawk long lines bug?
I applied Paul's mod to re.c (in gawk-3.1.0.tar.gz), and it does seem to
fix my test case.
Thanks,
-- Dave Slate
> > From: Aharon Robbins <address@hidden>
> > Date: Sun, 17 Feb 2002 15:09:18 +0200
> >
> > The problem is that the regex routines return -2 indicating that they
> > couldn't allocate enough memory to handle the long string
>
> That -2 doesn't mean that they couldn't allocate enough memory; it
> means that they merely went over a heuristic limit designed to prevent
> them from allocating too much memory on the C stack. This heuristic
> doesn't apply to gawk, since it compiles with REGEX_MALLOC.
>
> This is clearly a bug in regex.c, but there's an easy workaround:
> raise that heuristic limit to be as high as possible. That way, you
> won't run into this silly limit until much later.
>
> The following patch causes 'gawk' to work correctly on that test case,
> without any error.
>
> 2002-02-17 Paul Eggert <address@hidden>
>
> * re.c (resetup): Try to avoid silly limitation of regex.c by
> setting re_max_failures to the largest reasonable value.
>
> ===================================================================
> RCS file: re.c,v
> retrieving revision 3.1.0.1
> retrieving revision 3.1.0.2
> diff -pu -r3.1.0.1 -r3.1.0.2
> --- re.c 2002/02/18 05:45:27 3.1.0.1
> +++ re.c 2002/02/18 06:58:40 3.1.0.2
> @@ -245,6 +245,18 @@ re_update(NODE *t)
> void
> resetup()
> {
> + /*
> + * Set RE_MAX_FAILURES to the largest reasonable value,
> + * to avoid spurious "not enough memory" messages.
> + * The '80' is computed as follows:
> + * regex.c's MAX_FAILURE_ITEMS is at most 20.
> + * regex.c computes 2 * MAX_FAILURE_ITEMS, giving us 40.
> + * re_max_failures is signed, not unsigned, for another factor of 2,
> + * giving us 80.
> + */
> + extern int re_max_failures;
> + re_max_failures = ((unsigned) -1) / 80;
> +
> if (do_posix)
> syn = RE_SYNTAX_POSIX_AWK; /* strict POSIX re's */
> else if (do_traditional)