diff options
author | Ron Yorston <rmy@pobox.com> | 2022-06-23 16:05:17 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-06-23 16:05:17 +0100 |
commit | 6c19fb9008e2dcd7a2d4ce42f618ec2079b1230f (patch) | |
tree | 0b6694dbc72da8e77bcc679ba8235607f91261d5 /win32 | |
parent | 31467ddfcbbc433ed9ceff2eae2a359d0ca1e6d5 (diff) | |
download | busybox-w32-6c19fb9008e2dcd7a2d4ce42f618ec2079b1230f.tar.gz busybox-w32-6c19fb9008e2dcd7a2d4ce42f618ec2079b1230f.tar.bz2 busybox-w32-6c19fb9008e2dcd7a2d4ce42f618ec2079b1230f.zip |
win32: bug fix in fnmatch(3)
A user reports:
Here is the shell script that causes me problems:
var=foo:bar
echo ${var#*[[:space:]]}
What expect I to see echoed is foo:bar, however what I see
bar. It seems that the [[:space:]] character class is matching
the colon character in addition to whitespace characters. I
see the same problem with the [[:blank:]] character class.
This is due to a bug in the WIN32 implementation of fnmatch(3)
which is derived from an old snapshot of glibc code (glibc commit
7814856974 from 1999-09-12). The bug was fixed in glibc by commit
83b1b6d8fa of 2000-07-04.
Apply the equivalent fix to our version.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/fnmatch.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/win32/fnmatch.c b/win32/fnmatch.c index 7d8fde6a2..77b54c5f5 100644 --- a/win32/fnmatch.c +++ b/win32/fnmatch.c | |||
@@ -423,6 +423,7 @@ internal_fnmatch (const char *pattern, const char *string, | |||
423 | goto matched; | 423 | goto matched; |
424 | break; | 424 | break; |
425 | } | 425 | } |
426 | c = *p++; | ||
426 | # endif | 427 | # endif |
427 | } | 428 | } |
428 | else if (c == '\0') | 429 | else if (c == '\0') |
@@ -463,13 +464,14 @@ internal_fnmatch (const char *pattern, const char *string, | |||
463 | 464 | ||
464 | matched: | 465 | matched: |
465 | /* Skip the rest of the [...] that already matched. */ | 466 | /* Skip the rest of the [...] that already matched. */ |
466 | while (c != ']') | 467 | do |
467 | { | 468 | { |
469 | c = *p++; | ||
470 | |||
468 | if (c == '\0') | 471 | if (c == '\0') |
469 | /* [... (unterminated) loses. */ | 472 | /* [... (unterminated) loses. */ |
470 | return FNM_NOMATCH; | 473 | return FNM_NOMATCH; |
471 | 474 | ||
472 | c = *p++; | ||
473 | if (!(flags & FNM_NOESCAPE) && c == '\\') | 475 | if (!(flags & FNM_NOESCAPE) && c == '\\') |
474 | { | 476 | { |
475 | if (*p == '\0') | 477 | if (*p == '\0') |
@@ -487,6 +489,7 @@ internal_fnmatch (const char *pattern, const char *string, | |||
487 | c = *p; | 489 | c = *p; |
488 | } | 490 | } |
489 | } | 491 | } |
492 | while (c != ']'); | ||
490 | if (not) | 493 | if (not) |
491 | return FNM_NOMATCH; | 494 | return FNM_NOMATCH; |
492 | } | 495 | } |