diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-31 02:17:47 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-31 02:17:47 -0400 |
| commit | da94f2bc8ceadcec014d8e5b4819f96ab34fecfb (patch) | |
| tree | 6407807a56c30148d2d250226809d1075be83afa /src/stdlib/text.c | |
| parent | 7a172be6213839a3d023ba21c3bafd7540a4bfe8 (diff) | |
Move pattern code into patterns file
Diffstat (limited to 'src/stdlib/text.c')
| -rw-r--r-- | src/stdlib/text.c | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/src/stdlib/text.c b/src/stdlib/text.c index 177a9130..65290bb3 100644 --- a/src/stdlib/text.c +++ b/src/stdlib/text.c @@ -1458,26 +1458,4 @@ public const TypeInfo_t Text$info = { .metamethods=Text$metamethods, }; -public Pattern_t Pattern$escape_text(Text_t text) -{ - // TODO: optimize for spans of non-escaped text - Text_t ret = EMPTY_TEXT; - TextIter_t state = NEW_TEXT_ITER_STATE(text); - for (int64_t i = 0; i < text.length; i++) { - int32_t g = Text$get_grapheme_fast(&state, i); - ucs4_t g0 = g < 0 ? GRAPHEME_CODEPOINTS(g)[0] : (ucs4_t)g; - - if (g == '{') { - ret = concat2_assuming_safe(ret, Text("{1{}")); - } else if (g0 == '?' - || uc_is_property_quotation_mark(g0) - || (uc_is_property_paired_punctuation(g0) && uc_is_property_left_of_pair(g0))) { - ret = Text$concat(ret, Text("{1"), Text$slice(text, I(i+1), I(i+1)), Text("}")); - } else { - ret = concat2_assuming_safe(ret, Text$slice(text, I(i+1), I(i+1))); - } - } - return ret; -} - // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
