Author: brane
Date: Sat May 23 13:12:25 2026
New Revision: 1934534

Log:
Follow up to r1934533: svn_utf__cstring_utf8_grapheme_breaks is no longer
the back-end for svn_utf_cstring_utf8_width, so always require the pool
and result pointer arguments.

* subversion/include/private/svn_utf_private.h
  (svn_utf__cstring_utf8_grapheme_breaks): Update the docstring.

* subversion/libsvn_subr/utf8proc.c
  (svn_utf__cstring_utf8_grapheme_breaks): Remove the conditional bits that
   were intended to avoid grapheme allocation.

* subversion/tests/libsvn_subr/utf-test.c
  (test_utf8_grapheme_breaks): Add the required arguments to the invalid
   UTF8 string test.

Modified:
   subversion/trunk/subversion/include/private/svn_utf_private.h
   subversion/trunk/subversion/libsvn_subr/utf8proc.c
   subversion/trunk/subversion/tests/libsvn_subr/utf-test.c

Modified: subversion/trunk/subversion/include/private/svn_utf_private.h
==============================================================================
--- subversion/trunk/subversion/include/private/svn_utf_private.h       Sat May 
23 13:02:20 2026        (r1934533)
+++ subversion/trunk/subversion/include/private/svn_utf_private.h       Sat May 
23 13:12:25 2026        (r1934534)
@@ -311,10 +311,7 @@ typedef struct svn_utf__utf8_grapheme_t
  * grapheme in the returned array may not be complete; we don't check if
  * a grapheme break is allowed at the end bcause it's, well, the end.
  *
- * *GRAPHEMES will be NULL if CSTR is empty.
- *
- * If GRAPHEMES is NULL, the list of graphemes will not be allocated
- * and POOL may also be NULL.
+ * *GRAPHEMES will be set to NULL on return if CSTR is empty.
  *
  * If CSTR is not a valid UTF-8 string, the returned value will be -1.
  */

Modified: subversion/trunk/subversion/libsvn_subr/utf8proc.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/utf8proc.c  Sat May 23 13:02:20 
2026        (r1934533)
+++ subversion/trunk/subversion/libsvn_subr/utf8proc.c  Sat May 23 13:12:25 
2026        (r1934534)
@@ -614,7 +614,7 @@ svn_utf__cstring_utf8_grapheme_breaks(ap
                                       const char *cstr,
                                       apr_pool_t *pool)
 {
-  apr_array_header_t *breaks = NULL;
+  apr_array_header_t *breaks;
   apr_ssize_t total_width = 0;
 
   utf8proc_int32_t state = 0;
@@ -629,8 +629,7 @@ svn_utf__cstring_utf8_grapheme_breaks(ap
   const utf8proc_uint8_t *utf8 = (const utf8proc_uint8_t *)cstr;
   if (!*utf8)
     {
-      if (graphemes)
-        *graphemes = NULL;
+      *graphemes = NULL;
       return 0;
     }
 
@@ -638,8 +637,7 @@ svn_utf__cstring_utf8_grapheme_breaks(ap
   if (nbytes < 0)
     return -1;
 
-  if (graphemes)
-    breaks = apr_array_make(pool, 16, sizeof(svn_utf__utf8_grapheme_t));
+  breaks = apr_array_make(pool, 16, sizeof(svn_utf__utf8_grapheme_t));
   grapheme_width += utf8proc_charwidth(codepoint1);
   grapheme_end += nbytes;
   utf8 += nbytes;
@@ -652,14 +650,11 @@ svn_utf__cstring_utf8_grapheme_breaks(ap
 
       if (utf8proc_grapheme_break_stateful(codepoint1, codepoint2, &state))
         {
-          if (breaks)
-            {
-              svn_utf__utf8_grapheme_t grapheme;
-              grapheme.start = grapheme_start;
-              grapheme.end = grapheme_end;
-              grapheme.width = grapheme_width;
-              APR_ARRAY_PUSH(breaks, svn_utf__utf8_grapheme_t) = grapheme;
-            }
+          svn_utf__utf8_grapheme_t grapheme;
+          grapheme.start = grapheme_start;
+          grapheme.end = grapheme_end;
+          grapheme.width = grapheme_width;
+          APR_ARRAY_PUSH(breaks, svn_utf__utf8_grapheme_t) = grapheme;
 
           total_width += grapheme_width;
           grapheme_width = 0;
@@ -675,20 +670,16 @@ svn_utf__cstring_utf8_grapheme_breaks(ap
   /* Record the final grapheme. */
   if (grapheme_end > grapheme_start)
     {
-      if (breaks)
-        {
-          svn_utf__utf8_grapheme_t grapheme;
-          grapheme.start = grapheme_start;
-          grapheme.end = grapheme_end;
-          grapheme.width = grapheme_width;
-          APR_ARRAY_PUSH(breaks, svn_utf__utf8_grapheme_t) = grapheme;
-        }
+      svn_utf__utf8_grapheme_t grapheme;
+      grapheme.start = grapheme_start;
+      grapheme.end = grapheme_end;
+      grapheme.width = grapheme_width;
+      APR_ARRAY_PUSH(breaks, svn_utf__utf8_grapheme_t) = grapheme;
 
       total_width += grapheme_width;
     }
 
-  if (breaks && graphemes)
-    *graphemes = breaks;
+  *graphemes = breaks;
   return total_width;
 }
 

Modified: subversion/trunk/subversion/tests/libsvn_subr/utf-test.c
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/utf-test.c    Sat May 23 
13:02:20 2026        (r1934533)
+++ subversion/trunk/subversion/tests/libsvn_subr/utf-test.c    Sat May 23 
13:12:25 2026        (r1934534)
@@ -1042,7 +1042,7 @@ test_utf8_grapheme_breaks(apr_pool_t *po
   SVN_TEST_ASSERT(graphemes == NULL);
 
   SVN_TEST_INT_ASSERT(
-      svn_utf__cstring_utf8_grapheme_breaks(NULL, invalid, NULL), -1);
+      svn_utf__cstring_utf8_grapheme_breaks(&graphemes, invalid, pool), -1);
 
 #define STRING_LENGTH_FROM_GRAPHEMES \
   APR_ARRAY_IDX(graphemes, graphemes->nelts - 1, svn_utf__utf8_grapheme_t).end

Reply via email to