oops, casting negative char to size_t is… not nice
This commit is contained in:
9
sh.h
9
sh.h
@ -182,7 +182,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#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
|
#endif
|
||||||
#define MKSH_VERSION "R56 2017/10/17"
|
#define MKSH_VERSION "R56 2017/10/17"
|
||||||
|
|
||||||
@ -1474,14 +1474,17 @@ EXTERN char ifs0;
|
|||||||
extern unsigned int eek_ord;
|
extern unsigned int eek_ord;
|
||||||
#define ORD(c) ((size_t)(c) > 0xFF ? eek_ord : \
|
#define ORD(c) ((size_t)(c) > 0xFF ? eek_ord : \
|
||||||
((unsigned int)(unsigned char)(c)))
|
((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); \
|
size_t ord_c = (c); \
|
||||||
\
|
\
|
||||||
if (ord_c > 0xFF) \
|
if (ord_c > 0xFF) \
|
||||||
internal_errorf("%s:%d:ord(%zu)", \
|
internal_errorf("%s:%d:ord(%zu)", \
|
||||||
__FILE__, __LINE__, ord_c); \
|
__FILE__, __LINE__, ord_c); \
|
||||||
((unsigned int)(unsigned char)(c)); \
|
((unsigned int)(unsigned char)(c)); \
|
||||||
})
|
}))
|
||||||
#else
|
#else
|
||||||
#define ord(c) ((unsigned int)(unsigned char)(c))
|
#define ord(c) ((unsigned int)(unsigned char)(c))
|
||||||
#define ORD(c) ord(c) /* may evaluate arguments twice */
|
#define ORD(c) ord(c) /* may evaluate arguments twice */
|
||||||
|
Reference in New Issue
Block a user