summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2026-09-21 09:15:22 -0400
committerRich Felker <dalias@aerifal.cx>2026-09-21 09:15:22 -0400
commitc4e1bb3994c14ed5112c894d15a451bf00f0d501 (patch)
treee1d628db0ce713d5d2076d83e3fa75ca0a1088a4
parentbe5ba5695df9197365cdb1c95b12fa423059ce34 (diff)
downloadmusl-master.tar.gz
fnmatch: fix FNM_PERIOD failure of escaped '.' to match leading '.'HEADmaster
the new condition also allows forward progress into ordinary matching if the pattern begins with a backslash. this is fine independent of FNM_NOESCAPE and independent of what follows the backslash; if FNM_NOESCAPE is active, the backslash is literal and will not match. if FNM_NOESCAPE is not active, the pattern beginning with a backslash ensures that the first character is literal.
-rw-r--r--src/regex/fnmatch.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/regex/fnmatch.c b/src/regex/fnmatch.c
index 978fff88..ae3c1c24 100644
--- a/src/regex/fnmatch.c
+++ b/src/regex/fnmatch.c
@@ -168,7 +168,7 @@ static int fnmatch_internal(const char *pat, size_t m, const char *str, size_t n
int c, k, kfold;
if (flags & FNM_PERIOD) {
- if (*str == '.' && *pat != '.')
+ if (*str == '.' && *pat != '.' && *pat != '\\')
return FNM_NOMATCH;
}
for (;;) {