diff options
| author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2026-04-12 16:41:29 +0300 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2026-04-16 10:42:13 +0100 |
| commit | 36d76efaa9c10f22925eb94a9d0883cb24a13bd8 (patch) | |
| tree | 6a1c4849744f6ec8b564a7064290c93e1964bc4a | |
| parent | b9a1b0db1d7d455278611efb1d63c96675b15b67 (diff) | |
| download | busybox-w32-36d76efaa9c10f22925eb94a9d0883cb24a13bd8.tar.gz busybox-w32-36d76efaa9c10f22925eb94a9d0883cb24a13bd8.tar.bz2 busybox-w32-36d76efaa9c10f22925eb94a9d0883cb24a13bd8.zip | |
win32: fnmatch.c: use isactype insead of switch
This preserves the original semantics where only ASCII chars are
tested, and unknown class name is considered known-but-unmatched name,
which is different than the equivalent wctype code just above.
The ASCII test is redundant, at least on windows - where all the
class tests (isalnum, isupper, etc) can only return true for ASCII
values, but nevertheless it's kept as the original semantics.
| -rw-r--r-- | win32/fnmatch.c | 60 |
1 files changed, 9 insertions, 51 deletions
diff --git a/win32/fnmatch.c b/win32/fnmatch.c index b25871216..c0c8f22f9 100644 --- a/win32/fnmatch.c +++ b/win32/fnmatch.c | |||
| @@ -373,57 +373,15 @@ internal_fnmatch (const char *pattern, const char *string, | |||
| 373 | if (__iswctype (__btowc ((unsigned char) *n), wt)) | 373 | if (__iswctype (__btowc ((unsigned char) *n), wt)) |
| 374 | goto matched; | 374 | goto matched; |
| 375 | # else | 375 | # else |
| 376 | switch (actype(str)) { | 376 | /* note: the equivalent wctype code above returns |
| 377 | case CCLASS_ALNUM: | 377 | * FNM_NOMATCH for unknown name, while here we consider |
| 378 | if (ISALNUM ((unsigned char) *n)) | 378 | * it as simply non-matched class (and only if ASCII). |
| 379 | goto matched; | 379 | */ |
| 380 | break; | 380 | if (ISASCII((unsigned char) *n)) |
| 381 | case CCLASS_ALPHA: | 381 | if (isactype((unsigned char) *n, actype(str))) |
| 382 | if (ISALPHA ((unsigned char) *n)) | 382 | goto matched; |
| 383 | goto matched; | 383 | |
| 384 | break; | 384 | c = *p++; |
| 385 | case CCLASS_BLANK: | ||
| 386 | if (ISBLANK ((unsigned char) *n)) | ||
| 387 | goto matched; | ||
| 388 | break; | ||
| 389 | case CCLASS_CNTRL: | ||
| 390 | if (ISCNTRL ((unsigned char) *n)) | ||
| 391 | goto matched; | ||
| 392 | break; | ||
| 393 | case CCLASS_DIGIT: | ||
| 394 | if (ISDIGIT ((unsigned char) *n)) | ||
| 395 | goto matched; | ||
| 396 | break; | ||
| 397 | case CCLASS_GRAPH: | ||
| 398 | if (ISGRAPH ((unsigned char) *n)) | ||
| 399 | goto matched; | ||
| 400 | break; | ||
| 401 | case CCLASS_LOWER: | ||
| 402 | if (ISLOWER ((unsigned char) *n)) | ||
| 403 | goto matched; | ||
| 404 | break; | ||
| 405 | case CCLASS_PRINT: | ||
| 406 | if (ISPRINT ((unsigned char) *n)) | ||
| 407 | goto matched; | ||
| 408 | break; | ||
| 409 | case CCLASS_PUNCT: | ||
| 410 | if (ISPUNCT ((unsigned char) *n)) | ||
| 411 | goto matched; | ||
| 412 | break; | ||
| 413 | case CCLASS_SPACE: | ||
| 414 | if (ISSPACE ((unsigned char) *n)) | ||
| 415 | goto matched; | ||
| 416 | break; | ||
| 417 | case CCLASS_UPPER: | ||
| 418 | if (ISUPPER ((unsigned char) *n)) | ||
| 419 | goto matched; | ||
| 420 | break; | ||
| 421 | case CCLASS_XDIGIT: | ||
| 422 | if (ISXDIGIT ((unsigned char) *n)) | ||
| 423 | goto matched; | ||
| 424 | break; | ||
| 425 | } | ||
| 426 | c = *p++; | ||
| 427 | # endif | 385 | # endif |
| 428 | } | 386 | } |
| 429 | else if (c == '\0') | 387 | else if (c == '\0') |
