This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch tymux-11-parser-speedup
in repository terminology.

View the commit online.

commit 197da0888c9b233480126d9f653a509c4abb828b
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 22 14:38:41 2026 -0600

    utf8: widen ASCII with its controls in one run
    
    The decoder stopped its vector run at every C0 control, so each ESC and
    line feed ended a run, went through the per-character path and started
    the scan again. Every byte below 0x80 decodes to itself, NUL and DEL
    included, so one kernel widens up to the first byte with the high bit
    set, in a single pass instead of a scan and a widen.
    
    tybench, cycles per input byte, 7 interleaved rounds: csi-motion
    -24.8% (18.42 from 24.50), sgr -15.9%, insert -14.7%, scroll-region
    -14.7%, insert-mode -11.2%, truecolor-cells -9.8%, fill -8.5%, scroll
    -8.0%, rep -7.6%, hyperlink -4.1%, plain-ascii -2.9%, strings -2.4%.
    unicode and long-lines do not move (-0.4%, -0.3%). No corpus is slower.
---
 src/bin/simd/simd.c        | 136 ++++++++++++++++++++++++++++++++++++++-
 src/bin/simd/simd.h        |  22 +++++++
 src/bin/simd/simd_avx2.c   |  51 +++++++++++++++
 src/bin/simd/simd_neon.c   |  36 +++++++++++
 src/bin/simd/simd_scalar.c |  14 ++++
 src/bin/simd/simd_sse2.c   |  32 ++++++++++
 src/bin/tytest.c           |   1 +
 src/bin/unit_tests.h       |   1 +
 src/bin/utf8.c             | 156 +++++++++++++++++++++++++++++++++++++++------
 9 files changed, 428 insertions(+), 21 deletions(-)

diff --git a/src/bin/simd/simd.c b/src/bin/simd/simd.c
index 41e6a983..1749db97 100644
--- a/src/bin/simd/simd.c
+++ b/src/bin/simd/simd.c
@@ -163,6 +163,24 @@ simd_widen_ascii(const unsigned char *buf, size_t len, Eina_Unicode *out)
 #endif
    simd_widen_ascii_scalar(buf, len, out);
 }
+
+size_t
+simd_widen_ascii_run(const unsigned char *buf, size_t len, Eina_Unicode *out)
+{
+#if defined(TERMINOLOGY_HAVE_NEON)
+   if (EINA_LIKELY(_use_simd))
+     return simd_widen_ascii_run_neon(buf, len, out);
+#endif
+#if defined(TERMINOLOGY_HAVE_AVX2)
+   if (EINA_LIKELY(_use_avx2))
+     return simd_widen_ascii_run_avx2(buf, len, out);
+#endif
+#if defined(TERMINOLOGY_HAVE_SSE2)
+   if (EINA_LIKELY(_use_simd))
+     return simd_widen_ascii_run_sse2(buf, len, out);
+#endif
+   return simd_widen_ascii_run_scalar(buf, len, out);
+}
 /* Kernel tests, in two halves.
  *
  * Everywhere: each kernel is checked against a reference written from the
@@ -500,6 +518,37 @@ _test_ref_widen(void)
      }
 }
 
+static void
+_test_ref_widen_run(void)
+{
+   size_t len, off, pos, i;
+
+   for (len = 0; len <= 70; len++)
+     {
+        for (off = 0; off < 16; off++)
+          {
+             for (pos = 0; pos <= len; pos++)
+               {
+                  unsigned char *base = _alloc_guarded(off + len);
+                  unsigned char *p = base + GUARD + off;
+                  Eina_Unicode o1[80], o2[80];
+
+                  memset(p, 0x1b, len);
+                  if (pos < len) p[pos] = 0xe4;
+                  assert(simd_widen_ascii_run_scalar(p, len, o1) == pos);
+                  assert(simd_widen_ascii_run(p, len, o2) == pos);
+                  for (i = 0; i < pos; i++)
+                    {
+                       assert(o1[i] == 0x1b);
+                       assert(o2[i] == 0x1b);
+                    }
+                  assert(_guards_intact(base, off + len));
+                  free(base);
+               }
+          }
+     }
+}
+
 /* From here on, the vector kernels against the scalar ones. Every kernel set
  * implements the same functions, so the tests are written once and run for
  * each set in the table below. */
@@ -514,6 +563,7 @@ typedef struct tag_SimdVector
    void (*records_or)(void *buf, size_t n, size_t rec, size_t off,
                       unsigned char bit);
    void (*widen)(const unsigned char *buf, size_t len, Eina_Unicode *out);
+   size_t (*widen_run)(const unsigned char *buf, size_t len, Eina_Unicode *out);
 } SimdVector;
 
 static const SimdVector _vectors[] = {
@@ -523,7 +573,8 @@ static const SimdVector _vectors[] = {
      simd_scan_plain_ascii_u32_neon,
      simd_rscan_nonzero_neon,
      simd_records_or_byte_neon,
-     simd_widen_ascii_neon },
+     simd_widen_ascii_neon,
+     simd_widen_ascii_run_neon },
 #endif
 #if defined(TERMINOLOGY_HAVE_SSE2)
    { NULL,
@@ -531,7 +582,8 @@ static const SimdVector _vectors[] = {
      simd_scan_plain_ascii_u32_sse2,
      simd_rscan_nonzero_sse2,
      simd_records_or_byte_sse2,
-     simd_widen_ascii_sse2 },
+     simd_widen_ascii_sse2,
+     simd_widen_ascii_run_sse2 },
 #endif
 #if defined(TERMINOLOGY_HAVE_AVX2)
    { simd_avx2_supported,
@@ -539,7 +591,8 @@ static const SimdVector _vectors[] = {
      simd_scan_plain_ascii_u32_avx2,
      simd_rscan_nonzero_avx2,
      simd_records_or_byte_avx2,
-     simd_widen_ascii_avx2 },
+     simd_widen_ascii_avx2,
+     simd_widen_ascii_run_avx2 },
 #endif
 };
 
@@ -718,6 +771,81 @@ _test_widen(const SimdVector *set)
      }
 }
 
+/* The run ends at the first byte with the high bit set, whatever precedes it:
+ * controls, NUL and DEL are part of the run. */
+static void
+_test_widen_run(const SimdVector *set)
+{
+   size_t len, off, pos, i;
+   int density;
+
+   for (len = 0; len <= 70; len++)
+     {
+        for (density = 0; density <= 100; density += 25)
+          {
+             for (off = 0; off < 16; off++)
+               {
+                  unsigned char *base = _alloc_guarded(off + len);
+                  unsigned char *p = base + GUARD + off;
+                  Eina_Unicode *o1 = calloc(len + 8, sizeof(Eina_Unicode));
+                  Eina_Unicode *o2 = calloc(len + 8, sizeof(Eina_Unicode));
+                  size_t want, got;
+
+                  assert(o1 != NULL);
+                  assert(o2 != NULL);
+                  _fill(p, len, density);
+                  for (i = 0; i < 8; i++)
+                    {
+                       o1[len + i] = 0xdeadbeef;
+                       o2[len + i] = 0xdeadbeef;
+                    }
+
+                  want = simd_widen_ascii_run_scalar(p, len, o1);
+                  got = set->widen_run(p, len, o2);
+                  assert(want == got);
+                  for (i = 0; i < want; i++)
+                    assert(o2[i] == p[i]);
+                  /* Nothing may be written past the output. */
+                  for (i = 0; i < 8; i++)
+                    assert(o2[len + i] == 0xdeadbeef);
+                  assert(_guards_intact(base, off + len));
+
+                  free(base);
+                  free(o1);
+                  free(o2);
+               }
+          }
+     }
+
+   /* One byte with the high bit set walked across every position, in a buffer
+    * of every length: 0x80 and 0xff are the extremes, 0x7f and 0x00 must not
+    * end the run. */
+   for (len = 1; len <= 70; len++)
+     {
+        static const unsigned char ends[] = { 0x80, 0xc3, 0xff };
+        static const unsigned char kept[] = { 0x00, 0x0a, 0x1b, 0x20, 0x7f };
+        size_t e, k;
+
+        for (pos = 0; pos <= len; pos++)
+          {
+             for (e = 0; e < sizeof(ends); e++)
+               {
+                  for (k = 0; k < sizeof(kept); k++)
+                    {
+                       unsigned char buf[80];
+                       Eina_Unicode out[80];
+
+                       memset(buf, kept[k], sizeof(buf));
+                       if (pos < len) buf[pos] = ends[e];
+                       assert(set->widen_run(buf, len, out) == pos);
+                       for (i = 0; i < pos; i++)
+                         assert(out[i] == kept[k]);
+                    }
+               }
+          }
+     }
+}
+
 /* Every byte value, at every position, exhaustively. */
 static void
 _test_every_byte(const SimdVector *set)
@@ -779,6 +907,7 @@ tytest_simd_parity(void)
    _test_ref_rscan();
    _test_ref_records_or();
    _test_ref_widen();
+   _test_ref_widen_run();
 #if defined(TERMINOLOGY_HAVE_NEON) || defined(TERMINOLOGY_HAVE_SSE2)
    {
       size_t k;
@@ -796,6 +925,7 @@ tytest_simd_parity(void)
            _test_rscan(set);
            _test_records_or(set);
            _test_widen(set);
+           _test_widen_run(set);
            _test_every_byte(set);
            _test_every_u32_boundary(set);
         }
diff --git a/src/bin/simd/simd.h b/src/bin/simd/simd.h
index 73667c4a..9a5fa868 100644
--- a/src/bin/simd/simd.h
+++ b/src/bin/simd/simd.h
@@ -102,6 +102,28 @@ void simd_widen_ascii_avx2(const unsigned char *buf, size_t len,
                            Eina_Unicode *out);
 #endif
 
+/* Widen the leading bytes below 0x80 into codepoints: C0 controls, NUL and DEL
+ * included, since each of them decodes to itself. Returns how many there are,
+ * which is the index of the first byte with its high bit set, or len. Entries
+ * of 'out' past the returned count may be overwritten, but never past
+ * out[len - 1]. */
+size_t simd_widen_ascii_run(const unsigned char *buf, size_t len,
+                            Eina_Unicode *out);
+size_t simd_widen_ascii_run_scalar(const unsigned char *buf, size_t len,
+                                   Eina_Unicode *out);
+#if defined(TERMINOLOGY_HAVE_NEON)
+size_t simd_widen_ascii_run_neon(const unsigned char *buf, size_t len,
+                                 Eina_Unicode *out);
+#endif
+#if defined(TERMINOLOGY_HAVE_SSE2)
+size_t simd_widen_ascii_run_sse2(const unsigned char *buf, size_t len,
+                                 Eina_Unicode *out);
+#endif
+#if defined(TERMINOLOGY_HAVE_AVX2)
+size_t simd_widen_ascii_run_avx2(const unsigned char *buf, size_t len,
+                                 Eina_Unicode *out);
+#endif
+
 /* Read TERMINOLOGY_SIMD_DISABLE, which switches the vector kernels off without
  * a rebuild. Modelled on EFL's EVAS_NEON_DISABLE. When AVX2 is compiled in,
  * also enable it if Eina reports the CPU supports it. Eina reports no feature
diff --git a/src/bin/simd/simd_avx2.c b/src/bin/simd/simd_avx2.c
index 5dc94857..87fbfed8 100644
--- a/src/bin/simd/simd_avx2.c
+++ b/src/bin/simd/simd_avx2.c
@@ -231,4 +231,55 @@ simd_widen_ascii_avx2(const unsigned char *buf, size_t len, Eina_Unicode *out)
      out[i] = buf[i];
 }
 
+AVX2_TARGET
+size_t
+simd_widen_ascii_run_avx2(const unsigned char *buf, size_t len,
+                          Eina_Unicode *out)
+{
+   size_t i = 0;
+
+   for (; i + 32 <= len; i += 32)
+     {
+        const unsigned char *in = buf + i;
+        Eina_Unicode *o = out + i;
+        unsigned int m = (unsigned int)_mm256_movemask_epi8(
+           _mm256_loadu_si256((const __m256i *)in));
+
+        /* Widened whole, the bytes of the run and the ones past it: the caller
+         * overwrites those with what they decode to. */
+        _mm256_storeu_si256((__m256i *)o, _mm256_cvtepu8_epi32(
+                               _mm_loadl_epi64((const __m128i *)in)));
+        _mm256_storeu_si256((__m256i *)(o + 8), _mm256_cvtepu8_epi32(
+                               _mm_loadl_epi64((const __m128i *)(in + 8))));
+        _mm256_storeu_si256((__m256i *)(o + 16), _mm256_cvtepu8_epi32(
+                               _mm_loadl_epi64((const __m128i *)(in + 16))));
+        _mm256_storeu_si256((__m256i *)(o + 24), _mm256_cvtepu8_epi32(
+                               _mm_loadl_epi64((const __m128i *)(in + 24))));
+        if (m) return i + (size_t)__builtin_ctz(m);
+     }
+
+   /* Runs are short in terminal output: do not fall from 32 bytes to scalar. */
+   if (i + 16 <= len)
+     {
+        const unsigned char *in = buf + i;
+        Eina_Unicode *o = out + i;
+        unsigned int m = (unsigned int)_mm_movemask_epi8(
+           _mm_loadu_si128((const __m128i *)in));
+
+        _mm256_storeu_si256((__m256i *)o, _mm256_cvtepu8_epi32(
+                               _mm_loadl_epi64((const __m128i *)in)));
+        _mm256_storeu_si256((__m256i *)(o + 8), _mm256_cvtepu8_epi32(
+                               _mm_loadl_epi64((const __m128i *)(in + 8))));
+        if (m) return i + (size_t)__builtin_ctz(m);
+        i += 16;
+     }
+
+   for (; i < len; i++)
+     {
+        if (buf[i] >= 0x80) return i;
+        out[i] = buf[i];
+     }
+   return len;
+}
+
 #endif
diff --git a/src/bin/simd/simd_neon.c b/src/bin/simd/simd_neon.c
index 6a3fb976..db1e1531 100644
--- a/src/bin/simd/simd_neon.c
+++ b/src/bin/simd/simd_neon.c
@@ -176,4 +176,40 @@ simd_widen_ascii_neon(const unsigned char *buf, size_t len, Eina_Unicode *out)
      out[i] = buf[i];
 }
 
+size_t
+simd_widen_ascii_run_neon(const unsigned char *buf, size_t len,
+                          Eina_Unicode *out)
+{
+   const uint8x16_t high = vdupq_n_u8(0x80);
+   size_t i = 0;
+
+   for (; i + 16 <= len; i += 16)
+     {
+        uint8x16_t v = vld1q_u8(buf + i);
+        uint16x8_t w0 = vmovl_u8(vget_low_u8(v));
+        uint16x8_t w1 = vmovl_u8(vget_high_u8(v));
+        uint64_t m;
+
+        /* Widened whole, the bytes of the run and the ones past it: the caller
+         * overwrites those with what they decode to. */
+        vst1q_u32((uint32_t *)(out + i +  0), vmovl_u16(vget_low_u16(w0)));
+        vst1q_u32((uint32_t *)(out + i +  4), vmovl_u16(vget_high_u16(w0)));
+        vst1q_u32((uint32_t *)(out + i +  8), vmovl_u16(vget_low_u16(w1)));
+        vst1q_u32((uint32_t *)(out + i + 12), vmovl_u16(vget_high_u16(w1)));
+
+        /* One nibble per byte, as in simd_scan_plain_ascii_neon(). */
+        m = vget_lane_u64(vreinterpret_u64_u8(
+                             vshrn_n_u16(vreinterpretq_u16_u8(
+                                            vcgeq_u8(v, high)), 4)), 0);
+        if (m) return i + (size_t)(__builtin_ctzll(m) >> 2);
+     }
+
+   for (; i < len; i++)
+     {
+        if (buf[i] >= 0x80) return i;
+        out[i] = buf[i];
+     }
+   return len;
+}
+
 #endif
diff --git a/src/bin/simd/simd_scalar.c b/src/bin/simd/simd_scalar.c
index 61c36e96..7a91856f 100644
--- a/src/bin/simd/simd_scalar.c
+++ b/src/bin/simd/simd_scalar.c
@@ -61,3 +61,17 @@ simd_widen_ascii_scalar(const unsigned char *buf, size_t len, Eina_Unicode *out)
    for (i = 0; i < len; i++)
      out[i] = buf[i];
 }
+
+size_t
+simd_widen_ascii_run_scalar(const unsigned char *buf, size_t len,
+                            Eina_Unicode *out)
+{
+   size_t i;
+
+   for (i = 0; i < len; i++)
+     {
+        if (buf[i] >= 0x80) return i;
+        out[i] = buf[i];
+     }
+   return len;
+}
diff --git a/src/bin/simd/simd_sse2.c b/src/bin/simd/simd_sse2.c
index 87eaae23..dd96e11a 100644
--- a/src/bin/simd/simd_sse2.c
+++ b/src/bin/simd/simd_sse2.c
@@ -187,4 +187,36 @@ simd_widen_ascii_sse2(const unsigned char *buf, size_t len, Eina_Unicode *out)
      out[i] = buf[i];
 }
 
+size_t
+simd_widen_ascii_run_sse2(const unsigned char *buf, size_t len,
+                          Eina_Unicode *out)
+{
+   const __m128i zero = _mm_setzero_si128();
+   size_t i = 0;
+
+   for (; i + 16 <= len; i += 16)
+     {
+        __m128i v = _mm_loadu_si128((const __m128i *)(buf + i));
+        __m128i w0 = _mm_unpacklo_epi8(v, zero);
+        __m128i w1 = _mm_unpackhi_epi8(v, zero);
+        /* The top bit of every byte, which is what tells ASCII apart. */
+        unsigned int m = (unsigned int)_mm_movemask_epi8(v);
+
+        /* Widened whole, the bytes of the run and the ones past it: the caller
+         * overwrites those with what they decode to. */
+        _mm_storeu_si128((__m128i *)(out + i +  0), _mm_unpacklo_epi16(w0, zero));
+        _mm_storeu_si128((__m128i *)(out + i +  4), _mm_unpackhi_epi16(w0, zero));
+        _mm_storeu_si128((__m128i *)(out + i +  8), _mm_unpacklo_epi16(w1, zero));
+        _mm_storeu_si128((__m128i *)(out + i + 12), _mm_unpackhi_epi16(w1, zero));
+        if (m) return i + (size_t)__builtin_ctz(m);
+     }
+
+   for (; i < len; i++)
+     {
+        if (buf[i] >= 0x80) return i;
+        out[i] = buf[i];
+     }
+   return len;
+}
+
 #endif
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index c5361baf..ab529ff4 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -171,6 +171,7 @@ static struct {
        { "ty_escape_max", tytest_ty_escape_max},
        { "osc_arg_get", tytest_osc_arg_get},
        { "termpty_log_level", tytest_termpty_log_level},
+       { "utf8_decode", tytest_utf8_decode},
        { "osc_color_reset", tytest_osc_color_reset},
        { "osc_color_name", tytest_osc_color_name},
        { "xterm_parse_color", tytest_xterm_parse_color},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index e282a68f..5d052c89 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -126,6 +126,7 @@ int tytest_osc52_long_max(void);
 int tytest_ty_escape_max(void);
 int tytest_osc_arg_get(void);
 int tytest_termpty_log_level(void);
+int tytest_utf8_decode(void);
 int tytest_osc_color_reset(void);
 int tytest_osc_color_name(void);
 int tytest_xterm_parse_color(void);
diff --git a/src/bin/utf8.c b/src/bin/utf8.c
index f2d82bc5..35c9ca6b 100644
--- a/src/bin/utf8.c
+++ b/src/bin/utf8.c
@@ -65,27 +65,22 @@ utf8_to_codepoints(const char *buf, int len, Eina_Unicode *codepoints,
      {
         Eina_Unicode g;
 #if defined(TERMINOLOGY_HAVE_NEON) || defined(TERMINOLOGY_HAVE_SSE2)
-        size_t run;
-
-        /* Plain printable ASCII needs none of the per-character work below, so
-         * widen it a run at a time. The inline test on the first byte keeps
-         * mostly-non-ASCII input from calling the scanner per character.
+        /* Every byte below 0x80 decodes to itself, controls, NUL and DEL
+         * included, so the kernel widens up to the first byte with the high
+         * bit set whatever the escape sequences and line feeds in between.
+         * The inline test on the first byte keeps mostly-non-ASCII input from
+         * calling it per character.
          *
          * Compiled in only where there is a vector kernel to call. The scalar
-         * kernel walks the run exactly as the loop below does, so it can only
-         * pay for the same bytes twice -- and merely leaving this in the loop
-         * to be branched over costs the decoder ~8% on a scalar-only target. */
-        if (fast &&
-            ((unsigned char)buf[i] >= 0x20) && ((unsigned char)buf[i] < 0x7f))
-          run = simd_scan_plain_ascii((const unsigned char *)buf + i,
-                                      (size_t)(len - i));
-        else
-          run = 0;
-        /* Below this the scan-then-widen pair costs more than it saves. */
-        if (run >= 4)
+         * kernel walks the run exactly as the loop below does, and merely
+         * leaving this in the loop to be branched over costs the decoder ~8% on
+         * a scalar-only target. */
+        if (fast && ((unsigned char)buf[i] < 0x80))
           {
-             simd_widen_ascii((const unsigned char *)buf + i, run,
-                              codepoints + j);
+             size_t run = simd_widen_ascii_run((const unsigned char *)buf + i,
+                                               (size_t)(len - i),
+                                               codepoints + j);
+
              i += (int)run;
              j += (int)run;
              continue;
@@ -156,3 +151,128 @@ codepoint_to_utf8(Eina_Unicode g, char *txt)
         return 0;
      }
 }
+
+#if defined(BINARY_TYTEST)
+#include <assert.h>
+#include <string.h>
+
+/* What utf8_to_codepoints() does one character at a time, with no vector
+ * kernel in the way. */
+static int
+_decode_reference(const char *buf, int len, Eina_Unicode *codepoints,
+                  int *consumed)
+{
+   int i = 0, j = 0;
+
+   while (i < len)
+     {
+        if (buf[i])
+          {
+             if (((len - i) < UTF8_CARRY_MAX) && _utf8_truncated(buf + i, len - i))
+               break;
+             codepoints[j++] = eina_unicode_utf8_next_get(buf, &i);
+          }
+        else
+          {
+             codepoints[j++] = 0;
+             i++;
+          }
+     }
+   *consumed = i;
+   return j;
+}
+
+static int
+_random_input(char *buf, int max, unsigned int *seed)
+{
+   static const char *const pieces[] = {
+      "a", "hello", " ", "\033[38;2;1;2;3m", "\033[m", "\n", "\r\n", "\t",
+      "\x7f", "\x1f", "\xc3\xa9", "\xe2\x96\x80", "\xe4\xbd\xa0",
+      "\xf0\x9f\x98\x80", "\x80", "\xff", "\xc3", "\xe2\x96", "\xf0\x9f\x98"
+   };
+   int n = 0, i;
+
+   for (;;)
+     {
+        const char *p;
+        int l;
+
+        *seed = *seed * 1103515245u + 12345u;
+        i = (*seed >> 16) % (sizeof(pieces) / sizeof(pieces[0]) + 1);
+        if (i == sizeof(pieces) / sizeof(pieces[0]))
+          {
+             /* NUL cannot go through a string literal. */
+             if (n >= max) break;
+             buf[n++] = 0;
+             continue;
+          }
+        p = pieces[i];
+        l = strlen(p);
+        if (n + l > max) break;
+        memcpy(buf + n, p, l);
+        n += l;
+     }
+   return n;
+}
+
+/* The decoder gives what the one-character-at-a-time reference gives, for
+ * runs of ASCII with controls, NUL and DEL in them, around multibyte
+ * characters, cut at every length, and again when the input arrives in two
+ * reads with the cut-off character carried over. */
+int
+tytest_utf8_decode(void)
+{
+   unsigned int seed = 12345;
+   int round, len, cut;
+
+   simd_init();
+
+   for (round = 0; round < 40; round++)
+     {
+        char input[200];
+        int total = _random_input(input, 150 + round, &seed);
+
+        for (len = 0; len <= total; len++)
+          {
+             char buf[256];
+             Eina_Unicode want[256], got[256];
+             int want_consumed, got_consumed, want_n, got_n;
+
+             memcpy(buf, input, len);
+             buf[len] = '\0';
+             want_n = _decode_reference(buf, len, want, &want_consumed);
+             got_n = utf8_to_codepoints(buf, len, got, &got_consumed);
+             assert(got_n == want_n);
+             assert(got_consumed == want_consumed);
+             assert(!memcmp(got, want, want_n * sizeof(got[0])));
+          }
+
+        for (cut = 0; cut <= total; cut++)
+          {
+             char first[256], second[256];
+             Eina_Unicode want[256], got[256];
+             int want_consumed, got_consumed, left, n, want_n, got_n;
+
+             memcpy(first, input, cut);
+             first[cut] = '\0';
+             got_n = utf8_to_codepoints(first, cut, got, &got_consumed);
+             left = cut - got_consumed;
+             assert(left < UTF8_CARRY_MAX);
+             memcpy(second, first + got_consumed, left);
+             memcpy(second + left, input + cut, total - cut);
+             n = left + total - cut;
+             second[n] = '\0';
+             got_n += utf8_to_codepoints(second, n, got + got_n,
+                                         &got_consumed);
+
+             memcpy(first, input, total);
+             first[total] = '\0';
+             want_n = _decode_reference(first, total, want, &want_consumed);
+             /* The tail the second read cannot finish is left over in both. */
+             assert(got_n == want_n);
+             assert(!memcmp(got, want, want_n * sizeof(got[0])));
+          }
+     }
+   return 0;
+}
+#endif

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to