This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Bug in Glibc Regex
Ulrich Drepper wrote:
>
> Andreas Pour <pour@mieterra.com> writes:
>
> > Really? I don't get that. Are you sure you used the second attachment
> > I sent (the first one was the one that does work with 2.1.3 -- the one
> > that doesn't has the line:
> >
> > const char *text = "{test}";
>
> ??? This cannot work. Why should it? { and } are special characters
> and have to be escaped. The behavior for above expression is
> undefined. Glibc is correct, your code not.
Well, it worked under prior versions of glibc. And my understanding of
'{' and '}' is that they are special only when followed by a number;
that is how it is defined in the regex man page:
A bound is `{' followed by an unsigned decimal integer,
possibly followed by `,' possibly followed by another
unsigned decimal integer, always followed by `}'.
Notice how other metacharacters do not have the "followed by" anything
description. For example:
A bracket expression is a list of characters enclosed in
`[]'.
Moreover, a regex is defined as branches. A branch as a "piece"
optionally followed by a "bound". In the example, there is no "piece"
before the "bound". So the two conditions prescribed for a bound --
preceded by a "piece" and succeeded by an "unsigned decimal integer" --
are not present in the "{test}" case. Thus there is no reason to
believe that it would be interpreted as a "bound". Can you give a
reason why it should be?
And that's how I've seen it implemented in other regex engines. As I
mentioned in my initial report, I don't have the POSIX spec available,
so I don't know if it contradicts the man page and the way everyone else
-- including prior versions of glibc -- implement regexes.
Ciao,
Andreas Pour
http://www.kde.com/ : Everything KDE
http://apps.kde.com/: The Latest in KDE Applications