1570af302Sopenharmony_ci// [^aBcC] with REG_ICASE should match d,D but not a,A,b,B,c,C according to 2570af302Sopenharmony_ci// http://austingroupbugs.net/view.php?id=872 3570af302Sopenharmony_ci#include <regex.h> 4570af302Sopenharmony_ci#include <limits.h> 5570af302Sopenharmony_ci#include <stdio.h> 6570af302Sopenharmony_ci#include "test.h" 7570af302Sopenharmony_ci 8570af302Sopenharmony_ciint main(void) 9570af302Sopenharmony_ci{ 10570af302Sopenharmony_ci char buf[100]; 11570af302Sopenharmony_ci char *pat; 12570af302Sopenharmony_ci regex_t re; 13570af302Sopenharmony_ci int n, i; 14570af302Sopenharmony_ci struct { 15570af302Sopenharmony_ci char *s; 16570af302Sopenharmony_ci int n; 17570af302Sopenharmony_ci } t[] = { 18570af302Sopenharmony_ci {"a", REG_NOMATCH}, 19570af302Sopenharmony_ci {"A", REG_NOMATCH}, 20570af302Sopenharmony_ci {"b", REG_NOMATCH}, 21570af302Sopenharmony_ci {"B", REG_NOMATCH}, 22570af302Sopenharmony_ci {"c", REG_NOMATCH}, 23570af302Sopenharmony_ci {"C", REG_NOMATCH}, 24570af302Sopenharmony_ci {"d", 0}, 25570af302Sopenharmony_ci {"D", 0}, 26570af302Sopenharmony_ci {0,0} 27570af302Sopenharmony_ci }; 28570af302Sopenharmony_ci 29570af302Sopenharmony_ci pat = "[^aBcC]"; 30570af302Sopenharmony_ci n = regcomp(&re, pat, REG_ICASE); 31570af302Sopenharmony_ci if (n) { 32570af302Sopenharmony_ci regerror(n, &re, buf, sizeof buf); 33570af302Sopenharmony_ci t_error("regcomp(\"%s\") failed: %d (%s)\n", pat, n, buf); 34570af302Sopenharmony_ci } 35570af302Sopenharmony_ci 36570af302Sopenharmony_ci for (i = 0; t[i].s; i++) { 37570af302Sopenharmony_ci n = regexec(&re, t[i].s, 0, 0, 0); 38570af302Sopenharmony_ci if (n != t[i].n) { 39570af302Sopenharmony_ci regerror(n, &re, buf, sizeof buf); 40570af302Sopenharmony_ci t_error("regexec(/%s/, \"%s\") returned %d (%s), wanted %d\n", 41570af302Sopenharmony_ci pat, t[i].s, n, buf, t[i].n); 42570af302Sopenharmony_ci } 43570af302Sopenharmony_ci } 44570af302Sopenharmony_ci 45570af302Sopenharmony_ci return t_status; 46570af302Sopenharmony_ci} 47