texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/convert_html.c (html_set_


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/convert_html.c (html_set_pages_files) (html_converter_initialize): initialize file_changed_counter in html_set_pages_files as it requires knowing the number of output files.
Date: Thu, 02 Nov 2023 09:57:35 -0400

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 3a64c83282 * tp/Texinfo/XS/convert/convert_html.c 
(html_set_pages_files) (html_converter_initialize): initialize 
file_changed_counter in html_set_pages_files as it requires knowing the number 
of output files.
3a64c83282 is described below

commit 3a64c8328280cd55036951398836d581d2ae0a2b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Nov 2 15:57:39 2023 +0100

    * tp/Texinfo/XS/convert/convert_html.c (html_set_pages_files)
    (html_converter_initialize): initialize file_changed_counter in
    html_set_pages_files as it requires knowing the number of output
    files.
    
    * tp/Texinfo/XS/convert/convert_html.c
    (convert_output_output_unit_internal): handle the case of no
    conversion to output encoding setup.
    
    * tp/Texinfo/XS/main/build_perl_info.c (init): initialize "utf-8"
    &output_conversions to be sure that it is set before other
    conversions.
    
    * tp/Texinfo/XS/main/utils.c (get_encoding_conversion): use strcasecmp
    to compare encoding names in a case-insensitive way.
---
 ChangeLog                            | 18 ++++++++++++++++++
 tp/Texinfo/XS/convert/convert_html.c | 32 ++++++++++++++++++++++----------
 tp/Texinfo/XS/main/build_perl_info.c | 18 ++++++++----------
 tp/Texinfo/XS/main/utils.c           | 11 ++++++-----
 4 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 46601275ae..40b17332d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2023-11-02  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/convert_html.c (html_set_pages_files)
+       (html_converter_initialize): initialize file_changed_counter in
+       html_set_pages_files as it requires knowing the number of output
+       files.
+
+       * tp/Texinfo/XS/convert/convert_html.c
+       (convert_output_output_unit_internal): handle the case of no
+       conversion to output encoding setup.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (init): initialize "utf-8"
+       &output_conversions to be sure that it is set before other
+       conversions.
+
+       * tp/Texinfo/XS/main/utils.c (get_encoding_conversion): use strcasecmp
+       to compare encoding names in a case-insensitive way.
+
 2023-11-02  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c (html_convert_output): correct
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 0eace7b80a..f5b3b655cd 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1949,6 +1949,12 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST 
*output_units,
         }
     }
 
+  /* initialize data that requires output_unit_files number */
+  self->file_changed_counter.list = (size_t *)
+      malloc (self->output_unit_files.number * sizeof (size_t));
+  memset (self->file_changed_counter.list, 0,
+          self->output_unit_files.number * sizeof (size_t));
+
   return files_source_info;
 }
 
@@ -2263,11 +2269,6 @@ html_converter_initialize (CONVERTER *self)
       memset (self->no_arg_formatted_cmd_translated.list, 0,
               self->no_arg_formatted_cmd.number * sizeof (enum command_id));
     }
-
-  self->file_changed_counter.list = (size_t *)
-      malloc (self->output_unit_files.number * sizeof (size_t));
-  memset (self->file_changed_counter.list, 0,
-          self->output_unit_files.number * sizeof (size_t));
 }
 
 void
@@ -3708,11 +3709,19 @@ convert_output_output_unit_internal (CONVERTER *self,
         }
       if (text->end)
         {
-          char *result = encode_with_iconv (conversion->iconv, text->text, 0);
-          size_t res_len = strlen (result)+1;
-          size_t write_len = fwrite (result, sizeof (char), res_len,
+          char *result;
+          size_t res_len;
+          size_t write_len;
+
+          if (conversion)
+            result = encode_with_iconv (conversion->iconv, text->text, 0);
+          else
+            result = text->text;
+          res_len = strlen (result)+1;
+          write_len = fwrite (result, sizeof (char), res_len,
                                      file_fh);
-          free (result);
+          if (conversion)
+            free (result);
           if (write_len != res_len)
             { /* register error message instead? */
               fprintf (stderr, "ERROR: write to %s failed (%zu/%zu)\n",
@@ -3861,8 +3870,11 @@ html_convert_output (CONVERTER *self, ELEMENT *root,
       ENCODING_CONVERSION *conversion = 0;
 
       if (self->conf->OUTPUT_ENCODING_NAME)
-        conversion = get_encoding_conversion (self->conf->OUTPUT_ENCODING_NAME,
+        {
+          conversion
+             = get_encoding_conversion (self->conf->OUTPUT_ENCODING_NAME,
                                               &output_conversions);
+        }
 
       if (self->conf->DEBUG > 0)
         fprintf (stderr, "DO Units with filenames\n");
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 96c8f1cd1b..be35cb0e09 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -41,7 +41,7 @@
 /* for GLOBAL_INFO ERROR_MESSAGE CONVERTER */
 #include "converter_types.h"
 #include "tree.h"
-/* for fatal output_unit_type_names
+/* for output_conversions fatal output_unit_type_names
    HMSF_* */
 #include "utils.h"
 /* for debugging */
@@ -75,11 +75,11 @@
      free below is redirected to Perl's implementation.  This could
      cause crashes if the two malloc/free implementations were different.  */
 
-#ifdef ENABLE_NLS
-
 int
 init (int texinfo_uninstalled, char *builddir)
 {
+#ifdef ENABLE_NLS
+
   setlocale (LC_ALL, "");
 
   /* Note: this uses the installed translations even when running an
@@ -87,19 +87,17 @@ init (int texinfo_uninstalled, char *builddir)
   bindtextdomain (PACKAGE, LOCALEDIR);
 
   textdomain (PACKAGE);
+#else
 
-  return 1;
-}
+#endif
 
-#else
+  /* do that before any other call to get_encoding_conversion with
+     &output_conversions. */
+  get_encoding_conversion ("utf-8", &output_conversions);
 
-int
-init (int texinfo_uninstalled, char *builddir)
-{
   return 1;
 }
 
-#endif
 
 static void element_to_perl_hash (ELEMENT *e);
 
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 1ee53f6402..b6a0fa7b73 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -238,7 +238,8 @@ width_multibyte (const char *text)
 
 
 /* encoding and decoding. Use iconv. */
-/* ENCODING should always be lower cased */
+/* conversion to or from utf-8 should always be set before other
+   conversion */
 ENCODING_CONVERSION *
 get_encoding_conversion (char *encoding,
                          ENCODING_CONVERSION_LIST *encodings_list)
@@ -251,10 +252,10 @@ get_encoding_conversion (char *encoding,
      Thoughts on this mapping are available near
      Texinfo::Common::encoding_name_conversion_map definition
   */
-  if (!strcmp (encoding, "us-ascii"))
+  if (!strcasecmp (encoding, "us-ascii"))
     conversion_encoding = "iso-8859-1";
 
-  if (!strcmp (encoding, "utf-8"))
+  if (!strcasecmp (encoding, "utf-8"))
     {
       if (encodings_list->number > 0)
         encoding_index = 0;
@@ -266,8 +267,8 @@ get_encoding_conversion (char *encoding,
       int i;
       for (i = 1; i < encodings_list->number; i++)
         {
-          if (!strcmp (conversion_encoding,
-                       encodings_list->list[i].encoding_name))
+          if (!strcasecmp (conversion_encoding,
+                           encodings_list->list[i].encoding_name))
             {
               encoding_index = i;
               break;



reply via email to

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