This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: regcomp problem with 2.1.3
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: regcomp problem with 2.1.3
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Mon, 15 May 2000 13:14:53 -0700
- Cc: libc-alpha Mailinglist <libc-alpha at sourceware dot cygnus dot com>,Andreas Hartmann <andihartmann at 01019freenet dot de>
- References: <u8puqorl7h.fsf@gromit.rhein-neckar.de>
On Mon, May 15, 2000 at 03:34:26PM +0200, Andreas Jaeger wrote:
>
> Hi all,
>
> Andreas Hartmann reported a problem with regular expressions in glibc
> 2.1.3. He's written a small program to show the problem which I just
> polished up a little bit.
>
>
> The appended program gives the following error:
> $ ./a.out
> <13>
> <Invalid preceding regular expression>
>
> Removing either of the RE_ options results in correct behaviour, but
> the combination of both RE_BACKSLASH_ESCAPE_IN_LISTS and
> RE_CONTEXT_INDEP_ANCHORS leads to an error in regcomp.
>
> Could somebody please investigate what's wrong here?
>
> Thanks,
> Andreas
>
> #include <ctype.h>
> #include <regex.h>
> #include <stdio.h>
> #include <malloc.h>
>
> int
> main (void)
> {
> regex_t *preg;
> int ret;
>
> preg = calloc(1, sizeof(regex_t));
>
> if((ret = regcomp(preg, "*.ANF", RE_BACKSLASH_ESCAPE_IN_LISTS|RE_CONTEXT_INDEP_ANCHORS)) != 0)
> {
I am confused. From regex.h:
/* If this bit is set, then ^ and $ are always anchors (outside bracket
expressions, of course).
If this bit is not set, then it depends:
^ is an anchor if it is at the beginning of a regular
expression or after an open-group or an alternation operator;
$ is an anchor if it is at the end of a regular expression, or
before a close-group or an alternation operator.
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
POSIX draft 11.2 says that * etc. in leading positions is undefined.
We already implemented a previous draft which made those constructs
invalid, though, so we haven't changed the code back. */
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
When you have "*..ANF", you will get undefined hehavior. I have no
idea if there is an incorrect behaviour.
H.J.