keep ksh_ctypes[] array keys in EBCDIC
we set $IFS massively less often than use ctype()
This commit is contained in:
parent
7ff7821d6a
commit
cb4bac0615
4
sh.h
4
sh.h
@ -175,7 +175,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.828 2017/04/28 11:13:48 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.829 2017/04/28 11:31:51 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R55 2017/04/27"
|
#define MKSH_VERSION "R55 2017/04/27"
|
||||||
|
|
||||||
@ -1492,7 +1492,7 @@ extern void ebcdic_init(void);
|
|||||||
#define ksh_isctrl(c) ((ord(c) & 0x7F) < 0x20 || (c) == 0x7F)
|
#define ksh_isctrl(c) ((ord(c) & 0x7F) < 0x20 || (c) == 0x7F)
|
||||||
#endif
|
#endif
|
||||||
/* new fast character classes */
|
/* new fast character classes */
|
||||||
#define ctype(c,t) tobool(ksh_ctypes[rtt2asc(c)] & (t))
|
#define ctype(c,t) tobool(ksh_ctypes[ord(c)] & (t))
|
||||||
/* helper functions */
|
/* helper functions */
|
||||||
#define ksh_isdash(s) tobool(ord((s)[0]) == '-' && ord((s)[1]) == '\0')
|
#define ksh_isdash(s) tobool(ord((s)[0]) == '-' && ord((s)[1]) == '\0')
|
||||||
/* invariant distance even in EBCDIC */
|
/* invariant distance even in EBCDIC */
|
||||||
|
13
shf.c
13
shf.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.91 2017/04/28 11:27:58 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.92 2017/04/28 11:31:53 tg Exp $");
|
||||||
|
|
||||||
/* flags to shf_emptybuf() */
|
/* flags to shf_emptybuf() */
|
||||||
#define EB_READSW 0x01 /* about to switch to reading */
|
#define EB_READSW 0x01 /* about to switch to reading */
|
||||||
@ -1209,12 +1209,21 @@ const uint32_t tpl_ctypes[128] = {
|
|||||||
void
|
void
|
||||||
set_ifs(const char *s)
|
set_ifs(const char *s)
|
||||||
{
|
{
|
||||||
|
#if defined(MKSH_EBCDIC) || defined(MKSH_FAUX_EBCDIC)
|
||||||
|
int i = 256;
|
||||||
|
|
||||||
|
memset(ksh_ctypes, 0, sizeof(ksh_ctypes));
|
||||||
|
while (i--)
|
||||||
|
if (ebcdic_map[i] < 0x80U)
|
||||||
|
ksh_ctypes[i] = tpl_ctypes[ebcdic_map[i]];
|
||||||
|
#else
|
||||||
memcpy(ksh_ctypes, tpl_ctypes, sizeof(tpl_ctypes));
|
memcpy(ksh_ctypes, tpl_ctypes, sizeof(tpl_ctypes));
|
||||||
memset((char *)ksh_ctypes + sizeof(tpl_ctypes), '\0',
|
memset((char *)ksh_ctypes + sizeof(tpl_ctypes), '\0',
|
||||||
sizeof(ksh_ctypes) - sizeof(tpl_ctypes));
|
sizeof(ksh_ctypes) - sizeof(tpl_ctypes));
|
||||||
|
#endif
|
||||||
ifs0 = *s;
|
ifs0 = *s;
|
||||||
while (*s)
|
while (*s)
|
||||||
ksh_ctypes[rtt2asc(*s++)] |= CiIFS;
|
ksh_ctypes[ord(*s++)] |= CiIFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MKSH_EBCDIC) || defined(MKSH_FAUX_EBCDIC)
|
#if defined(MKSH_EBCDIC) || defined(MKSH_FAUX_EBCDIC)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user