rename asc() to asciibetical() to make clear it’s for POSIX ordering only
and switch remaining consumers, except the allowed one, to rtt2asc()
This commit is contained in:
parent
1c6b2d1cb8
commit
d905bd16e1
6
misc.c
6
misc.c
@ -32,7 +32,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.267 2017/04/28 03:28:18 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.268 2017/04/28 03:46:49 tg Exp $");
|
||||||
|
|
||||||
#define KSH_CHVT_FLAG
|
#define KSH_CHVT_FLAG
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
@ -937,7 +937,7 @@ ascstrcmp(const void *s1, const void *s2)
|
|||||||
return (0);
|
return (0);
|
||||||
++cp2;
|
++cp2;
|
||||||
}
|
}
|
||||||
return ((int)asc(*cp1) - (int)asc(*cp2));
|
return ((int)asciibetical(*cp1) - (int)asciibetical(*cp2));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1098,7 +1098,7 @@ print_value_quoted(struct shf *shf, const char *s)
|
|||||||
bool inquote = true;
|
bool inquote = true;
|
||||||
|
|
||||||
/* first, check whether any quotes are needed */
|
/* first, check whether any quotes are needed */
|
||||||
while (asc(c = *p++) >= 32)
|
while (rtt2asc(c = *p++) >= 32)
|
||||||
if (ctype(c, C_QUOTE | C_SPC))
|
if (ctype(c, C_QUOTE | C_SPC))
|
||||||
inquote = false;
|
inquote = false;
|
||||||
|
|
||||||
|
15
sh.h
15
sh.h
@ -175,7 +175,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.825 2017/04/28 03:28:18 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.826 2017/04/28 03:46:50 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R55 2017/04/27"
|
#define MKSH_VERSION "R55 2017/04/27"
|
||||||
|
|
||||||
@ -1467,13 +1467,14 @@ EXTERN char ifs0;
|
|||||||
|
|
||||||
/* identity transform of octet */
|
/* identity transform of octet */
|
||||||
#define ord(c) ((unsigned int)(unsigned char)(c))
|
#define ord(c) ((unsigned int)(unsigned char)(c))
|
||||||
/* one-way to-ascii-or-high conversion */
|
|
||||||
#ifdef MKSH_EBCDIC
|
#ifdef MKSH_EBCDIC
|
||||||
EXTERN unsigned short ebcdic_map[256];
|
EXTERN unsigned short ebcdic_map[256];
|
||||||
EXTERN unsigned char ebcdic_rtt_toascii[256];
|
EXTERN unsigned char ebcdic_rtt_toascii[256];
|
||||||
EXTERN unsigned char ebcdic_rtt_fromascii[256];
|
EXTERN unsigned char ebcdic_rtt_fromascii[256];
|
||||||
extern void ebcdic_init(void);
|
extern void ebcdic_init(void);
|
||||||
#define asc(c) ((unsigned int)ebcdic_map[(unsigned char)(c)])
|
/* one-way to-ascii-or-high conversion, for POSIX locale ordering */
|
||||||
|
#define asciibetical(c) ((unsigned int)ebcdic_map[(unsigned char)(c)])
|
||||||
|
/* two-way round-trip conversion, for general use */
|
||||||
#define rtt2asc(c) ebcdic_rtt_toascii[(unsigned char)(c)]
|
#define rtt2asc(c) ebcdic_rtt_toascii[(unsigned char)(c)]
|
||||||
#define asc2rtt(c) ebcdic_rtt_fromascii[(unsigned char)(c)]
|
#define asc2rtt(c) ebcdic_rtt_fromascii[(unsigned char)(c)]
|
||||||
/* control character foo */
|
/* control character foo */
|
||||||
@ -1481,7 +1482,7 @@ extern void ebcdic_init(void);
|
|||||||
/* case-independent char comparison */
|
/* case-independent char comparison */
|
||||||
#define ksh_eq(c,u,l) (ord(c) == ord(u) || ord(c) == ord(l))
|
#define ksh_eq(c,u,l) (ord(c) == ord(u) || ord(c) == ord(l))
|
||||||
#else
|
#else
|
||||||
#define asc(c) ord(c)
|
#define asciibetical(c) ord(c)
|
||||||
#define rtt2asc(c) ((unsigned char)(c))
|
#define rtt2asc(c) ((unsigned char)(c))
|
||||||
#define asc2rtt(c) ((unsigned char)(c))
|
#define asc2rtt(c) ((unsigned char)(c))
|
||||||
#define ksh_isctrl(c) (((c) & 0x7F) < 0x20 || (c) == 0x7F)
|
#define ksh_isctrl(c) (((c) & 0x7F) < 0x20 || (c) == 0x7F)
|
||||||
@ -1494,10 +1495,10 @@ extern void ebcdic_init(void);
|
|||||||
/* invariant distance even in EBCDIC */
|
/* invariant distance even in EBCDIC */
|
||||||
#define ksh_tolower(c) (ctype(c, C_UPPER) ? (c) - 'A' + 'a' : (c))
|
#define ksh_tolower(c) (ctype(c, C_UPPER) ? (c) - 'A' + 'a' : (c))
|
||||||
#define ksh_toupper(c) (ctype(c, C_LOWER) ? (c) - 'a' + 'A' : (c))
|
#define ksh_toupper(c) (ctype(c, C_LOWER) ? (c) - 'a' + 'A' : (c))
|
||||||
/* strictly speaking asc() here, but this works even in EBCDIC */
|
/* strictly speaking rtt2asc() here, but this works even in EBCDIC */
|
||||||
#define ksh_numdig(c) (ord(c) - ord('0'))
|
#define ksh_numdig(c) (ord(c) - ord('0'))
|
||||||
#define ksh_numuc(c) (asc(c) - asc('A'))
|
#define ksh_numuc(c) (rtt2asc(c) - rtt2asc('A'))
|
||||||
#define ksh_numlc(c) (asc(c) - asc('a'))
|
#define ksh_numlc(c) (rtt2asc(c) - rtt2asc('a'))
|
||||||
#define ksh_toctrl(c) asc2rtt(ord(c) == ord('?') ? 0x7F : rtt2asc(c) & 0x9F)
|
#define ksh_toctrl(c) asc2rtt(ord(c) == ord('?') ? 0x7F : rtt2asc(c) & 0x9F)
|
||||||
#define ksh_unctrl(c) asc2rtt(rtt2asc(c) ^ 0x40U)
|
#define ksh_unctrl(c) asc2rtt(rtt2asc(c) ^ 0x40U)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user