aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-10-25 14:05:07 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-10-25 14:05:07 -0400
commit29d1d74d7aab8354be0c01792c4b355f34565676 (patch)
treeeb332a93a5002f5eeaa6b9b03d3991205d7ad904
parent67702b2d77d8474c2a7fe7f1816f4eb9a0a98af1 (diff)
Move unistr header out of tomo header
-rw-r--r--stdlib/patterns.c14
-rw-r--r--stdlib/shell.c1
-rw-r--r--stdlib/text.c3
-rw-r--r--stdlib/text.h3
4 files changed, 11 insertions, 10 deletions
diff --git a/stdlib/patterns.c b/stdlib/patterns.c
index 701aff9c..875ea372 100644
--- a/stdlib/patterns.c
+++ b/stdlib/patterns.c
@@ -67,7 +67,7 @@ static inline bool match_str(TextIter_t *state, int64_t *i, const char *str)
static inline bool match_property(TextIter_t *state, int64_t *i, uc_property_t prop)
{
if (*i >= state->text.length) return false;
- ucs4_t grapheme = Text$get_main_grapheme_fast(state, *i);
+ uint32_t grapheme = Text$get_main_grapheme_fast(state, *i);
// TODO: check every codepoint in the cluster?
if (uc_is_property(grapheme, prop)) {
*i += 1;
@@ -80,8 +80,8 @@ static int64_t parse_int(TextIter_t *state, int64_t *i)
{
int64_t value = 0;
for (;; *i += 1) {
- ucs4_t grapheme = Text$get_main_grapheme_fast(state, *i);
- int digit = uc_digit_value((ucs4_t)grapheme);
+ uint32_t grapheme = Text$get_main_grapheme_fast(state, *i);
+ int digit = uc_digit_value(grapheme);
if (digit < 0) break;
if (value >= INT64_MAX/10) break;
value = 10*value + digit;
@@ -143,8 +143,8 @@ static int64_t match_email(TextIter_t *state, int64_t index)
// dns-label = 1-63 ([a-zA-Z0-9-] | non-ascii)
if (index > 0) {
- ucs4_t prev_codepoint = Text$get_main_grapheme_fast(state, index - 1);
- if (uc_is_property_alphabetic((ucs4_t)prev_codepoint))
+ uint32_t prev_codepoint = Text$get_main_grapheme_fast(state, index - 1);
+ if (uc_is_property_alphabetic(prev_codepoint))
return -1;
}
@@ -310,7 +310,7 @@ static int64_t match_uri(TextIter_t *state, int64_t index)
if (index > 0) {
// Don't match if we're not at a word edge:
- ucs4_t prev_codepoint = Text$get_main_grapheme_fast(state, index - 1);
+ uint32_t prev_codepoint = Text$get_main_grapheme_fast(state, index - 1);
if (uc_is_property_alphabetic(prev_codepoint))
return -1;
}
@@ -407,7 +407,7 @@ static int64_t match_newline(TextIter_t *state, int64_t index)
if (index >= state->text.length)
return -1;
- ucs4_t grapheme = index >= state->text.length ? 0 : Text$get_main_grapheme_fast(state, index);
+ uint32_t grapheme = index >= state->text.length ? 0 : Text$get_main_grapheme_fast(state, index);
if (grapheme == '\n')
return 1;
if (grapheme == '\r' && Text$get_grapheme_fast(state, index + 1) == '\n')
diff --git a/stdlib/shell.c b/stdlib/shell.c
index d2d0f78a..68c61115 100644
--- a/stdlib/shell.c
+++ b/stdlib/shell.c
@@ -2,6 +2,7 @@
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
+#include <unistr.h>
#include "arrays.h"
#include "integers.h"
diff --git a/stdlib/text.c b/stdlib/text.c
index 96b0c2cd..7b579f5e 100644
--- a/stdlib/text.c
+++ b/stdlib/text.c
@@ -56,6 +56,7 @@
#include <stdlib.h>
#include <sys/param.h>
+#include <unistr.h>
#include <unicase.h>
#include <unictype.h>
#include <unigbrk.h>
@@ -846,7 +847,7 @@ public int32_t Text$get_grapheme_fast(TextIter_t *state, int64_t index)
return 0;
}
-public ucs4_t Text$get_main_grapheme_fast(TextIter_t *state, int64_t index)
+public uint32_t Text$get_main_grapheme_fast(TextIter_t *state, int64_t index)
{
return MAIN_GRAPHEME_CODEPOINT(Text$get_grapheme_fast(state, index));
}
diff --git a/stdlib/text.h b/stdlib/text.h
index 43eee1cc..e915eefd 100644
--- a/stdlib/text.h
+++ b/stdlib/text.h
@@ -6,7 +6,6 @@
#include <stdbool.h>
#include <printf.h>
#include <stdint.h>
-#include <unistr.h>
#include "datatypes.h"
#include "integers.h"
@@ -55,7 +54,7 @@ Array_t Text$lines(Text_t text);
Text_t Text$join(Text_t glue, Array_t pieces);
Text_t Text$repeat(Text_t text, Int_t count);
int32_t Text$get_grapheme_fast(TextIter_t *state, int64_t index);
-ucs4_t Text$get_main_grapheme_fast(TextIter_t *state, int64_t index);
+uint32_t Text$get_main_grapheme_fast(TextIter_t *state, int64_t index);
static inline int32_t Text$get_grapheme(Text_t text, int64_t index)
{