small character classes overhaul:

• make fast character classes even faster by removing the C_SUBOP2 hack
  in favour of a separate seldom-used ksh_issubop2 macro (which also
  makes ctype() side-effect-safe) which is a slower class (no change there)
• optimise cases of ksh_isalphx followed by a ksh_isalnux loop
  (used parsing variable names)
• remove a misleading comment in initctypes() about \0 from pdksh
• rename C_ALPHA to C_ALPHX to make it more clear the underscore is included
• sprinkle a few ord() in there
• add new ksh_isalpha() which tests for [A-Za-z] (slow character class)
• there is no '_:\' drive on OS/2 (which inspired the whole changeset)
This commit is contained in:
tg
2017-03-26 00:10:26 +00:00
parent 034d0c0269
commit 7529e350cf
7 changed files with 33 additions and 33 deletions

9
misc.c
View File

@@ -30,7 +30,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.252 2017/03/11 23:56:17 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.253 2017/03/26 00:10:24 tg Exp $");
#define KSH_CHVT_FLAG
#ifdef MKSH_SMALL
@@ -89,11 +89,10 @@ setctypes(const char *s, int t)
void
initctypes(void)
{
setctypes(letters_uc, C_ALPHA);
setctypes(letters_lc, C_ALPHA);
chtypes['_'] |= C_ALPHA;
setctypes(letters_uc, C_ALPHX);
setctypes(letters_lc, C_ALPHX);
chtypes['_'] |= C_ALPHX;
setctypes("0123456789", C_DIGIT);
/* \0 added automatically */
setctypes(TC_LEX1, C_LEX1);
setctypes("*@#!$-?", C_VAR1);
setctypes(TC_IFSWS, C_IFSWS);