| 1 |
/* Test of fnmatch string matching function. |
| 2 |
Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This program is free software: you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation, either version 3 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 16 |
|
| 17 |
/* Written by Simon Josefsson <[email protected]>, 2009, |
| 18 |
and Bruno Haible <[email protected]>, 2023. */ |
| 19 |
|
| 20 |
#include <config.h> |
| 21 |
|
| 22 |
#include <fnmatch.h> |
| 23 |
|
| 24 |
#include "signature.h" |
| 25 |
SIGNATURE_CHECK (fnmatch, int, (char const *, char const *, int)); |
| 26 |
|
| 27 |
#include <locale.h> |
| 28 |
#include <stdio.h> |
| 29 |
#include <stdlib.h> |
| 30 |
#include <string.h> |
| 31 |
#include <wchar.h> |
| 32 |
#include <wctype.h> |
| 33 |
|
| 34 |
#include "macros.h" |
| 35 |
|
| 36 |
int |
| 37 |
main (int argc, char *argv[]) |
| 38 |
{ |
| 39 |
/* configure should already have checked that the locale is supported. */ |
| 40 |
if (setlocale (LC_ALL, "") == NULL) |
| 41 |
return 1; |
| 42 |
|
| 43 |
#ifdef __ANDROID__ |
| 44 |
/* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the |
| 45 |
"C" locale. Furthermore, when you attempt to set the "C" or "POSIX" |
| 46 |
locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, |
| 47 |
that is, effectively the "C.UTF-8" locale. */ |
| 48 |
if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) |
| 49 |
argv[1] = "3"; |
| 50 |
#endif |
| 51 |
|
| 52 |
/* Patterns with ordinary characters. */ |
| 53 |
|
| 54 |
ASSERT (fnmatch ("", "", 0) == 0); |
| 55 |
ASSERT (fnmatch ("", "abc", 0) == FNM_NOMATCH); |
| 56 |
|
| 57 |
ASSERT (fnmatch ("xy", "xy", 0) == 0); |
| 58 |
ASSERT (fnmatch ("xy", "", 0) == FNM_NOMATCH); |
| 59 |
ASSERT (fnmatch ("xy", "wxy", 0) == FNM_NOMATCH); |
| 60 |
ASSERT (fnmatch ("xy", "xyz", 0) == FNM_NOMATCH); |
| 61 |
|
| 62 |
/* Patterns with special pattern characters. */ |
| 63 |
|
| 64 |
ASSERT (fnmatch ("?", "", 0) == FNM_NOMATCH); |
| 65 |
ASSERT (fnmatch ("?", "a", 0) == 0); |
| 66 |
ASSERT (fnmatch ("?", "z", 0) == 0); |
| 67 |
ASSERT (fnmatch ("?", ".", 0) == 0); |
| 68 |
ASSERT (fnmatch ("?", "/", 0) == 0); |
| 69 |
ASSERT (fnmatch ("?", "az", 0) == FNM_NOMATCH); |
| 70 |
ASSERT (fnmatch ("?", "//", 0) == FNM_NOMATCH); |
| 71 |
|
| 72 |
ASSERT (fnmatch ("x?y", "", 0) == FNM_NOMATCH); |
| 73 |
ASSERT (fnmatch ("x?y", "y", 0) == FNM_NOMATCH); |
| 74 |
ASSERT (fnmatch ("x?y", "xy", 0) == FNM_NOMATCH); |
| 75 |
ASSERT (fnmatch ("x?y", "xay", 0) == 0); |
| 76 |
ASSERT (fnmatch ("x?y", "xzy", 0) == 0); |
| 77 |
ASSERT (fnmatch ("x?y", "x.y", 0) == 0); |
| 78 |
ASSERT (fnmatch ("x?y", "x/y", 0) == 0); |
| 79 |
ASSERT (fnmatch ("x?y", "xazy", 0) == FNM_NOMATCH); |
| 80 |
ASSERT (fnmatch ("x?y", "x//y", 0) == FNM_NOMATCH); |
| 81 |
|
| 82 |
ASSERT (fnmatch ("*", "", 0) == 0); |
| 83 |
ASSERT (fnmatch ("*", "a", 0) == 0); |
| 84 |
ASSERT (fnmatch ("*", "z", 0) == 0); |
| 85 |
ASSERT (fnmatch ("*", ".", 0) == 0); |
| 86 |
ASSERT (fnmatch ("*", "*", 0) == 0); |
| 87 |
ASSERT (fnmatch ("*", "/", 0) == 0); |
| 88 |
ASSERT (fnmatch ("*", "az", 0) == 0); |
| 89 |
ASSERT (fnmatch ("*", "//", 0) == 0); |
| 90 |
ASSERT (fnmatch ("*", "some long text", 0) == 0); |
| 91 |
|
| 92 |
ASSERT (fnmatch ("x*y", "", 0) == FNM_NOMATCH); |
| 93 |
ASSERT (fnmatch ("x*y", "y", 0) == FNM_NOMATCH); |
| 94 |
ASSERT (fnmatch ("x*y", "xy", 0) == 0); |
| 95 |
ASSERT (fnmatch ("x*y", "xay", 0) == 0); |
| 96 |
ASSERT (fnmatch ("x*y", "xzy", 0) == 0); |
| 97 |
ASSERT (fnmatch ("x*y", "x.y", 0) == 0); |
| 98 |
ASSERT (fnmatch ("x*y", "x*y", 0) == 0); |
| 99 |
ASSERT (fnmatch ("x*y", "x/y", 0) == 0); |
| 100 |
ASSERT (fnmatch ("x*y", "xazy", 0) == 0); |
| 101 |
ASSERT (fnmatch ("x*y", "x//y", 0) == 0); |
| 102 |
|
| 103 |
ASSERT (fnmatch ("**", "", 0) == 0); |
| 104 |
ASSERT (fnmatch ("**", "a", 0) == 0); |
| 105 |
ASSERT (fnmatch ("**", "z", 0) == 0); |
| 106 |
ASSERT (fnmatch ("**", ".", 0) == 0); |
| 107 |
ASSERT (fnmatch ("**", "*", 0) == 0); |
| 108 |
ASSERT (fnmatch ("**", "/", 0) == 0); |
| 109 |
ASSERT (fnmatch ("**", "az", 0) == 0); |
| 110 |
ASSERT (fnmatch ("**", "//", 0) == 0); |
| 111 |
ASSERT (fnmatch ("**", "some long text", 0) == 0); |
| 112 |
|
| 113 |
ASSERT (fnmatch ("x**y", "", 0) == FNM_NOMATCH); |
| 114 |
ASSERT (fnmatch ("x**y", "y", 0) == FNM_NOMATCH); |
| 115 |
ASSERT (fnmatch ("x**y", "xy", 0) == 0); |
| 116 |
ASSERT (fnmatch ("x**y", "xay", 0) == 0); |
| 117 |
ASSERT (fnmatch ("x**y", "xzy", 0) == 0); |
| 118 |
ASSERT (fnmatch ("x**y", "x.y", 0) == 0); |
| 119 |
ASSERT (fnmatch ("x**y", "x*y", 0) == 0); |
| 120 |
ASSERT (fnmatch ("x**y", "x/y", 0) == 0); |
| 121 |
ASSERT (fnmatch ("x**y", "xazy", 0) == 0); |
| 122 |
ASSERT (fnmatch ("x**y", "x//y", 0) == 0); |
| 123 |
ASSERT (fnmatch ("x**y", "", 0) == FNM_NOMATCH); |
| 124 |
ASSERT (fnmatch ("x**y", "y", 0) == FNM_NOMATCH); |
| 125 |
|
| 126 |
ASSERT (fnmatch ("*.*", "foo.txt", 0) == 0); |
| 127 |
ASSERT (fnmatch ("*.*", "foo.", 0) == 0); |
| 128 |
ASSERT (fnmatch ("*.*", "foo", 0) == FNM_NOMATCH); |
| 129 |
|
| 130 |
ASSERT (fnmatch ("x*y*z", "", 0) == FNM_NOMATCH); |
| 131 |
ASSERT (fnmatch ("x*y*z", "x", 0) == FNM_NOMATCH); |
| 132 |
ASSERT (fnmatch ("x*y*z", "y", 0) == FNM_NOMATCH); |
| 133 |
ASSERT (fnmatch ("x*y*z", "z", 0) == FNM_NOMATCH); |
| 134 |
ASSERT (fnmatch ("x*y*z", "xy", 0) == FNM_NOMATCH); |
| 135 |
ASSERT (fnmatch ("x*y*z", "xz", 0) == FNM_NOMATCH); |
| 136 |
ASSERT (fnmatch ("x*y*z", "yz", 0) == FNM_NOMATCH); |
| 137 |
ASSERT (fnmatch ("x*y*z", "xyz", 0) == 0); |
| 138 |
ASSERT (fnmatch ("x*y*z", "xayz", 0) == 0); |
| 139 |
ASSERT (fnmatch ("x*y*z", "xybz", 0) == 0); |
| 140 |
ASSERT (fnmatch ("x*y*z", "xaybz", 0) == 0); |
| 141 |
ASSERT (fnmatch ("x*y*z", "xxyz", 0) == 0); |
| 142 |
ASSERT (fnmatch ("x*y*z", "xyyz", 0) == 0); |
| 143 |
ASSERT (fnmatch ("x*y*z", "xyzz", 0) == 0); |
| 144 |
ASSERT (fnmatch ("x*y*z", "xyxyz", 0) == 0); |
| 145 |
|
| 146 |
ASSERT (fnmatch ("x***??y", "", 0) == FNM_NOMATCH); |
| 147 |
ASSERT (fnmatch ("x***??y", "xy", 0) == FNM_NOMATCH); |
| 148 |
ASSERT (fnmatch ("x***??y", "x1y", 0) == FNM_NOMATCH); |
| 149 |
ASSERT (fnmatch ("x***??y", "x12y", 0) == 0); |
| 150 |
ASSERT (fnmatch ("x***??y", "x123y", 0) == 0); |
| 151 |
|
| 152 |
ASSERT (fnmatch ("x**??*y", "", 0) == FNM_NOMATCH); |
| 153 |
ASSERT (fnmatch ("x**??*y", "xy", 0) == FNM_NOMATCH); |
| 154 |
ASSERT (fnmatch ("x**??*y", "x1y", 0) == FNM_NOMATCH); |
| 155 |
ASSERT (fnmatch ("x**??*y", "x12y", 0) == 0); |
| 156 |
ASSERT (fnmatch ("x**??*y", "x123y", 0) == 0); |
| 157 |
|
| 158 |
ASSERT (fnmatch ("x*??**y", "", 0) == FNM_NOMATCH); |
| 159 |
ASSERT (fnmatch ("x*??**y", "xy", 0) == FNM_NOMATCH); |
| 160 |
ASSERT (fnmatch ("x*??**y", "x1y", 0) == FNM_NOMATCH); |
| 161 |
ASSERT (fnmatch ("x*??**y", "x12y", 0) == 0); |
| 162 |
ASSERT (fnmatch ("x*??**y", "x123y", 0) == 0); |
| 163 |
|
| 164 |
ASSERT (fnmatch ("x??***y", "", 0) == FNM_NOMATCH); |
| 165 |
ASSERT (fnmatch ("x??***y", "xy", 0) == FNM_NOMATCH); |
| 166 |
ASSERT (fnmatch ("x??***y", "x1y", 0) == FNM_NOMATCH); |
| 167 |
ASSERT (fnmatch ("x??***y", "x12y", 0) == 0); |
| 168 |
ASSERT (fnmatch ("x??***y", "x123y", 0) == 0); |
| 169 |
|
| 170 |
ASSERT (fnmatch ("x**?*?y", "", 0) == FNM_NOMATCH); |
| 171 |
ASSERT (fnmatch ("x**?*?y", "xy", 0) == FNM_NOMATCH); |
| 172 |
ASSERT (fnmatch ("x**?*?y", "x1y", 0) == FNM_NOMATCH); |
| 173 |
ASSERT (fnmatch ("x**?*?y", "x12y", 0) == 0); |
| 174 |
ASSERT (fnmatch ("x**?*?y", "x123y", 0) == 0); |
| 175 |
|
| 176 |
ASSERT (fnmatch ("x*?*?*y", "", 0) == FNM_NOMATCH); |
| 177 |
ASSERT (fnmatch ("x*?*?*y", "xy", 0) == FNM_NOMATCH); |
| 178 |
ASSERT (fnmatch ("x*?*?*y", "x1y", 0) == FNM_NOMATCH); |
| 179 |
ASSERT (fnmatch ("x*?*?*y", "x12y", 0) == 0); |
| 180 |
ASSERT (fnmatch ("x*?*?*y", "x123y", 0) == 0); |
| 181 |
|
| 182 |
ASSERT (fnmatch ("x?*?**y", "", 0) == FNM_NOMATCH); |
| 183 |
ASSERT (fnmatch ("x?*?**y", "xy", 0) == FNM_NOMATCH); |
| 184 |
ASSERT (fnmatch ("x?*?**y", "x1y", 0) == FNM_NOMATCH); |
| 185 |
ASSERT (fnmatch ("x?*?**y", "x12y", 0) == 0); |
| 186 |
ASSERT (fnmatch ("x?*?**y", "x123y", 0) == 0); |
| 187 |
|
| 188 |
ASSERT (fnmatch ("x*?**?y", "", 0) == FNM_NOMATCH); |
| 189 |
ASSERT (fnmatch ("x*?**?y", "xy", 0) == FNM_NOMATCH); |
| 190 |
ASSERT (fnmatch ("x*?**?y", "x1y", 0) == FNM_NOMATCH); |
| 191 |
ASSERT (fnmatch ("x*?**?y", "x12y", 0) == 0); |
| 192 |
ASSERT (fnmatch ("x*?**?y", "x123y", 0) == 0); |
| 193 |
|
| 194 |
ASSERT (fnmatch ("x?**?*y", "", 0) == FNM_NOMATCH); |
| 195 |
ASSERT (fnmatch ("x?**?*y", "xy", 0) == FNM_NOMATCH); |
| 196 |
ASSERT (fnmatch ("x?**?*y", "x1y", 0) == FNM_NOMATCH); |
| 197 |
ASSERT (fnmatch ("x?**?*y", "x12y", 0) == 0); |
| 198 |
ASSERT (fnmatch ("x?**?*y", "x123y", 0) == 0); |
| 199 |
|
| 200 |
ASSERT (fnmatch ("x?***?y", "", 0) == FNM_NOMATCH); |
| 201 |
ASSERT (fnmatch ("x?***?y", "xy", 0) == FNM_NOMATCH); |
| 202 |
ASSERT (fnmatch ("x?***?y", "x1y", 0) == FNM_NOMATCH); |
| 203 |
ASSERT (fnmatch ("x?***?y", "x12y", 0) == 0); |
| 204 |
ASSERT (fnmatch ("x?***?y", "x123y", 0) == 0); |
| 205 |
|
| 206 |
/* Patterns with bracket expressions. */ |
| 207 |
|
| 208 |
ASSERT (fnmatch ("[a-z]", "", 0) == FNM_NOMATCH); |
| 209 |
ASSERT (fnmatch ("[a-z]", "a", 0) == 0); |
| 210 |
ASSERT (fnmatch ("[a-z]", "z", 0) == 0); |
| 211 |
ASSERT (fnmatch ("[a-z]", ".", 0) == FNM_NOMATCH); |
| 212 |
ASSERT (fnmatch ("[a-z]", "/", 0) == FNM_NOMATCH); |
| 213 |
ASSERT (fnmatch ("[a-z]", "az", 0) == FNM_NOMATCH); |
| 214 |
ASSERT (fnmatch ("[a-z]", "//", 0) == FNM_NOMATCH); |
| 215 |
|
| 216 |
ASSERT (fnmatch ("[!a-z]", "", 0) == FNM_NOMATCH); |
| 217 |
ASSERT (fnmatch ("[!a-z]", "a", 0) == FNM_NOMATCH); |
| 218 |
ASSERT (fnmatch ("[!a-z]", "z", 0) == FNM_NOMATCH); |
| 219 |
ASSERT (fnmatch ("[!a-z]", ".", 0) == 0); |
| 220 |
ASSERT (fnmatch ("[!a-z]", "/", 0) == 0); |
| 221 |
ASSERT (fnmatch ("[!a-z]", "az", 0) == FNM_NOMATCH); |
| 222 |
ASSERT (fnmatch ("[!a-z]", "//", 0) == FNM_NOMATCH); |
| 223 |
|
| 224 |
ASSERT (fnmatch ("[[:alnum:]]", "", 0) == FNM_NOMATCH); |
| 225 |
ASSERT (fnmatch ("[[:alnum:]]", "a", 0) == 0); |
| 226 |
ASSERT (fnmatch ("[[:alnum:]]", "z", 0) == 0); |
| 227 |
ASSERT (fnmatch ("[[:alnum:]]", "7", 0) == 0); |
| 228 |
ASSERT (fnmatch ("[[:alnum:]]", ".", 0) == FNM_NOMATCH); |
| 229 |
ASSERT (fnmatch ("[[:alnum:]]", "/", 0) == FNM_NOMATCH); |
| 230 |
ASSERT (fnmatch ("[[:alnum:]]", "az", 0) == FNM_NOMATCH); |
| 231 |
ASSERT (fnmatch ("[[:alnum:]]", "//", 0) == FNM_NOMATCH); |
| 232 |
|
| 233 |
ASSERT (fnmatch ("[[:alpha:]]", "", 0) == FNM_NOMATCH); |
| 234 |
ASSERT (fnmatch ("[[:alpha:]]", "a", 0) == 0); |
| 235 |
ASSERT (fnmatch ("[[:alpha:]]", "z", 0) == 0); |
| 236 |
ASSERT (fnmatch ("[[:alpha:]]", "7", 0) == FNM_NOMATCH); |
| 237 |
ASSERT (fnmatch ("[[:alpha:]]", ".", 0) == FNM_NOMATCH); |
| 238 |
ASSERT (fnmatch ("[[:alpha:]]", "/", 0) == FNM_NOMATCH); |
| 239 |
ASSERT (fnmatch ("[[:alpha:]]", "az", 0) == FNM_NOMATCH); |
| 240 |
ASSERT (fnmatch ("[[:alpha:]]", "//", 0) == FNM_NOMATCH); |
| 241 |
|
| 242 |
ASSERT (fnmatch ("[[:blank:]]", "", 0) == FNM_NOMATCH); |
| 243 |
ASSERT (fnmatch ("[[:blank:]]", "a", 0) == FNM_NOMATCH); |
| 244 |
ASSERT (fnmatch ("[[:blank:]]", "z", 0) == FNM_NOMATCH); |
| 245 |
ASSERT (fnmatch ("[[:blank:]]", "7", 0) == FNM_NOMATCH); |
| 246 |
ASSERT (fnmatch ("[[:blank:]]", " ", 0) == 0); |
| 247 |
ASSERT (fnmatch ("[[:blank:]]", ".", 0) == FNM_NOMATCH); |
| 248 |
ASSERT (fnmatch ("[[:blank:]]", "/", 0) == FNM_NOMATCH); |
| 249 |
ASSERT (fnmatch ("[[:blank:]]", "az", 0) == FNM_NOMATCH); |
| 250 |
ASSERT (fnmatch ("[[:blank:]]", "//", 0) == FNM_NOMATCH); |
| 251 |
|
| 252 |
ASSERT (fnmatch ("[[:cntrl:]]", "", 0) == FNM_NOMATCH); |
| 253 |
ASSERT (fnmatch ("[[:cntrl:]]", "a", 0) == FNM_NOMATCH); |
| 254 |
ASSERT (fnmatch ("[[:cntrl:]]", "z", 0) == FNM_NOMATCH); |
| 255 |
ASSERT (fnmatch ("[[:cntrl:]]", "7", 0) == FNM_NOMATCH); |
| 256 |
ASSERT (fnmatch ("[[:cntrl:]]", "\n", 0) == 0); |
| 257 |
ASSERT (fnmatch ("[[:cntrl:]]", ".", 0) == FNM_NOMATCH); |
| 258 |
ASSERT (fnmatch ("[[:cntrl:]]", "/", 0) == FNM_NOMATCH); |
| 259 |
ASSERT (fnmatch ("[[:cntrl:]]", "az", 0) == FNM_NOMATCH); |
| 260 |
ASSERT (fnmatch ("[[:cntrl:]]", "//", 0) == FNM_NOMATCH); |
| 261 |
|
| 262 |
ASSERT (fnmatch ("[[:digit:]]", "", 0) == FNM_NOMATCH); |
| 263 |
ASSERT (fnmatch ("[[:digit:]]", "a", 0) == FNM_NOMATCH); |
| 264 |
ASSERT (fnmatch ("[[:digit:]]", "z", 0) == FNM_NOMATCH); |
| 265 |
ASSERT (fnmatch ("[[:digit:]]", "7", 0) == 0); |
| 266 |
ASSERT (fnmatch ("[[:digit:]]", ".", 0) == FNM_NOMATCH); |
| 267 |
ASSERT (fnmatch ("[[:digit:]]", "/", 0) == FNM_NOMATCH); |
| 268 |
ASSERT (fnmatch ("[[:digit:]]", "az", 0) == FNM_NOMATCH); |
| 269 |
ASSERT (fnmatch ("[[:digit:]]", "//", 0) == FNM_NOMATCH); |
| 270 |
|
| 271 |
ASSERT (fnmatch ("[[:graph:]]", "", 0) == FNM_NOMATCH); |
| 272 |
ASSERT (fnmatch ("[[:graph:]]", "a", 0) == 0); |
| 273 |
ASSERT (fnmatch ("[[:graph:]]", "z", 0) == 0); |
| 274 |
ASSERT (fnmatch ("[[:graph:]]", "7", 0) == 0); |
| 275 |
ASSERT (fnmatch ("[[:graph:]]", " ", 0) == FNM_NOMATCH); |
| 276 |
ASSERT (fnmatch ("[[:graph:]]", ".", 0) == 0); |
| 277 |
ASSERT (fnmatch ("[[:graph:]]", "/", 0) == 0); |
| 278 |
ASSERT (fnmatch ("[[:graph:]]", "az", 0) == FNM_NOMATCH); |
| 279 |
ASSERT (fnmatch ("[[:graph:]]", "//", 0) == FNM_NOMATCH); |
| 280 |
|
| 281 |
ASSERT (fnmatch ("[[:lower:]]", "", 0) == FNM_NOMATCH); |
| 282 |
ASSERT (fnmatch ("[[:lower:]]", "a", 0) == 0); |
| 283 |
ASSERT (fnmatch ("[[:lower:]]", "z", 0) == 0); |
| 284 |
ASSERT (fnmatch ("[[:lower:]]", "A", 0) == FNM_NOMATCH); |
| 285 |
ASSERT (fnmatch ("[[:lower:]]", "Z", 0) == FNM_NOMATCH); |
| 286 |
ASSERT (fnmatch ("[[:lower:]]", "7", 0) == FNM_NOMATCH); |
| 287 |
ASSERT (fnmatch ("[[:lower:]]", ".", 0) == FNM_NOMATCH); |
| 288 |
ASSERT (fnmatch ("[[:lower:]]", "/", 0) == FNM_NOMATCH); |
| 289 |
ASSERT (fnmatch ("[[:lower:]]", "az", 0) == FNM_NOMATCH); |
| 290 |
ASSERT (fnmatch ("[[:lower:]]", "//", 0) == FNM_NOMATCH); |
| 291 |
|
| 292 |
ASSERT (fnmatch ("[[:print:]]", "", 0) == FNM_NOMATCH); |
| 293 |
ASSERT (fnmatch ("[[:print:]]", "a", 0) == 0); |
| 294 |
ASSERT (fnmatch ("[[:print:]]", "z", 0) == 0); |
| 295 |
ASSERT (fnmatch ("[[:print:]]", "7", 0) == 0); |
| 296 |
ASSERT (fnmatch ("[[:print:]]", " ", 0) == 0); |
| 297 |
ASSERT (fnmatch ("[[:print:]]", ".", 0) == 0); |
| 298 |
ASSERT (fnmatch ("[[:print:]]", "/", 0) == 0); |
| 299 |
ASSERT (fnmatch ("[[:print:]]", "az", 0) == FNM_NOMATCH); |
| 300 |
ASSERT (fnmatch ("[[:print:]]", "//", 0) == FNM_NOMATCH); |
| 301 |
|
| 302 |
ASSERT (fnmatch ("[[:punct:]]", "", 0) == FNM_NOMATCH); |
| 303 |
ASSERT (fnmatch ("[[:punct:]]", "a", 0) == FNM_NOMATCH); |
| 304 |
ASSERT (fnmatch ("[[:punct:]]", "z", 0) == FNM_NOMATCH); |
| 305 |
ASSERT (fnmatch ("[[:punct:]]", "7", 0) == FNM_NOMATCH); |
| 306 |
ASSERT (fnmatch ("[[:punct:]]", ".", 0) == 0); |
| 307 |
ASSERT (fnmatch ("[[:punct:]]", "/", 0) == 0); |
| 308 |
ASSERT (fnmatch ("[[:punct:]]", "az", 0) == FNM_NOMATCH); |
| 309 |
ASSERT (fnmatch ("[[:punct:]]", "//", 0) == FNM_NOMATCH); |
| 310 |
|
| 311 |
ASSERT (fnmatch ("[[:space:]]", "", 0) == FNM_NOMATCH); |
| 312 |
ASSERT (fnmatch ("[[:space:]]", "a", 0) == FNM_NOMATCH); |
| 313 |
ASSERT (fnmatch ("[[:space:]]", "z", 0) == FNM_NOMATCH); |
| 314 |
ASSERT (fnmatch ("[[:space:]]", "7", 0) == FNM_NOMATCH); |
| 315 |
ASSERT (fnmatch ("[[:space:]]", " ", 0) == 0); |
| 316 |
ASSERT (fnmatch ("[[:space:]]", "\t", 0) == 0); |
| 317 |
ASSERT (fnmatch ("[[:space:]]", ".", 0) == FNM_NOMATCH); |
| 318 |
ASSERT (fnmatch ("[[:space:]]", "/", 0) == FNM_NOMATCH); |
| 319 |
ASSERT (fnmatch ("[[:space:]]", "az", 0) == FNM_NOMATCH); |
| 320 |
ASSERT (fnmatch ("[[:space:]]", "//", 0) == FNM_NOMATCH); |
| 321 |
|
| 322 |
ASSERT (fnmatch ("[[:upper:]]", "", 0) == FNM_NOMATCH); |
| 323 |
ASSERT (fnmatch ("[[:upper:]]", "a", 0) == FNM_NOMATCH); |
| 324 |
ASSERT (fnmatch ("[[:upper:]]", "z", 0) == FNM_NOMATCH); |
| 325 |
ASSERT (fnmatch ("[[:upper:]]", "A", 0) == 0); |
| 326 |
ASSERT (fnmatch ("[[:upper:]]", "Z", 0) == 0); |
| 327 |
ASSERT (fnmatch ("[[:upper:]]", "7", 0) == FNM_NOMATCH); |
| 328 |
ASSERT (fnmatch ("[[:upper:]]", ".", 0) == FNM_NOMATCH); |
| 329 |
ASSERT (fnmatch ("[[:upper:]]", "/", 0) == FNM_NOMATCH); |
| 330 |
ASSERT (fnmatch ("[[:upper:]]", "az", 0) == FNM_NOMATCH); |
| 331 |
ASSERT (fnmatch ("[[:upper:]]", "//", 0) == FNM_NOMATCH); |
| 332 |
|
| 333 |
ASSERT (fnmatch ("[[:xdigit:]]", "", 0) == FNM_NOMATCH); |
| 334 |
ASSERT (fnmatch ("[[:xdigit:]]", "a", 0) == 0); |
| 335 |
ASSERT (fnmatch ("[[:xdigit:]]", "F", 0) == 0); |
| 336 |
ASSERT (fnmatch ("[[:xdigit:]]", "z", 0) == FNM_NOMATCH); |
| 337 |
ASSERT (fnmatch ("[[:xdigit:]]", "7", 0) == 0); |
| 338 |
ASSERT (fnmatch ("[[:xdigit:]]", ".", 0) == FNM_NOMATCH); |
| 339 |
ASSERT (fnmatch ("[[:xdigit:]]", "/", 0) == FNM_NOMATCH); |
| 340 |
ASSERT (fnmatch ("[[:xdigit:]]", "az", 0) == FNM_NOMATCH); |
| 341 |
ASSERT (fnmatch ("[[:xdigit:]]", "//", 0) == FNM_NOMATCH); |
| 342 |
|
| 343 |
ASSERT (fnmatch ("[[:alpha:]'[:alpha:]\0]", "a", 0) == FNM_NOMATCH); |
| 344 |
|
| 345 |
ASSERT (fnmatch ("[a[.\0.]]", "a", 0) == FNM_NOMATCH); |
| 346 |
|
| 347 |
/* Verify that an unmatched [ is treated as a literal, as POSIX requires. */ |
| 348 |
ASSERT (fnmatch ("[", "[", 0) == 0); |
| 349 |
ASSERT (fnmatch ("[", "]", 0) == FNM_NOMATCH); |
| 350 |
|
| 351 |
/* The FNM_PATHNAME flag. */ |
| 352 |
|
| 353 |
ASSERT (fnmatch ("x?y", "x/y", 0) == 0); |
| 354 |
ASSERT (fnmatch ("x?y", "x/y", FNM_PATHNAME) == FNM_NOMATCH); |
| 355 |
|
| 356 |
ASSERT (fnmatch ("x*y", "x/y", 0) == 0); |
| 357 |
ASSERT (fnmatch ("x*y", "x/y", FNM_PATHNAME) == FNM_NOMATCH); |
| 358 |
|
| 359 |
ASSERT (fnmatch ("[/-/]", "/", 0) == 0); |
| 360 |
ASSERT (fnmatch ("[/-/]", "/", FNM_PATHNAME) == FNM_NOMATCH); |
| 361 |
ASSERT (fnmatch ("[!-~]", "/", FNM_PATHNAME) == FNM_NOMATCH); |
| 362 |
|
| 363 |
ASSERT (fnmatch ("[[:graph:]]", "/", FNM_PATHNAME) == FNM_NOMATCH); |
| 364 |
ASSERT (fnmatch ("[[:print:]]", "/", FNM_PATHNAME) == FNM_NOMATCH); |
| 365 |
ASSERT (fnmatch ("[[:punct:]]", "/", FNM_PATHNAME) == FNM_NOMATCH); |
| 366 |
|
| 367 |
/* The FNM_NOESCAPE flag. */ |
| 368 |
|
| 369 |
ASSERT (fnmatch ("foo\\.txt", "foo.txt", 0) == 0); |
| 370 |
ASSERT (fnmatch ("foo\\.txt", "foo.txt", FNM_NOESCAPE) == FNM_NOMATCH); |
| 371 |
|
| 372 |
ASSERT (fnmatch ("x?y", "x/y", 0) == 0); |
| 373 |
ASSERT (fnmatch ("x\\?y", "x/y", 0) == FNM_NOMATCH); |
| 374 |
ASSERT (fnmatch ("x\\?y", "x/y", FNM_NOESCAPE) == FNM_NOMATCH); |
| 375 |
ASSERT (fnmatch ("x\\?y", "x?y", 0) == 0); |
| 376 |
ASSERT (fnmatch ("x\\?y", "x?y", FNM_NOESCAPE) == FNM_NOMATCH); |
| 377 |
ASSERT (fnmatch ("x\\?y", "x\\?y", 0) == FNM_NOMATCH); |
| 378 |
ASSERT (fnmatch ("x\\?y", "x\\?y", FNM_NOESCAPE) == 0); |
| 379 |
|
| 380 |
ASSERT (fnmatch ("x*y", "x/y", 0) == 0); |
| 381 |
ASSERT (fnmatch ("x\\*y", "x/y", 0) == FNM_NOMATCH); |
| 382 |
ASSERT (fnmatch ("x\\*y", "x/y", FNM_NOESCAPE) == FNM_NOMATCH); |
| 383 |
ASSERT (fnmatch ("x\\*y", "x*y", 0) == 0); |
| 384 |
ASSERT (fnmatch ("x\\*y", "x*y", FNM_NOESCAPE) == FNM_NOMATCH); |
| 385 |
ASSERT (fnmatch ("x\\*y", "x\\*y", 0) == FNM_NOMATCH); |
| 386 |
ASSERT (fnmatch ("x\\*y", "x\\*y", FNM_NOESCAPE) == 0); |
| 387 |
|
| 388 |
/* The FNM_PERIOD flag. */ |
| 389 |
|
| 390 |
ASSERT (fnmatch ("foo.rc", "foo.rc", 0) == 0); |
| 391 |
ASSERT (fnmatch ("foo.rc", "foo.rc", FNM_PATHNAME) == 0); |
| 392 |
ASSERT (fnmatch ("foo.rc", "foo.rc", FNM_PERIOD) == 0); |
| 393 |
ASSERT (fnmatch ("foo.rc", "foo.rc", FNM_PATHNAME | FNM_PERIOD) == 0); |
| 394 |
ASSERT (fnmatch ("foo?rc", "foo.rc", 0) == 0); |
| 395 |
ASSERT (fnmatch ("foo?rc", "foo.rc", FNM_PATHNAME) == 0); |
| 396 |
ASSERT (fnmatch ("foo?rc", "foo.rc", FNM_PERIOD) == 0); |
| 397 |
ASSERT (fnmatch ("foo?rc", "foo.rc", FNM_PATHNAME | FNM_PERIOD) == 0); |
| 398 |
ASSERT (fnmatch ("foo[[:punct:]]rc", "foo.rc", 0) == 0); |
| 399 |
ASSERT (fnmatch ("foo[[:punct:]]rc", "foo.rc", FNM_PATHNAME) == 0); |
| 400 |
ASSERT (fnmatch ("foo[[:punct:]]rc", "foo.rc", FNM_PERIOD) == 0); |
| 401 |
ASSERT (fnmatch ("foo[[:punct:]]rc", "foo.rc", FNM_PATHNAME | FNM_PERIOD) == 0); |
| 402 |
ASSERT (fnmatch ("foo*rc", "foo.rc", 0) == 0); |
| 403 |
ASSERT (fnmatch ("foo*rc", "foo.rc", FNM_PATHNAME) == 0); |
| 404 |
ASSERT (fnmatch ("foo*rc", "foo.rc", FNM_PERIOD) == 0); |
| 405 |
ASSERT (fnmatch ("foo*rc", "foo.rc", FNM_PATHNAME | FNM_PERIOD) == 0); |
| 406 |
|
| 407 |
ASSERT (fnmatch (".rc", ".rc", 0) == 0); |
| 408 |
ASSERT (fnmatch (".rc", ".rc", FNM_PATHNAME) == 0); |
| 409 |
ASSERT (fnmatch (".rc", ".rc", FNM_PERIOD) == 0); |
| 410 |
ASSERT (fnmatch (".rc", ".rc", FNM_PATHNAME | FNM_PERIOD) == 0); |
| 411 |
ASSERT (fnmatch ("?rc", ".rc", 0) == 0); |
| 412 |
ASSERT (fnmatch ("?rc", ".rc", FNM_PATHNAME) == 0); |
| 413 |
ASSERT (fnmatch ("?rc", ".rc", FNM_PERIOD) == FNM_NOMATCH); |
| 414 |
ASSERT (fnmatch ("?rc", ".rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); |
| 415 |
ASSERT (fnmatch ("[[:punct:]]rc", ".rc", 0) == 0); |
| 416 |
ASSERT (fnmatch ("[[:punct:]]rc", ".rc", FNM_PATHNAME) == 0); |
| 417 |
ASSERT (fnmatch ("[[:punct:]]rc", ".rc", FNM_PERIOD) == FNM_NOMATCH); |
| 418 |
ASSERT (fnmatch ("[[:punct:]]rc", ".rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); |
| 419 |
ASSERT (fnmatch ("*rc", ".rc", 0) == 0); |
| 420 |
ASSERT (fnmatch ("*rc", ".rc", FNM_PATHNAME) == 0); |
| 421 |
ASSERT (fnmatch ("*rc", ".rc", FNM_PERIOD) == FNM_NOMATCH); |
| 422 |
ASSERT (fnmatch ("*rc", ".rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); |
| 423 |
|
| 424 |
ASSERT (fnmatch ("dir/.rc", "dir/.rc", 0) == 0); |
| 425 |
ASSERT (fnmatch ("dir/.rc", "dir/.rc", FNM_PATHNAME) == 0); |
| 426 |
ASSERT (fnmatch ("dir/.rc", "dir/.rc", FNM_PERIOD) == 0); |
| 427 |
ASSERT (fnmatch ("dir/.rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == 0); |
| 428 |
ASSERT (fnmatch ("dir/?rc", "dir/.rc", 0) == 0); |
| 429 |
ASSERT (fnmatch ("dir/?rc", "dir/.rc", FNM_PATHNAME) == 0); |
| 430 |
ASSERT (fnmatch ("dir/?rc", "dir/.rc", FNM_PERIOD) == 0); |
| 431 |
ASSERT (fnmatch ("dir/?rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); |
| 432 |
ASSERT (fnmatch ("dir/[[:punct:]]rc", "dir/.rc", 0) == 0); |
| 433 |
ASSERT (fnmatch ("dir/[[:punct:]]rc", "dir/.rc", FNM_PATHNAME) == 0); |
| 434 |
ASSERT (fnmatch ("dir/[[:punct:]]rc", "dir/.rc", FNM_PERIOD) == 0); |
| 435 |
ASSERT (fnmatch ("dir/[[:punct:]]rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); |
| 436 |
ASSERT (fnmatch ("dir/*rc", "dir/.rc", 0) == 0); |
| 437 |
ASSERT (fnmatch ("dir/*rc", "dir/.rc", FNM_PATHNAME) == 0); |
| 438 |
ASSERT (fnmatch ("dir/*rc", "dir/.rc", FNM_PERIOD) == 0); |
| 439 |
ASSERT (fnmatch ("dir/*rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); |
| 440 |
ASSERT (fnmatch ("*rc", "dir/.rc", 0) == 0); |
| 441 |
ASSERT (fnmatch ("*rc", "dir/.rc", FNM_PATHNAME) == FNM_NOMATCH); |
| 442 |
ASSERT (fnmatch ("*rc", "dir/.rc", FNM_PERIOD) == 0); |
| 443 |
ASSERT (fnmatch ("*rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); |
| 444 |
|
| 445 |
/* The FNM_LEADING_DIR flag (common extension). */ |
| 446 |
#if GNULIB_FNMATCH_GNU && defined FNM_LEADING_DIR |
| 447 |
|
| 448 |
ASSERT (fnmatch ("x", "x", 0) == 0); |
| 449 |
ASSERT (fnmatch ("x", "x", FNM_LEADING_DIR) == 0); |
| 450 |
ASSERT (fnmatch ("x", "x/", 0) == FNM_NOMATCH); |
| 451 |
ASSERT (fnmatch ("x", "x/", FNM_LEADING_DIR) == 0); |
| 452 |
ASSERT (fnmatch ("x", "x/y", 0) == FNM_NOMATCH); |
| 453 |
ASSERT (fnmatch ("x", "x/y", FNM_LEADING_DIR) == 0); |
| 454 |
|
| 455 |
ASSERT (fnmatch ("x?y", "x/y", 0) == 0); |
| 456 |
ASSERT (fnmatch ("x?y", "x/y", FNM_LEADING_DIR) == 0); |
| 457 |
ASSERT (fnmatch ("x?y", "x/y", FNM_PATHNAME) == FNM_NOMATCH); |
| 458 |
ASSERT (fnmatch ("x?y", "x/y", FNM_PATHNAME | FNM_LEADING_DIR) == FNM_NOMATCH); |
| 459 |
ASSERT (fnmatch ("x?y", "x/y/z", FNM_PATHNAME | FNM_LEADING_DIR) == FNM_NOMATCH); |
| 460 |
|
| 461 |
#endif |
| 462 |
|
| 463 |
/* The FNM_CASEFOLD flag (common extension). */ |
| 464 |
#if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD |
| 465 |
|
| 466 |
ASSERT (fnmatch ("xy", "xy", 0) == 0); |
| 467 |
ASSERT (fnmatch ("xy", "xy", FNM_CASEFOLD) == 0); |
| 468 |
ASSERT (fnmatch ("xy", "Xy", 0) == FNM_NOMATCH); |
| 469 |
ASSERT (fnmatch ("xy", "Xy", FNM_CASEFOLD) == 0); |
| 470 |
ASSERT (fnmatch ("xy", "xY", 0) == FNM_NOMATCH); |
| 471 |
ASSERT (fnmatch ("xy", "xY", FNM_CASEFOLD) == 0); |
| 472 |
ASSERT (fnmatch ("xy", "XY", 0) == FNM_NOMATCH); |
| 473 |
ASSERT (fnmatch ("xy", "XY", FNM_CASEFOLD) == 0); |
| 474 |
|
| 475 |
/* Locales other than the "C" locale may order the ASCII letters like this: |
| 476 |
AaBb...Mm...Zz . Seen on FreeBSD and Solaris 11. */ |
| 477 |
if (argc == 1 || strcmp (argv[1], "1") == 0) |
| 478 |
ASSERT (fnmatch ("[a-z]", "M", 0) == FNM_NOMATCH); |
| 479 |
#if !defined GNULIB_defined_fnmatch_function |
| 480 |
ASSERT (fnmatch ("[a-z]", "M", FNM_CASEFOLD) == 0); |
| 481 |
#endif |
| 482 |
if (argc == 1 || strcmp (argv[1], "1") == 0) |
| 483 |
ASSERT (fnmatch ("[A-Z]", "m", 0) == FNM_NOMATCH); |
| 484 |
#if !defined GNULIB_defined_fnmatch_function |
| 485 |
ASSERT (fnmatch ("[A-Z]", "m", FNM_CASEFOLD) == 0); |
| 486 |
#endif |
| 487 |
|
| 488 |
#endif |
| 489 |
|
| 490 |
/* The FNM_EXTMATCH flag (GNU extension). */ |
| 491 |
#if GNULIB_FNMATCH_GNU && defined FNM_EXTMATCH |
| 492 |
|
| 493 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); |
| 494 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 495 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "xy", FNM_EXTMATCH) == 0); |
| 496 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == 0); |
| 497 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == 0); |
| 498 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "xay", FNM_EXTMATCH) == FNM_NOMATCH); |
| 499 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == FNM_NOMATCH); |
| 500 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 501 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 502 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 503 |
ASSERT (fnmatch ("x?($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 504 |
|
| 505 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); |
| 506 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 507 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "xy", FNM_EXTMATCH) == 0); |
| 508 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == 0); |
| 509 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == 0); |
| 510 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "xay", FNM_EXTMATCH) == FNM_NOMATCH); |
| 511 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == FNM_NOMATCH); |
| 512 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 513 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == 0); |
| 514 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == 0); |
| 515 |
ASSERT (fnmatch ("x*($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == 0); |
| 516 |
|
| 517 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); |
| 518 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 519 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "xy", FNM_EXTMATCH) == FNM_NOMATCH); |
| 520 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == 0); |
| 521 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == 0); |
| 522 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "xay", FNM_EXTMATCH) == FNM_NOMATCH); |
| 523 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == FNM_NOMATCH); |
| 524 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 525 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == 0); |
| 526 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == 0); |
| 527 |
ASSERT (fnmatch ("x+($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == 0); |
| 528 |
|
| 529 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); |
| 530 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 531 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "xy", FNM_EXTMATCH) == FNM_NOMATCH); |
| 532 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == 0); |
| 533 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == 0); |
| 534 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "xay", FNM_EXTMATCH) == FNM_NOMATCH); |
| 535 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == FNM_NOMATCH); |
| 536 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 537 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 538 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 539 |
ASSERT (fnmatch ("x@($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 540 |
|
| 541 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); |
| 542 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 543 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "xy", FNM_EXTMATCH) == 0); |
| 544 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 545 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == FNM_NOMATCH); |
| 546 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "xay", FNM_EXTMATCH) == 0); |
| 547 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == 0); |
| 548 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == 0); |
| 549 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == 0); |
| 550 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == 0); |
| 551 |
ASSERT (fnmatch ("x!($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == 0); |
| 552 |
|
| 553 |
ASSERT (fnmatch ("**(!()", "**(!()", FNM_EXTMATCH) == 0); |
| 554 |
|
| 555 |
#endif |
| 556 |
|
| 557 |
/* Verify that the test cases from fnmatch.m4 are really working. */ |
| 558 |
{ |
| 559 |
char const *Apat = 'A' < '\\' ? "[A-\\\\]" : "[\\\\-A]"; |
| 560 |
char const *apat = 'a' < '\\' ? "[a-\\\\]" : "[\\\\-a]"; |
| 561 |
static char const A_1[] = { 'A' - 1, 0 }; |
| 562 |
static char const A01[] = { 'A' + 1, 0 }; |
| 563 |
static char const a_1[] = { 'a' - 1, 0 }; |
| 564 |
static char const a01[] = { 'a' + 1, 0 }; |
| 565 |
static char const bs_1[] = { '\\' - 1, 0 }; |
| 566 |
static char const bs01[] = { '\\' + 1, 0 }; |
| 567 |
/* These are sanity checks. They all succeed on current platforms. */ |
| 568 |
ASSERT (fnmatch ("a*", "", 0) == FNM_NOMATCH); |
| 569 |
ASSERT (fnmatch ("a*", "abc", 0) == 0); |
| 570 |
ASSERT (fnmatch ("d*/*1", "d/s/1", FNM_PATHNAME) == FNM_NOMATCH); |
| 571 |
ASSERT (fnmatch ("a\\bc", "abc", 0) == 0); |
| 572 |
ASSERT (fnmatch ("a\\bc", "abc", FNM_NOESCAPE) == FNM_NOMATCH); |
| 573 |
ASSERT (fnmatch ("*x", ".x", 0) == 0); |
| 574 |
ASSERT (fnmatch ("*x", ".x", FNM_PERIOD) == FNM_NOMATCH); |
| 575 |
if (argc == 1 || strcmp (argv[1], "1") == 0) |
| 576 |
{ |
| 577 |
/* glibc bug <https://sourceware.org/bugzilla/show_bug.cgi?id=361> |
| 578 |
exists in glibc 2.3.3, fixed in glibc 2.5. */ |
| 579 |
ASSERT (fnmatch (Apat, "\\", 0) == 0); |
| 580 |
ASSERT (fnmatch (Apat, "A", 0) == 0); |
| 581 |
ASSERT (fnmatch (apat, "\\", 0) == 0); |
| 582 |
ASSERT (fnmatch (apat, "a", 0) == 0); |
| 583 |
ASSERT (fnmatch (Apat, A_1, 0) == ('A' < '\\' ? FNM_NOMATCH : 0)); |
| 584 |
ASSERT (fnmatch (apat, a_1, 0) == ('a' < '\\' ? FNM_NOMATCH : 0)); |
| 585 |
ASSERT (fnmatch (Apat, A01, 0) == ('A' < '\\' ? 0 : FNM_NOMATCH)); |
| 586 |
ASSERT (fnmatch (apat, a01, 0) == ('a' < '\\' ? 0 : FNM_NOMATCH)); |
| 587 |
ASSERT (fnmatch (Apat, bs_1, 0) == ('A' < '\\' ? 0 : FNM_NOMATCH)); |
| 588 |
ASSERT (fnmatch (apat, bs_1, 0) == ('a' < '\\' ? 0 : FNM_NOMATCH)); |
| 589 |
ASSERT (fnmatch (Apat, bs01, 0) == ('A' < '\\' ? FNM_NOMATCH : 0)); |
| 590 |
ASSERT (fnmatch (apat, bs01, 0) == ('a' < '\\' ? FNM_NOMATCH : 0)); |
| 591 |
} |
| 592 |
/* glibc bug <https://sourceware.org/bugzilla/show_bug.cgi?id=12378> |
| 593 |
exists in glibc 2.12, fixed in glibc 2.13. */ |
| 594 |
ASSERT (fnmatch ("[/b", "[/b", 0) == 0); |
| 595 |
/* This test fails on FreeBSD 13.2, NetBSD 9.3, Cygwin 3.4.6. */ |
| 596 |
ASSERT (fnmatch ("[[:alnum:]]", "a", 0) == 0); |
| 597 |
#if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD |
| 598 |
ASSERT (fnmatch ("xxXX", "xXxX", FNM_CASEFOLD) == 0); |
| 599 |
#endif |
| 600 |
#if GNULIB_FNMATCH_GNU && defined FNM_EXTMATCH |
| 601 |
ASSERT (fnmatch ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH) == 0); |
| 602 |
#endif |
| 603 |
#if GNULIB_FNMATCH_GNU && defined FNM_FILE_NAME |
| 604 |
ASSERT (fnmatch ("d*/*1", "d/s/1", FNM_FILE_NAME) == FNM_NOMATCH); |
| 605 |
ASSERT (fnmatch ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR) == 0); |
| 606 |
ASSERT (fnmatch ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR) == 0); |
| 607 |
ASSERT (fnmatch ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR) == 0); |
| 608 |
#endif |
| 609 |
} |
| 610 |
|
| 611 |
/* Locale specific recognition of multibyte characters. */ |
| 612 |
|
| 613 |
if (argc > 1) |
| 614 |
switch (argv[1][0]) |
| 615 |
{ |
| 616 |
case '1': |
| 617 |
/* C or POSIX locale. */ |
| 618 |
return test_exit_status; |
| 619 |
|
| 620 |
case '2': |
| 621 |
/* Locale encoding is ISO-8859-1 or ISO-8859-15. */ |
| 622 |
|
| 623 |
ASSERT (fnmatch ("x?y", "x\374y", 0) == 0); /* "xüy" */ |
| 624 |
ASSERT (fnmatch ("x?y", "x\337y", 0) == 0); /* "xßy" */ |
| 625 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 626 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\330y", 0) == 0); |
| 627 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 628 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\330y", 0) == 0); |
| 629 |
#if !(defined __FreeBSD__ || defined __DragonFly__) |
| 630 |
/* U+00B8 CEDILLA */ |
| 631 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\270y", 0) == 0); |
| 632 |
#endif |
| 633 |
/* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ |
| 634 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\377y", 0) == 0); |
| 635 |
#if !(defined __FreeBSD__ || defined __DragonFly__) |
| 636 |
/* U+00B8 CEDILLA */ |
| 637 |
ASSERT (fnmatch ("x[[:print:]]y", "x\270y", 0) == 0); |
| 638 |
#endif |
| 639 |
#if !(defined __FreeBSD__ || defined __DragonFly__) |
| 640 |
/* U+00BF INVERTED QUESTION MARK */ |
| 641 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\277y", 0) == 0); |
| 642 |
#endif |
| 643 |
/* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ |
| 644 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\311y", 0) == 0); |
| 645 |
/* U+00D7 MULTIPLICATION SIGN */ |
| 646 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\327y", 0) == FNM_NOMATCH); |
| 647 |
/* U+00D7 MULTIPLICATION SIGN */ |
| 648 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\327y", 0) == FNM_NOMATCH); |
| 649 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 650 |
ASSERT (fnmatch ("x[[:blank:]]y", "x\330y", 0) == FNM_NOMATCH); |
| 651 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 652 |
ASSERT (fnmatch ("x[[:cntrl:]]y", "x\330y", 0) == FNM_NOMATCH); |
| 653 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 654 |
ASSERT (fnmatch ("x[[:digit:]]y", "x\330y", 0) == FNM_NOMATCH); |
| 655 |
/* U+00B2 SUPERSCRIPT TWO */ |
| 656 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\262y", 0) == FNM_NOMATCH); |
| 657 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 658 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\330y", 0) == FNM_NOMATCH); |
| 659 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 660 |
ASSERT (fnmatch ("x[[:space:]]y", "x\330y", 0) == FNM_NOMATCH); |
| 661 |
/* U+00B2 SUPERSCRIPT TWO */ |
| 662 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\262y", 0) == FNM_NOMATCH); |
| 663 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 664 |
ASSERT (fnmatch ("x[[:xdigit:]]y", "x\330y", 0) == FNM_NOMATCH); |
| 665 |
|
| 666 |
#if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD |
| 667 |
/* "Höhle" */ |
| 668 |
ASSERT (fnmatch ("H\366hle", "H\326hLe", FNM_CASEFOLD) == 0); |
| 669 |
ASSERT (fnmatch ("H\326hLe", "H\366hle", FNM_CASEFOLD) == 0); |
| 670 |
ASSERT (fnmatch ("H\326hle", "H\366hLe", FNM_CASEFOLD) == 0); |
| 671 |
ASSERT (fnmatch ("H\366hLe", "H\326hle", FNM_CASEFOLD) == 0); |
| 672 |
#endif |
| 673 |
|
| 674 |
return test_exit_status; |
| 675 |
|
| 676 |
case '3': |
| 677 |
/* Locale encoding is UTF-8. */ |
| 678 |
|
| 679 |
ASSERT (fnmatch ("x?y", "x\303\274y", 0) == 0); /* "xüy" */ |
| 680 |
ASSERT (fnmatch ("x?y", "x\303\237y", 0) == 0); /* "xßy" */ |
| 681 |
ASSERT (fnmatch ("x?y", "x\360\237\230\213y", 0) == 0); /* "x😋y" */ |
| 682 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 683 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\305\201y", 0) == 0); |
| 684 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) |
| 685 |
/* U+10330 GOTHIC LETTER AHSA */ |
| 686 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\360\220\214\260y", 0) == 0); |
| 687 |
#endif |
| 688 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 689 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\305\201y", 0) == 0); |
| 690 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) |
| 691 |
/* U+10330 GOTHIC LETTER AHSA */ |
| 692 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\360\220\214\260y", 0) == 0); |
| 693 |
#endif |
| 694 |
/* U+00B8 CEDILLA */ |
| 695 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\302\270y", 0) == 0); |
| 696 |
#if !defined __sun |
| 697 |
/* U+20000 <CJK Ideograph> */ |
| 698 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\360\240\200\200y", 0) == 0); |
| 699 |
#endif |
| 700 |
/* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ |
| 701 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\303\277y", 0) == 0); |
| 702 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) |
| 703 |
/* U+10441 DESERET SMALL LETTER EF */ |
| 704 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\360\220\221\201y", 0) == 0); |
| 705 |
#endif |
| 706 |
/* U+00B8 CEDILLA */ |
| 707 |
ASSERT (fnmatch ("x[[:print:]]y", "x\302\270y", 0) == 0); |
| 708 |
#if !defined __sun |
| 709 |
/* U+20000 <CJK Ideograph> */ |
| 710 |
ASSERT (fnmatch ("x[[:print:]]y", "x\360\240\200\200y", 0) == 0); |
| 711 |
#endif |
| 712 |
/* U+00BF INVERTED QUESTION MARK */ |
| 713 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\302\277y", 0) == 0); |
| 714 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) |
| 715 |
/* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ |
| 716 |
if (iswpunct (0x1D100)) |
| 717 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\360\235\204\200y", 0) == 0); |
| 718 |
#endif |
| 719 |
/* U+3000 IDEOGRAPHIC SPACE */ |
| 720 |
ASSERT (fnmatch ("x[[:space:]]y", "x\343\200\200y", 0) == 0); |
| 721 |
/* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ |
| 722 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\320\251y", 0) == 0); |
| 723 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) |
| 724 |
/* U+10419 DESERET CAPITAL LETTER EF */ |
| 725 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\360\220\220\231y", 0) == 0); |
| 726 |
#endif |
| 727 |
/* U+00D7 MULTIPLICATION SIGN */ |
| 728 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\303\227y", 0) == FNM_NOMATCH); |
| 729 |
/* U+00D7 MULTIPLICATION SIGN */ |
| 730 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\303\227y", 0) == FNM_NOMATCH); |
| 731 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 732 |
ASSERT (fnmatch ("x[[:blank:]]y", "x\305\201y", 0) == FNM_NOMATCH); |
| 733 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 734 |
ASSERT (fnmatch ("x[[:cntrl:]]y", "x\305\201y", 0) == FNM_NOMATCH); |
| 735 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 736 |
ASSERT (fnmatch ("x[[:digit:]]y", "x\305\201y", 0) == FNM_NOMATCH); |
| 737 |
/* U+2002 EN SPACE */ |
| 738 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\342\200\202y", 0) == FNM_NOMATCH); |
| 739 |
/* U+00B2 SUPERSCRIPT TWO */ |
| 740 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\302\262y", 0) == FNM_NOMATCH); |
| 741 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 742 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\305\201y", 0) == FNM_NOMATCH); |
| 743 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 744 |
ASSERT (fnmatch ("x[[:space:]]y", "x\305\201y", 0) == FNM_NOMATCH); |
| 745 |
/* U+00B2 SUPERSCRIPT TWO */ |
| 746 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\302\262y", 0) == FNM_NOMATCH); |
| 747 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 748 |
ASSERT (fnmatch ("x[[:xdigit:]]y", "x\305\201y", 0) == FNM_NOMATCH); |
| 749 |
|
| 750 |
#if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD |
| 751 |
/* "özgür" */ |
| 752 |
{ |
| 753 |
/* Some platforms, e.g. MSVC 14, lack the upper/lower mappings for |
| 754 |
these wide characters in the *.65001 locales. */ |
| 755 |
mbstate_t state; |
| 756 |
wchar_t wc; |
| 757 |
memset (&state, 0, sizeof (mbstate_t)); |
| 758 |
if (mbrtowc (&wc, "\303\274", 2, &state) == 2 |
| 759 |
&& towupper (wc) != wc) |
| 760 |
{ |
| 761 |
ASSERT (fnmatch ("\303\266zg\303\274r", "\303\226ZG\303\234R", FNM_CASEFOLD) == 0); |
| 762 |
ASSERT (fnmatch ("\303\226ZG\303\234R", "\303\266zg\303\274r", FNM_CASEFOLD) == 0); |
| 763 |
ASSERT (fnmatch ("\303\266Zg\303\234r", "\303\226zG\303\274R", FNM_CASEFOLD) == 0); |
| 764 |
ASSERT (fnmatch ("\303\226zG\303\274R", "\303\266Zg\303\234r", FNM_CASEFOLD) == 0); |
| 765 |
} |
| 766 |
} |
| 767 |
#endif |
| 768 |
|
| 769 |
return test_exit_status; |
| 770 |
|
| 771 |
case '4': |
| 772 |
/* Locale encoding is EUC-JP. */ |
| 773 |
|
| 774 |
ASSERT (fnmatch ("x?y", "x\306\374y", 0) == 0); /* "x日y" */ |
| 775 |
ASSERT (fnmatch ("x?y", "x\313\334y", 0) == 0); /* "x本y" */ |
| 776 |
ASSERT (fnmatch ("x?y", "x\270\354y", 0) == 0); /* "x語y" */ |
| 777 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) |
| 778 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 779 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\217\251\250y", 0) == 0); |
| 780 |
#endif |
| 781 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) |
| 782 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 783 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\217\251\250y", 0) == 0); |
| 784 |
#endif |
| 785 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) |
| 786 |
/* U+00B8 CEDILLA */ |
| 787 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\217\242\261y", 0) == 0); |
| 788 |
#endif |
| 789 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) |
| 790 |
/* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ |
| 791 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\217\253\363y", 0) == 0); |
| 792 |
#endif |
| 793 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) |
| 794 |
/* U+00B8 CEDILLA */ |
| 795 |
ASSERT (fnmatch ("x[[:print:]]y", "x\217\242\261y", 0) == 0); |
| 796 |
#endif |
| 797 |
#if !(defined __FreeBSD__ || defined __DragonFly__) |
| 798 |
/* U+00D7 MULTIPLICATION SIGN */ |
| 799 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\241\337y", 0) == 0); |
| 800 |
#endif |
| 801 |
#if !(defined __FreeBSD__ || defined __DragonFly__) |
| 802 |
/* U+3000 IDEOGRAPHIC SPACE */ |
| 803 |
ASSERT (fnmatch ("x[[:space:]]y", "x\241\241y", 0) == 0); |
| 804 |
#endif |
| 805 |
#if !(defined __FreeBSD__ || defined __DragonFly__) |
| 806 |
/* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ |
| 807 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\247\273y", 0) == 0); |
| 808 |
#endif |
| 809 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 810 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 811 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 812 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 813 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 814 |
ASSERT (fnmatch ("x[[:blank:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 815 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 816 |
ASSERT (fnmatch ("x[[:cntrl:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 817 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 818 |
ASSERT (fnmatch ("x[[:digit:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 819 |
/* U+3000 IDEOGRAPHIC SPACE */ |
| 820 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\241\241y", 0) == FNM_NOMATCH); |
| 821 |
/* U+3073 HIRAGANA LETTER BI */ |
| 822 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\244\323y", 0) == FNM_NOMATCH); |
| 823 |
/* U+00DF LATIN SMALL LETTER SHARP S */ |
| 824 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\217\251\316y", 0) == FNM_NOMATCH); |
| 825 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 826 |
ASSERT (fnmatch ("x[[:space:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 827 |
/* U+3073 HIRAGANA LETTER BI */ |
| 828 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\244\323y", 0) == FNM_NOMATCH); |
| 829 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 830 |
ASSERT (fnmatch ("x[[:xdigit:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 831 |
|
| 832 |
#if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD |
| 833 |
/* "özgür" */ |
| 834 |
{ |
| 835 |
/* Some platforms, e.g. macOS 12.5 and NetBSD 9.3, lack the |
| 836 |
upper/lower mappings for these wide characters in the ja_JP.eucJP |
| 837 |
locale. */ |
| 838 |
mbstate_t state; |
| 839 |
wchar_t wc; |
| 840 |
memset (&state, 0, sizeof (mbstate_t)); |
| 841 |
if (mbrtowc (&wc, "\217\253\344", 3, &state) == 3 |
| 842 |
&& towupper (wc) != wc) |
| 843 |
{ |
| 844 |
ASSERT (fnmatch ("\217\253\323zg\217\253\344r", "\217\252\323ZG\217\252\344R", FNM_CASEFOLD) == 0); |
| 845 |
ASSERT (fnmatch ("\217\252\323ZG\217\252\344R", "\217\253\323zg\217\253\344r", FNM_CASEFOLD) == 0); |
| 846 |
ASSERT (fnmatch ("\217\253\323Zg\217\252\344r", "\217\252\323zG\217\253\344R", FNM_CASEFOLD) == 0); |
| 847 |
ASSERT (fnmatch ("\217\252\323zG\217\253\344R", "\217\253\323Zg\217\252\344r", FNM_CASEFOLD) == 0); |
| 848 |
} |
| 849 |
} |
| 850 |
#endif |
| 851 |
|
| 852 |
return test_exit_status; |
| 853 |
|
| 854 |
case '5': |
| 855 |
/* Locale encoding is GB18030. */ |
| 856 |
#if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) |
| 857 |
if (test_exit_status != EXIT_SUCCESS) |
| 858 |
return test_exit_status; |
| 859 |
fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); |
| 860 |
return 77; |
| 861 |
#endif |
| 862 |
|
| 863 |
ASSERT (fnmatch ("x?y", "x\250\271y", 0) == 0); /* "xüy" */ |
| 864 |
ASSERT (fnmatch ("x?y", "x\201\060\211\070y", 0) == 0); /* "xßy" */ |
| 865 |
ASSERT (fnmatch ("x?y", "x\224\071\375\067y", 0) == 0); /* "x😋y" */ |
| 866 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) |
| 867 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 868 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\201\060\221\071y", 0) == 0); |
| 869 |
#endif |
| 870 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) |
| 871 |
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ |
| 872 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\201\060\221\071y", 0) == 0); |
| 873 |
#endif |
| 874 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) |
| 875 |
/* U+00B8 CEDILLA */ |
| 876 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\201\060\206\060y", 0) == 0); |
| 877 |
#endif |
| 878 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) |
| 879 |
/* U+20000 <CJK Ideograph> */ |
| 880 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\225\062\202\066y", 0) == 0); |
| 881 |
#endif |
| 882 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) |
| 883 |
/* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ |
| 884 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\201\060\213\067y", 0) == 0); |
| 885 |
#endif |
| 886 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) |
| 887 |
/* U+10441 DESERET SMALL LETTER EF */ |
| 888 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\220\060\355\071y", 0) == 0); |
| 889 |
#endif |
| 890 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) |
| 891 |
/* U+00B8 CEDILLA */ |
| 892 |
ASSERT (fnmatch ("x[[:print:]]y", "x\201\060\206\060y", 0) == 0); |
| 893 |
#endif |
| 894 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) |
| 895 |
/* U+20000 <CJK Ideograph> */ |
| 896 |
ASSERT (fnmatch ("x[[:print:]]y", "x\225\062\202\066y", 0) == 0); |
| 897 |
#endif |
| 898 |
#if !(defined __FreeBSD__ || defined __DragonFly__ || defined __illumos__) |
| 899 |
/* U+00D7 MULTIPLICATION SIGN */ |
| 900 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\241\301y", 0) == 0); |
| 901 |
#endif |
| 902 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) |
| 903 |
/* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ |
| 904 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\224\062\273\064y", 0) == 0); |
| 905 |
#endif |
| 906 |
#if !(defined __FreeBSD__ || defined __DragonFly__) |
| 907 |
/* U+3000 IDEOGRAPHIC SPACE */ |
| 908 |
ASSERT (fnmatch ("x[[:space:]]y", "x\241\241y", 0) == 0); |
| 909 |
#endif |
| 910 |
#if !(defined __FreeBSD__ || defined __DragonFly__) |
| 911 |
/* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ |
| 912 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\247\273y", 0) == 0); |
| 913 |
#endif |
| 914 |
#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) |
| 915 |
/* U+10419 DESERET CAPITAL LETTER EF */ |
| 916 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\220\060\351\071y", 0) == 0); |
| 917 |
#endif |
| 918 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 919 |
ASSERT (fnmatch ("x[[:alnum:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 920 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 921 |
ASSERT (fnmatch ("x[[:alpha:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 922 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 923 |
ASSERT (fnmatch ("x[[:blank:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 924 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 925 |
ASSERT (fnmatch ("x[[:cntrl:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 926 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 927 |
ASSERT (fnmatch ("x[[:digit:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 928 |
/* U+3000 IDEOGRAPHIC SPACE */ |
| 929 |
ASSERT (fnmatch ("x[[:graph:]]y", "x\241\241y", 0) == FNM_NOMATCH); |
| 930 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 931 |
ASSERT (fnmatch ("x[[:lower:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 932 |
/* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ |
| 933 |
ASSERT (fnmatch ("x[[:punct:]]y", "x\201\060\211\061y", 0) == FNM_NOMATCH); |
| 934 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 935 |
ASSERT (fnmatch ("x[[:space:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 936 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 937 |
ASSERT (fnmatch ("x[[:upper:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 938 |
/* U+3001 IDEOGRAPHIC COMMA */ |
| 939 |
ASSERT (fnmatch ("x[[:xdigit:]]y", "x\241\242y", 0) == FNM_NOMATCH); |
| 940 |
|
| 941 |
#if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD |
| 942 |
/* "özgür" */ |
| 943 |
{ |
| 944 |
/* Some platforms, e.g. FreeBSD 13.2 and Solaris 11.4, lack the |
| 945 |
upper/lower mappings for these wide characters in the zh_CN.GB18030 |
| 946 |
locale. */ |
| 947 |
mbstate_t state; |
| 948 |
wchar_t wc; |
| 949 |
memset (&state, 0, sizeof (mbstate_t)); |
| 950 |
if (mbrtowc (&wc, "\201\060\213\062", 4, &state) == 4 |
| 951 |
&& towupper (wc) != wc) |
| 952 |
{ |
| 953 |
ASSERT (fnmatch ("\201\060\213\062zg\250\271r", "\201\060\211\060ZG\201\060\211\065R", FNM_CASEFOLD) == 0); |
| 954 |
ASSERT (fnmatch ("\201\060\211\060ZG\201\060\211\065R", "\201\060\213\062zg\250\271r", FNM_CASEFOLD) == 0); |
| 955 |
ASSERT (fnmatch ("\201\060\213\062Zg\201\060\211\065r", "\201\060\211\060zG\250\271R", FNM_CASEFOLD) == 0); |
| 956 |
ASSERT (fnmatch ("\201\060\211\060zG\250\271R", "\201\060\213\062Zg\201\060\211\065r", FNM_CASEFOLD) == 0); |
| 957 |
} |
| 958 |
} |
| 959 |
#endif |
| 960 |
|
| 961 |
return test_exit_status; |
| 962 |
} |
| 963 |
|
| 964 |
return 1; |
| 965 |
} |