From: Szabolcs Nagy Date: Thu, 18 Jun 2015 21:46:13 +0000 (+0000) Subject: add regex REG_ICASE test for austingroupbug #872 X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=05b75aa5eb2a9908495c341300a2acc19e9eaf4b add regex REG_ICASE test for austingroupbug #872 --- diff --git a/src/regression/regex-bracket-icase.c b/src/regression/regex-bracket-icase.c new file mode 100644 index 0000000..82b9287 --- /dev/null +++ b/src/regression/regex-bracket-icase.c @@ -0,0 +1,46 @@ +// [^aBcC] with REG_ICASE should match d,D but not a,A,b,B,c,C according to +// http://austingroupbugs.net/view.php?id=872 +#include +#include +#include +#include "test.h" + +int main(void) +{ + char buf[100]; + char *pat; + regex_t re; + int n, i; + struct { + char *s; + int n; + } t[] = { + {"a", REG_NOMATCH}, + {"A", REG_NOMATCH}, + {"b", REG_NOMATCH}, + {"B", REG_NOMATCH}, + {"c", REG_NOMATCH}, + {"C", REG_NOMATCH}, + {"d", 0}, + {"D", 0}, + {0,0} + }; + + pat = "[^aBcC]"; + n = regcomp(&re, pat, REG_ICASE); + if (n) { + regerror(n, &re, buf, sizeof buf); + t_error("regcomp(\"%s\") failed: %d (%s)\n", pat, n, buf); + } + + for (i = 0; t[i].s; i++) { + n = regexec(&re, t[i].s, 0, 0, 0); + if (n != t[i].n) { + regerror(n, &re, buf, sizeof buf); + t_error("regexec(/%s/, \"%s\") returned %d (%s), wanted %d\n", + pat, t[i].s, n, buf, t[i].n); + } + } + + return t_status; +}