2 #include "linux/string.h"
18 for (i = 1; i <
strlen(str); i++) {
24 if (str[i + 1] !=
'B')
29 if (str[i + 1] !=
'b')
35 if (str[i + 1] !=
'B')
40 if (str[i + 1] !=
'b')
46 if (str[i + 1] !=
'B')
51 if (str[i + 1] !=
'b')
57 if (str[i + 1] !=
'B')
62 if (str[i + 1] !=
'b')
77 length = atoll(str) *
unit;
90 static const char *skip_sep(
const char *
cp)
98 static const char *skip_arg(
const char *cp)
106 static int count_argc(
const char *
str)
130 for (p = argv; *
p; p++)
150 int argc = count_argc(str);
151 char **argv =
zalloc(
sizeof(*argv) * (argc+1));
171 t = strndup(p, str-p);
188 static bool __match_charclass(
const char *
pat,
char c,
const char **npat)
190 bool complement =
false,
ret =
true;
199 while (*pat && *pat !=
']') {
200 if (*pat ==
'-' && *(pat + 1) !=
']') {
201 if (*(pat - 1) <= c && c <= *(pat + 1))
203 if (*(pat - 1) > *(pat + 1))
206 }
else if (*pat++ == c)
214 while (*pat && *pat !=
']')
219 return complement ? !
ret :
ret;
226 static bool __match_glob(
const char *str,
const char *pat,
bool ignore_space)
228 while (*str && *pat && *pat !=
'*') {
244 }
else if (*pat ==
'[')
245 if (__match_charclass(pat + 1, *str, &pat)) {
250 else if (*pat ==
'\\')
252 if (*str++ != *pat++)
262 if (__match_glob(str++, pat, ignore_space))
265 return !*str && !*pat;
282 return __match_glob(str, pat,
false);
295 return __match_glob(str, pat,
true);
309 while (--i1 >= 0 && --i2 >= 0) {
310 if (s1[i1] != s2[i2])
311 return s1[i1] - s2[i2];
332 while (end >= s &&
isspace(*end))