aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-05-20 12:15:24 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-05-20 12:15:24 -0700
commit57eb0c15a10dfcd9816b84166106a1aa32323325 (patch)
tree7e4060d941dca7060c57153e13b02928e533c187 /include
parent480611c452e8b4dc18654545e2de4d6dde2d7b4d (diff)
fix: made rune constants unsigned for implicit casting
Diffstat (limited to 'include')
-rw-r--r--include/libn.h22
1 files changed, 12 insertions, 10 deletions
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);