Hello again folks,
I supply a test program that clearly demonstrates
regex_old.c of uClibc-0.9.29
regex.c of uClibc-0.9.28
to be seriously disfunctional. The testprogram fails
for 11 out of 48 strings, where the new regex.c of
uClibc-0.9.29 as well as glibc succeed.
The toolchain was constructed from binutils-2.17,
gcc-4.1.2, and uClibc-0.9.29 for i386.
The complexity of regex_old.c is to grave for me to
resolve the error on my own, but the failing strings clearly
display that the problem lies in the interplay between
repetitions "{n}" and "*" as well as "?". "+" is not
affected here. Thus the case "zero_time_ok == 1" must be
checked in repetitions.
All testing patterns are crafted to use at least strings
built from the words "ab" and "ba". The maintainer of this
code will probably find the string "baab" to provide most
insight, since it provokes most of the failures. The test
program is very verbose with test strings and patterns,
and their grouping intends to simplify visual patterns.
Best regards
M E Andersson
/* test_regex.c
*
* The blocked (extended) regular expressions have as least common
* solution the two words "ab" and "ba". Thus all used regexes used
* here should at least match any sequence of "ab" and "ba", up to
* the repetition length they are crafted for.
*/
#include <sys/types.h>
#include <regex.h>
#include <stdio.h>
void match(const char *moenster, char *text[], int max) {
int n;
regex_t uttryck;
if ( regcomp(&uttryck, moenster, REG_EXTENDED) ) {
printf("Error\n");
return;
}
for (n=0; n<max; n++) {
if ( regexec(&uttryck, text[n], 0, NULL, 0) )
printf("\"%s\" FAILED eregex %s\n", text[n], moenster);
else
printf("\"%s\" matches eregex %s\n", text[n], moenster);
}
regfree(&uttryck);
}
int main(void) {
char *mns_ast = "^(a*b|ba){2}$",
*mns_astl = "^(a*b|ba)(a*b|ba)$",
*mns_plus = "^(a+b|ba){2}$",
*mnst = "^(a?b|ba){2}$",
*mnstl = "^(a?b|ba)(a?b|ba)$",
*mnstr = "^(ba|a?b){2}$",
*mnstrl = "^(ba|a?b)(ba|a?b)$",
*mnstrs = "^(ba|ab?){2}$",
*tretal_ast = "^(a*b|ba){3}$",
*tretal = "^(a?b|ba){3}$";
char *rad[] = { "abab", "abba", "baab", "baba"},
*triad[] = { "ababab", "ababba", "abbaab", "abbaba",
"baabab", "baabba", "babaab", "bababa" };
puts("==== *,{2} ==");
match(mns_ast, rad, 4);
puts("==== * duplicate ==");
match(mns_astl, rad, 4);
puts("==== +,{2} ==");
match(mns_plus, rad, 4);
puts("==== ?,{} ==");
match(mnst, rad, 4);
puts("==== ? duplicate ==");
match(mnstl, rad, 4);
puts("==== ?,{} reversed ==");
match(mnstr, rad, 4);
puts("==== ? reversed duplicate ==");
match(mnstrl, rad, 4);
puts("==== ? {} mirrored ==");
match(mnstrs, rad, 4);
puts("==== *,{3} ==");
match(tretal_ast, triad, 8);
puts("==== ?,{3} ==");
match(tretal, triad, 8);
}
_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc