[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] ash: improve / fix glob expansion
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2017-01-31 21:09:10
Message-ID: CAK1hOcN7DPqRP=iprhWYwim=tZgYMNgovTxDmLYWnBFD-Ypyuw () mail ! gmail ! com
[Download RAW message or body]
>> I plan to massage it into this - do you see any bugs?
> Looks okay.
I'm committing this version, yell if something wrong.
hasmeta(const char *p)
{
static const char chars[] ALIGN1 = {
'*', '?', '[', '\\', CTLQUOTEMARK, CTLESC, 0
};
for (;;) {
p = strpbrk(p, chars);
if (!p)
break;
switch ((unsigned char) *p) {
case CTLQUOTEMARK:
for (;;) {
p++;
if (*p == CTLQUOTEMARK)
break;
if (*p == CTLESC)
p++;
if (*p == '\0') /* huh? */
return 0;
}
break;
case '\\':
case CTLESC:
p++;
if (*p == '\0')
return 0;
break;
case '[':
if (!strchr(p + 1, ']')) {
/* It's not a properly closed [] pattern,
* but other metas may follow.
Continue checking.
* my[file* _is_ globbed by bash
* and matches filenames like "my[file1".
*/
break;
}
/* fallthrough */
default:
/* case '*': */
/* case '?': */
return 1;
}
p++;
}
return 0;
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic