From 57eb0c15a10dfcd9816b84166106a1aa32323325 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 20 May 2020 12:15:24 -0700 Subject: fix: made rune constants unsigned for implicit casting --- include/libn.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/libn.h b/include/libn.h index f469c5c..835d2c1 100644 --- a/include/libn.h +++ b/include/libn.h @@ -136,22 +136,24 @@ void str·replace(string s, const byte* from, const byte* to); string* str·split(string s, const byte* tok); string str·join(vlong len, byte** fields, const byte* sep); - /* +/* * UTF-8 functions. * Perhaps break into own unit * TODO: Add to(upper|lower|title) */ typedef uint32 rune; -enum -{ - UTFmax = 4, - RuneSync = 0x80, - RuneSelf = 0x80, - RuneErr = 0xFFFD, - RuneMax = 0x10FFFF, - RuneMask = 0x1FFFFF, -}; +/* + * We have to use the preprocessor to ensure + * we have unsigned constants. Unfortunate... + */ + +#define UTFmax 4 +#define RuneSync 0x80u +#define RuneSelf 0x80u +#define RuneErr 0xFFFDu +#define RuneMax 0x10FFFFu +#define RuneMask 0x1FFFFFu /* utf8 helpers */ int utf8·fullrune(byte *s, int n); -- cgit v1.2.1