* tta/C/main/manipulate_indices.c (setup_index_entries_sort_strings): use a cast to convert char *to uint8_t * and avoid a useless copy of the string. * tta/C/main/manipulate_indices.c (setup_index_entries_sort_strings): use locale variables for code clarity. * tta/C/main/unicode.c (utf8_from_string, string_from_utf8): remove comments, assume that casting is always a good way to convert between char and uint8_t.
diff --git a/ChangeLog b/ChangeLog index 08f7f6c..140d9e7 100644 --- a/ChangeLog +++ b/ChangeLog
@@ -1,6 +1,19 @@ 2026-05-29 Patrice Dumas <pertusus@free.fr> - * tta/C/texi2any.c (main): oad a Perl interpreter for the options + * tta/C/main/manipulate_indices.c (setup_index_entries_sort_strings): + use a cast to convert char *to uint8_t * and avoid a useless copy + of the string. + + * tta/C/main/manipulate_indices.c (setup_index_entries_sort_strings): + use locale variables for code clarity. + + * tta/C/main/unicode.c (utf8_from_string, string_from_utf8): remove + comments, assume that casting is always a good way to convert between + char and uint8_t. + +2026-05-29 Patrice Dumas <pertusus@free.fr> + + * tta/C/texi2any.c (main): load a Perl interpreter for the options triggering calling Perl functions from C, DOCUMENTLANGUAGE_COLLATION and COLLATION_LANGUAGE. Handle txi_sort_element_counts return value being NULL, even though it cannot happen right now because
diff --git a/tta/C/main/manipulate_indices.c b/tta/C/main/manipulate_indices.c index b56d12e..405ad0a 100644 --- a/tta/C/main/manipulate_indices.c +++ b/tta/C/main/manipulate_indices.c
@@ -512,6 +512,7 @@ for (l = 0; l < subentries_list.number; l++) { const ELEMENT *subentry = subentries_list.list[l]; + INDEX_SUBENTRY_SORT_STRING *subentry_sort_string; entry_sort_string.subentries_number++; @@ -569,23 +570,16 @@ for (k = 0; k < entry_sort_string.subentries_number; k++) { - uint8_t *encoded_u8; ucs4_t next_char; - int new_len; - - subentry_sort_string + INDEX_SUBENTRY_SORT_STRING *subentry_sort_string = &entry_sort_string.sort_string_subentries[k]; - /* TODO somewhat inefficient, only need the first character */ - encoded_u8 - = utf8_from_string (subentry_sort_string->sort_string); - new_len = u8_strmbtouc (&next_char, encoded_u8); + int new_len = u8_strmbtouc (&next_char, + (uint8_t *) subentry_sort_string->sort_string); if (new_len > 0 && uc_is_property (next_char, UC_PROPERTY_ALPHABETIC)) subentry_sort_string->alpha = 1; else subentry_sort_string->alpha = 0; - - free (encoded_u8); } memcpy (&index_sort_strings->sort_string_entries[nr-1],
diff --git a/tta/C/main/unicode.c b/tta/C/main/unicode.c index 6032c22..950f8b7 100644 --- a/tta/C/main/unicode.c +++ b/tta/C/main/unicode.c
@@ -84,20 +84,12 @@ utf8_from_string (const char *text) { return (uint8_t *) strdup (text); - - /* With uniconv gnulib module this could be the following, although - this pulls in quite a few other gnulib module dependencies. */ - /* TODO error checking? */ - /* return u8_strconv_from_encoding (text, "UTF-8", iconveh_question_mark); */ } char * string_from_utf8 (const uint8_t *encoded_u8) { return strdup ((char *) encoded_u8); - /* With uniconv gnulib module this could be the following, although - this pulls in quite a few other gnulib module dependencies. */ - /* return u8_strconv_to_encoding (encoded_u8, "UTF-8", iconveh_question_mark); */ } char *