fnmatch() does not appear to work with character classes or character equivalents. regcomp(), however, does work with character classes, but not character equivalents. Is this behavior one should expect? I've tested with Debian, and it matches in both cases.
I sent this to the Cygwin ML rather than the Newlib ML just because of the fact that it may be locale-related, which is a problem on Cygwin's end, not Newlib's, if it's a problem at all. The attached program will hopefully illustrate the trouble occurring on my Windows 10 machine: regexec: 0 matched /[[:digit:]]/ fnmatch: 0 did not match /[[:digit:]]/ -- Sent using Mozilla Thunderbird
#define _XOPEN_SOURCE 700 #include <assert.h> #include <fnmatch.h> #include <regex.h> #include <stdio.h> int main (void) { regex_t reg; const char *pattern = "[[:digit:]]"; const char *s = "0"; int cflags = REG_NOSUB; assert(regcomp(®, pattern, cflags) == 0); if (regexec(®, s, 0, NULL, 0) == REG_NOMATCH) { printf("regexec: %s did not match /%s/\n", s, pattern); } else { printf("regexec: %s matched /%s/\n", s, pattern); } regfree(®); if (fnmatch(pattern, s, 0) == FNM_NOMATCH) { printf("fnmatch: %s did not match /%s/\n", s, pattern); } else { printf("fnmatch: %s matched /%s/\n", s, pattern); } }
-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple