From 4679bde3e1ceca63d6eb4de5ce41c996405e61aa Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Mon, 29 Jul 2019 09:03:40 -0400 Subject: [PATCH] PR/81: oldping: Fix range matching issue where we were comparing with the range character instead of the start of range. --- glob.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/glob.c b/glob.c index c2bc95f8..dbdfa1e7 100644 --- a/glob.c +++ b/glob.c @@ -100,7 +100,7 @@ static int Lstat (const char *, struct stat *); static int Stat (const char *, struct stat *sb); static Char *Strchr (Char *, int); #ifdef DEBUG -static void qprintf (const Char *); +static void qprintf (const char *, const Char *); #endif #define DOLLAR '$' @@ -254,19 +254,20 @@ Strchr(Char *str, int ch) #ifdef DEBUG static void -qprintf(const Char *s) +qprintf(const char *pre, const Char *s) { const Char *p; - + + xprintf("%s", pre); for (p = s; *p; p++) - printf("%c", *p & 0xff); - printf("\n"); + xprintf("%c", *p & 0xff); + xprintf("\n%s", pre); for (p = s; *p; p++) - printf("%c", *p & M_PROTECT ? '"' : ' '); - printf("\n"); + xprintf("%c", *p & M_PROTECT ? '"' : ' '); + xprintf("\n%s", pre); for (p = s; *p; p++) - printf("%c", *p & M_META ? '_' : ' '); - printf("\n"); + xprintf("%c", *p & M_META ? '_' : ' '); + xprintf("\n"); } #endif /* DEBUG */ @@ -410,7 +411,7 @@ glob(const char *pattern, int flags, int (*errfunc) (const char *, int), } *bufnext = EOS; #ifdef DEBUG - qprintf(patbuf); + qprintf("patbuf=", patbuf); #endif if ((err = glob1(patbuf, pglob, no_match)) != 0) { @@ -707,7 +708,7 @@ match(const char *name, const Char *pat, const Char *patend, int m_not) while (pat < patend || *name) { size_t lwk, pwk; - __Char wc, wk; + __Char wc, wk, wc1; c = *pat; /* Only for M_MASK bits */ if (*name == EOS) @@ -742,18 +743,20 @@ match(const char *name, const Char *pat, const Char *patend, int m_not) pat += pwk; pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); } + wc1 = wc; while ((*pat & M_MASK) != M_END) { if ((*pat & M_MASK) == M_RNG) { __Char wc2; pat += pwk; pwk = One_Char_mbtowc(&wc2, pat, MB_LEN_MAX); - if (globcharcoll(wc, wk, 0) <= 0 && + if (globcharcoll(wc1, wk, 0) <= 0 && globcharcoll(wk, wc2, 0) <= 0) ok = 1; } else if (wc == wk) ok = 1; pat += pwk; + wc1 = wc; pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); } pat += pwk;