lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <fnmatch.h> |
| 2 | #include <stdio.h> |
| 3 | |
| 4 | int |
| 5 | do_test (void) |
| 6 | { |
| 7 | char pattern[] = "a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*"; |
| 8 | const char *string = "aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmm" |
| 9 | "nnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyy"; |
| 10 | if (fnmatch (pattern, string, 0) != FNM_NOMATCH) |
| 11 | { |
| 12 | puts ("First fnmatch didn't return FNM_NOMATCH"); |
| 13 | return 1; |
| 14 | } |
| 15 | pattern[(sizeof pattern) - 3] = '*'; |
| 16 | if (fnmatch (pattern, string, 0) != 0) |
| 17 | { |
| 18 | puts ("Second fnmatch didn't return 0"); |
| 19 | return 1; |
| 20 | } |
| 21 | if (fnmatch ("a*b/*", "abbb/.x", FNM_PATHNAME | FNM_PERIOD) != FNM_NOMATCH) |
| 22 | { |
| 23 | puts ("Third fnmatch didn't return FNM_NOMATCH"); |
| 24 | return 1; |
| 25 | } |
| 26 | if (fnmatch ("a*b/*", "abbb/xy", FNM_PATHNAME | FNM_PERIOD) != 0) |
| 27 | { |
| 28 | puts ("Fourth fnmatch didn't return 0"); |
| 29 | return 1; |
| 30 | } |
| 31 | if (fnmatch ("[", "[", 0) != 0) |
| 32 | { |
| 33 | puts ("Fifth fnmatch didn't return 0"); |
| 34 | return 1; |
| 35 | } |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | #define TEST_FUNCTION do_test () |
| 40 | #include "../test-skeleton.c" |