This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Bug in Glibc Regex
- To: libc-alpha at sources dot redhat dot com
- Subject: Bug in Glibc Regex
- From: Andreas Pour <pour at mieterra dot com>
- Date: Mon, 11 Sep 2000 03:30:36 -0400
Hi,
I just installed glibc 2.1.3 to run with php, and was disappointed to
find that a lot of my scripts were broken.
In glibc 2.1.1 and 2.1.2, and just about any other regex I have ever
used, the phrase "{text}" worked as a regex. Now it doesn't, treating
the '{' as a bound counter delimiter. My understanding was that '{'
should act that way only if followed by an integer, as the test case is
not. It's obviously not a count delimiter, and regex never thought so
before. From man 7 regex:
A bound is `{' followed by an unsigned decimal integer,
possibly followed by `,' possibly followed by another
unsigned decimal integer, always followed by `}'. The
integers must lie between 0 and RE_DUP_MAX (255) inclu
sive, and if there are two of them, the first may not
exceed the second. An atom followed by a bound containing
one integer i and no comma matches a sequence of exactly i
matches of the atom. An atom followed by a bound contain
ing one integer i and a comma matches a sequence of i or
more matches of the atom. An atom followed by a bound
containing two integers i and j matches a sequence of i
through j (inclusive) matches of the atom.
I realize this statement does not explicitly say that an occurrence of
'{' w/out a following integer does not have to be escaped, but it
certainly implies it; e.g. the definition of the metacharacter '[' does
not specify that any special character has to follow it to have a
special meaning. I don't have POSIX 1003.2 handy and IEEE makes it hard
to come by. My suspicion is that this change does not comply with
POSIX 1003.2?
The attached file outputs:
Matches:
Position 11 - 17
on glibc-2.1.1 and
Compilation of regex '{test}' failed, error 'Invalid content of \{\}'.
on glibc-2.1.3.
Switching to using "const char *text = '\\{test\\}'" works on both
versions of glibc.
Ciao,
Andreas Pour