Skip to content

Commit

Permalink
PR/81: oldping: Fix range matching issue where we were comparing with…
Browse files Browse the repository at this point in the history
… the

range character instead of the start of range.
  • Loading branch information
zoulasc committed Jul 29, 2019
1 parent d03b33c commit 4679bde
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions glob.c
Expand Up @@ -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 '$'
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4679bde

Please sign in to comment.