This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [regex] Fix BZ429
- From: Ulrich Drepper <drepper at redhat dot com>
- To: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Thu, 11 Nov 2004 22:48:29 -0800
- Subject: Re: [regex] Fix BZ429
- Organization: Red Hat, Inc.
- References: <4191F700.2030707@lu.unisi.ch>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
While this patch very much improves performance and probably
correctness in case of REG_NOSUB, the reported matches when REG_NOSUB
is not used are wrong. Try this modified version of the test case:
#include <regex.h>
#include <stdio.h>
int
main ()
{
regex_t rbuf;
const char *p;
int err;
p = "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?"
"\\9\\8\\7\\6\\5\\4\\3\\2\\1$";
if ((err = regcomp (&rbuf, p, REG_EXTENDED)))
{
char errstr[300];
regerror (err, &rbuf, errstr, sizeof (errstr));
puts (errstr);
return err;
}
regmatch_t m[10];
const char str[] = "civic";
err = regexec (&rbuf, str, sizeof (m) / sizeof (m[0]), m, 0);
if (err != 0)
{
puts ("regexec failed");
return 1;
}
for (int i = 0; i < sizeof (m) / sizeof (m[0]); ++i)
if (m[i].rm_so == -1)
printf ("m[%d] unused\n", i);
else
printf ("m[%d] = \"%.*s\"\n", i, (int) (m[i].rm_eo - m[i].rm_so),
str + m[i].rm_so);
return 0;
}
I get:
m[0] = "civic"
m[1] = "c"
m[2] = "i"
m[3] = ""
m[4] = ""
m[5] = ""
m[6] = ""
m[7] = ""
m[8] = ""
m[9] = ""
which is pretty much all wrong.
- --
â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFBlFy92ijCOnn/RHQRAjKTAJ9s20XD6+MSG6Uez338dFj9+CSiWQCfZBgj
dOOFVzG2Rl6khqdoQ/UxVrI=
=2rLH
-----END PGP SIGNATURE-----