From e6c361568181b5ff952a72b08897033981910147 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 28 Mar 2025 13:51:52 -0400 Subject: [PATCH] Remove dead code and add version check for emoji --- src/stdlib/patterns.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/stdlib/patterns.c b/src/stdlib/patterns.c index 500d29d..07a17af 100644 --- a/src/stdlib/patterns.c +++ b/src/stdlib/patterns.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "arrays.h" #include "integers.h" @@ -67,18 +68,6 @@ static INLINE bool match_str(TextIter_t *state, int64_t *i, const char *str) return true; } -static INLINE bool match_property(TextIter_t *state, int64_t *i, uc_property_t prop) -{ - if (*i >= state->stack[0].text.length) return false; - 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; - return true; - } - return false; -} - static int64_t parse_int(TextIter_t *state, int64_t *i) { int64_t value = 0; @@ -618,9 +607,12 @@ static pat_t parse_next_pat(TextIter_t *state, int64_t *index) return PAT(PAT_END, .non_capturing=!negated); } else if (strcasecmp(prop_name, "email") == 0) { return PAT(PAT_FUNCTION, .fn=match_email); - } else if (strcasecmp(prop_name, "emoji") == 0) { + } +#if _LIBUNISTRING_VERSION >= 0x0100000 + else if (strcasecmp(prop_name, "emoji") == 0) { return PAT(PAT_PROPERTY, .property=UC_PROPERTY_EMOJI); } +#endif break; case 'h': if (strcasecmp(prop_name, "host") == 0) {