texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: Wrapper for u8_strconv_to_encoding


From: Patrice Dumas
Subject: branch master updated: Wrapper for u8_strconv_to_encoding
Date: Tue, 20 Feb 2024 06:55:41 -0500

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

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new b32fd118ee Wrapper for u8_strconv_to_encoding
b32fd118ee is described below

commit b32fd118ee236bea637947ec06821034553d0572
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 20 12:55:37 2024 +0100

    Wrapper for u8_strconv_to_encoding
    
    * tp/Texinfo/XS/main/unicode.c (string_from_utf8):
    Create wrapper for u8_strconv_from_encoding to do the reverse of
    utf8_from_string.  All callers of u8_strconv_from_encoding updated.
    Also replace some incorrect calls of utf8_from_string by
    string_from_utf8.
---
 ChangeLog                               | 10 ++++++++++
 tp/Texinfo/XS/convert/convert_html.c    | 11 ++++-------
 tp/Texinfo/XS/convert/converter.c       |  3 +--
 tp/Texinfo/XS/main/manipulate_indices.c |  3 +--
 tp/Texinfo/XS/main/unicode.c            | 14 ++++++++++----
 tp/Texinfo/XS/main/unicode.h            |  1 +
 tp/Texinfo/XS/main/utils.c              |  5 ++---
 7 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f1f10f8215..fd5d88f30a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-20  Patrice Dumas  <pertusus@free.fr>
+
+       Wrapper for u8_strconv_to_encoding
+
+       * tp/Texinfo/XS/main/unicode.c (string_from_utf8):
+       Create wrapper for u8_strconv_from_encoding to do the reverse of
+       utf8_from_string.  All callers of u8_strconv_from_encoding updated.
+       Also replace some incorrect calls of utf8_from_string by
+       string_from_utf8.
+
 2024-02-20  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/build_perl_info.c (output_unit_to_perl_hash)
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 181e7d7b7b..92b30012bd 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -51,7 +51,7 @@
 #include "call_html_perl_function.h"
 /* for unregister_document_merge_with_document */
 #include "document.h"
-/* for OTXI_UNICODE_TEXT_CASES */
+/* for OTXI_UNICODE_TEXT_CASES utf8_from_string string_from_utf8 */
 #include "unicode.h"
 #include "manipulate_tree.h"
 /* for new_complete_menu_master_menu */
@@ -9461,8 +9461,7 @@ css_string_accent (CONVERTER *self, const char *text,
                           /* ASCII digits */
                           || (first_char >= 0x0030 && first_char <= 0x0039)))
                 {
-                  next_text = u8_strconv_to_encoding (next, "UTF-8",
-                                                      iconveh_question_mark);
+                  next_text = string_from_utf8 (next);
                 }
             }
           else
@@ -9509,8 +9508,7 @@ css_string_accent (CONVERTER *self, const char *text,
                       if (first_char_len < 0)
                         fatal ("u8_uctomb returns negative value");
                       first_char_u8[first_char_len] = 0;
-                      first_char_text = u8_strconv_to_encoding (first_char_u8,
-                                              "UTF-8", iconveh_question_mark);
+                      first_char_text = string_from_utf8 (first_char_u8);
                       free (first_char_u8);
                       text_append (&accented_text, first_char_text);
                       free (first_char_text);
@@ -9564,8 +9562,7 @@ css_string_accent (CONVERTER *self, const char *text,
           ucs4_t first_char;
           const uint8_t *next = u8_next (&first_char, encoded_u8);
           text_printf (&accented_text, "\\%04lX ", first_char);
-          next_text = u8_strconv_to_encoding (next, "UTF-8",
-                                              iconveh_question_mark);
+          next_text = string_from_utf8 (next);
           free (encoded_u8);
           text_append (&accented_text, next_text);
           free (next_text);
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 8012d58a37..98da0ecaee 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -1036,8 +1036,7 @@ next_for_tieaccent (const char *text, const char **next)
           if (first_char_len < 0)
             fatal ("u8_uctomb returns negative value");
           first_char_u8[first_char_len] = 0;
-          first_char_text = u8_strconv_to_encoding (first_char_u8, "UTF-8",
-                                                    iconveh_question_mark);
+          first_char_text = string_from_utf8 (first_char_u8);
           free (first_char_u8);
           p = text + strlen (first_char_text);
           *next = p;
diff --git a/tp/Texinfo/XS/main/manipulate_indices.c 
b/tp/Texinfo/XS/main/manipulate_indices.c
index 387833d868..0a880479b7 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.c
+++ b/tp/Texinfo/XS/main/manipulate_indices.c
@@ -1075,8 +1075,7 @@ sort_indices_by_letter (DOCUMENT *document, 
ERROR_MESSAGE_LIST *error_messages,
                   if (first_char_len < 0)
                     fatal ("u8_uctomb returns negative value");
                   first_char_u8[first_char_len] = 0;
-                  first_char_text = u8_strconv_to_encoding (first_char_u8,
-                                               "UTF-8", iconveh_question_mark);
+                  first_char_text = string_from_utf8 (first_char_u8);
                   free (first_char_u8);
                   text_append (&letter_text, first_char_text);
                   free (first_char_text);
diff --git a/tp/Texinfo/XS/main/unicode.c b/tp/Texinfo/XS/main/unicode.c
index 38a29d57e8..473274179c 100644
--- a/tp/Texinfo/XS/main/unicode.c
+++ b/tp/Texinfo/XS/main/unicode.c
@@ -44,6 +44,12 @@ utf8_from_string (const char *text)
   return u8_strconv_from_encoding (text, "UTF-8", iconveh_question_mark);
 }
 
+char *
+string_from_utf8 (const uint8_t *encoded_u8)
+{
+  return u8_strconv_to_encoding (encoded_u8, "UTF-8", iconveh_question_mark);
+}
+
 char *
 normalize_NFC (const char *text)
 {
@@ -56,7 +62,7 @@ normalize_NFC (const char *text)
                                          u8_strlen (encoded_u8)+1,
                                          NULL, &lengthp);
   free (encoded_u8);
-  result = utf8_from_string (normalized_u8);
+  result = string_from_utf8 (normalized_u8);
   free (normalized_u8);
   return result;
 }
@@ -73,7 +79,7 @@ normalize_NFKD (const char *text)
                                          u8_strlen (encoded_u8)+1,
                                          NULL, &lengthp);
   free (encoded_u8);
-  result = utf8_from_string (normalized_u8);
+  result = string_from_utf8 (normalized_u8);
   free (normalized_u8);
   return result;
 }
@@ -135,13 +141,13 @@ unicode_accent (const char *text, const ELEMENT *e)
                   if (first_char_len < 0)
                     fatal ("u8_uctomb returns negative value");
                   first_char_u8[first_char_len] = 0;
-                  first_char_text = utf8_from_string (first_char_u8);
+                  first_char_text = string_from_utf8 (first_char_u8);
                   free (first_char_u8);
                   text_init (&accented_text);
                   text_append (&accented_text, first_char_text);
                   free (first_char_text);
                   text_append (&accented_text, 
unicode_diacritics[e->cmd].text);
-                  next_text = utf8_from_string (next);
+                  next_text = string_from_utf8 (next);
                   text_append (&accented_text, next_text);
                   free (next_text);
                   result = normalize_NFC (accented_text.text);
diff --git a/tp/Texinfo/XS/main/unicode.h b/tp/Texinfo/XS/main/unicode.h
index 7911ea2d33..417917fe09 100644
--- a/tp/Texinfo/XS/main/unicode.h
+++ b/tp/Texinfo/XS/main/unicode.h
@@ -80,6 +80,7 @@ extern DIACRITIC_UNICODE unicode_diacritics[];
 extern COMMAND_UNICODE unicode_character_brace_no_arg_commands[];
 
 uint8_t *utf8_from_string (const char *text);
+char *string_from_utf8 (const uint8_t *encoded_u8);
 
 int unicode_point_decoded_in_encoding (const char *encoding, char *codepoint);
 
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index e6a376eef1..e10d954e87 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -44,8 +44,8 @@
 #include "debug.h"
 #include "builtin_commands.h"
 #include "api_to_perl.h"
-#include "utils.h"
 #include "unicode.h"
+#include "utils.h"
 
 #define min_level command_structuring_level[CM_chapter]
 #define max_level command_structuring_level[CM_subsubsection]
@@ -218,8 +218,7 @@ to_upper_or_lower_multibyte (const char *text, int 
lower_or_upper)
                             NULL, NULL, NULL, &lengthp);
 
   free (u8_text);
-  result = u8_strconv_to_encoding (u8_result, "UTF-8",
-                                   iconveh_question_mark);
+  result = string_from_utf8 (u8_result);
   free (u8_result);
   return result;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]