oops, casting negative char to size_t is… not nice
This commit is contained in:
parent
c763e7b0e9
commit
9e4868fb06
9
sh.h
9
sh.h
|
@ -182,7 +182,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.852 2018/01/14 00:03:03 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.853 2018/01/14 00:09:34 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R56 2017/10/17"
|
||||
|
||||
|
@ -1474,14 +1474,17 @@ EXTERN char ifs0;
|
|||
extern unsigned int eek_ord;
|
||||
#define ORD(c) ((size_t)(c) > 0xFF ? eek_ord : \
|
||||
((unsigned int)(unsigned char)(c)))
|
||||
#define ord(c) ({ \
|
||||
#define Oc(c,t) __builtin_types_compatible_p(__typeof__(c), t)
|
||||
#define ord(c) __builtin_choose_expr( \
|
||||
Oc((c), unsigned char) || Oc((c), char), \
|
||||
((unsigned int)(unsigned char)(c)), ({ \
|
||||
size_t ord_c = (c); \
|
||||
\
|
||||
if (ord_c > 0xFF) \
|
||||
internal_errorf("%s:%d:ord(%zu)", \
|
||||
__FILE__, __LINE__, ord_c); \
|
||||
((unsigned int)(unsigned char)(c)); \
|
||||
})
|
||||
}))
|
||||
#else
|
||||
#define ord(c) ((unsigned int)(unsigned char)(c))
|
||||
#define ORD(c) ord(c) /* may evaluate arguments twice */
|
||||
|
|
Loading…
Reference in New Issue