batch of optimisations
This commit is contained in:
23
misc.c
23
misc.c
@ -30,7 +30,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.260 2017/04/27 19:33:52 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.261 2017/04/27 20:22:26 tg Exp $");
|
||||
|
||||
#define KSH_CHVT_FLAG
|
||||
#ifdef MKSH_SMALL
|
||||
@ -1072,7 +1072,8 @@ ksh_getopt(const char **argv, Getopt *go, const char *optionsp)
|
||||
} else
|
||||
go->optarg = NULL;
|
||||
} else {
|
||||
if (argv[go->optind] && ctype(argv[go->optind][0], C_DIGIT)) {
|
||||
if (argv[go->optind] &&
|
||||
ctype(argv[go->optind][0], C_DIGIT)) {
|
||||
go->optarg = argv[go->optind++];
|
||||
go->p = 0;
|
||||
} else
|
||||
@ -1096,7 +1097,7 @@ print_value_quoted(struct shf *shf, const char *s)
|
||||
|
||||
/* first, check whether any quotes are needed */
|
||||
while ((c = *p++) >= 32)
|
||||
if (ctype(c, C_QUOTE))
|
||||
if (ctype(c, C_QUOTE | C_SPC))
|
||||
inquote = false;
|
||||
|
||||
p = (const unsigned char *)s;
|
||||
@ -2192,7 +2193,7 @@ unbksl(bool cstyle, int (*fg)(void), void (*fp)(int))
|
||||
wc = 0;
|
||||
i = 3;
|
||||
while (i--)
|
||||
if (ctype((c = (*fg)()), C_DIGIT) && asc(c) <= asc('7'))
|
||||
if (ctype((c = (*fg)()), C_OCTAL))
|
||||
wc = (wc << 3) + ksh_numdig(c);
|
||||
else {
|
||||
(*fp)(c);
|
||||
@ -2220,17 +2221,17 @@ unbksl(bool cstyle, int (*fg)(void), void (*fp)(int))
|
||||
n = 0;
|
||||
while (n < i || i == -1) {
|
||||
wc <<= 4;
|
||||
if (ctype((c = (*fg)()), C_DIGIT))
|
||||
wc += ksh_numdig(c);
|
||||
else if (asc(c) >= asc('A') && asc(c) <= asc('F'))
|
||||
wc += ksh_numuc(c) + 10;
|
||||
else if (asc(c) >= asc('a') && asc(c) <= asc('f'))
|
||||
wc += ksh_numlc(c) + 10;
|
||||
else {
|
||||
if (!ctype((c = (*fg)()), C_SEDEC)) {
|
||||
wc >>= 4;
|
||||
(*fp)(c);
|
||||
break;
|
||||
}
|
||||
if (ctype(c, C_DIGIT))
|
||||
wc += ksh_numdig(c);
|
||||
else if (ctype(c, C_UPPER))
|
||||
wc += ksh_numuc(c) + 10;
|
||||
else
|
||||
wc += ksh_numlc(c) + 10;
|
||||
++n;
|
||||
}
|
||||
if (!n)
|
||||
|
Reference in New Issue
Block a user