after literally HOURS of debugging, I got a working-ish expression…
This commit is contained in:
		
							
								
								
									
										22
									
								
								sh.h
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								sh.h
									
									
									
									
									
								
							@@ -182,7 +182,7 @@
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef EXTERN
 | 
			
		||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.854 2018/01/14 00:22:29 tg Exp $");
 | 
			
		||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.855 2018/01/14 00:47:11 tg Exp $");
 | 
			
		||||
#endif
 | 
			
		||||
#define MKSH_VERSION "R56 2017/10/17"
 | 
			
		||||
 | 
			
		||||
@@ -1474,16 +1474,16 @@ EXTERN char ifs0;
 | 
			
		||||
extern unsigned int eek_ord;
 | 
			
		||||
#define ORD(c)	((size_t)(c) > 0xFF ? eek_ord : \
 | 
			
		||||
		    ((unsigned int)(unsigned char)(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));		\
 | 
			
		||||
#define ord(c)	__builtin_choose_expr(				\
 | 
			
		||||
    __builtin_types_compatible_p(__typeof__(c), char) ||	\
 | 
			
		||||
    __builtin_types_compatible_p(__typeof__(c), unsigned char),	\
 | 
			
		||||
    ((unsigned int)(unsigned char)(c)), ({			\
 | 
			
		||||
	size_t ord_c = (c);					\
 | 
			
		||||
								\
 | 
			
		||||
	if (ord_c > (size_t)0xFFU)				\
 | 
			
		||||
		internal_errorf("%s:%d:ord(%zu)",		\
 | 
			
		||||
		    __FILE__, __LINE__, ord_c);			\
 | 
			
		||||
	((unsigned int)(unsigned char)(ord_c));			\
 | 
			
		||||
}))
 | 
			
		||||
#else
 | 
			
		||||
#define ord(c)	((unsigned int)(unsigned char)(c))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user