texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_units_dire


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_units_directions_files): encode to UTF-8 all the input strings, they are all character strings.
Date: Sun, 22 Oct 2023 08:11:36 -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 36e4f557dc * tp/Texinfo/Convert/HTML.pm 
(_prepare_units_directions_files): encode to UTF-8 all the input strings, they 
are all character strings.
36e4f557dc is described below

commit 36e4f557dcfdac17e41c3046fb37125336aedac7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 22 14:11:33 2023 +0200

    * tp/Texinfo/Convert/HTML.pm (_prepare_units_directions_files):
    encode to UTF-8 all the input strings, they are all character strings.
    
    * tp/Texinfo/XS/main/build_perl_info.c (build_html_files_source_info)
    (build_html_elements_in_file_count, build_filenames)
    (build_file_counters, build_out_filepaths): set all the output strings
    as character strings, as is the case for all the strings in the HTML
    converter.
    
    * tp/Texinfo/XS/convert/convert_html.c (prepare_special_units):
    define variable before, minor change.
---
 ChangeLog                            | 14 ++++++++++++++
 tp/Texinfo/Convert/HTML.pm           | 12 ++++++++----
 tp/Texinfo/XS/convert/convert_html.c |  4 +++-
 tp/Texinfo/XS/main/build_perl_info.c | 29 +++++++++++++++--------------
 4 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c3bdd50532..16253b56e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-10-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_prepare_units_directions_files):
+       encode to UTF-8 all the input strings, they are all character strings.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (build_html_files_source_info)
+       (build_html_elements_in_file_count, build_filenames)
+       (build_file_counters, build_out_filepaths): set all the output strings
+       as character strings, as is the case for all the strings in the HTML
+       converter.
+
+       * tp/Texinfo/XS/convert/convert_html.c (prepare_special_units):
+       define variable before, minor change.
+
 2023-10-21  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/Convert/ParagraphNonXS.pm (add_next, add_text):
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 8ff6497fd9..fb04475233 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9304,18 +9304,21 @@ sub _prepare_units_directions_files($$$$$$$$)
   my $output_filename = shift;
   my $document_name = shift;
 
-  if (0 and $self->{'converter_descriptor'}) {
-  #if ($self->{'converter_descriptor'}) {
+  if ($self->{'converter_descriptor'}) {
     my $encoded_converter = $self->encode_converter_for_output();
     my $encoded_document_name = Encode::encode('UTF-8', $document_name);
+    my $encoded_output_file = Encode::encode('UTF-8', $output_file);
+    my $encoded_destination_directory
+         = Encode::encode('UTF-8', $destination_directory);
+    my $encoded_output_filename = Encode::encode('UTF-8', $output_filename);
 
     my ($XS_files_source_info, $global_units_directions,
         $elements_in_file_count, $filenames,
         $file_counters, $out_filepaths)
       = _XS_prepare_units_directions_files($encoded_converter,
            $output_units, $special_units, $associated_special_units,
-           $output_file, $destination_directory, $output_filename,
-           $encoded_document_name);
+           $encoded_output_file, $encoded_destination_directory,
+           $encoded_output_filename, $encoded_document_name);
     $self->{'global_units_directions'} = $global_units_directions;
     $self->{'elements_in_file_count'} = $elements_in_file_count;
 
@@ -11627,6 +11630,7 @@ sub output($$)
       }
       $files{$output_unit_filename}->{'body'} .= $body;
       $self->{'file_counters'}->{$output_unit_filename}--;
+
       if ($self->{'file_counters'}->{$output_unit_filename} == 0) {
         my $file_output_unit = $files{$output_unit_filename}->{'first_unit'};
         my ($encoded_out_filepath, $path_encoding)
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 33c40757b3..26b26f93e9 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -685,8 +685,10 @@ prepare_special_units (CONVERTER *self, int 
output_units_descriptor,
   for (i = 0; i < do_special->number; i++)
     {
       /* take the string from special_unit_varieties */
+      char *special_unit_variety;
       int special_unit_varieties_idx = -1;
       int j;
+
       for (j = 0; j < special_unit_varieties->number; j++)
         if (!strcmp (special_unit_varieties->list[j],
                      special_units_order[i].variety))
@@ -702,7 +704,7 @@ prepare_special_units (CONVERTER *self, int 
output_units_descriptor,
           bug (msg);
         }
 
-      char *special_unit_variety = special_unit_varieties->list[j];
+      special_unit_variety = special_unit_varieties->list[j];
       OUTPUT_UNIT *special_output_unit
                     = register_special_unit (self, special_unit_variety);
       add_to_output_unit_list (special_units,
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index eaaa292f89..3def7b6fc3 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1604,19 +1604,19 @@ build_html_files_source_info (FILE_SOURCE_INFO_LIST 
*files_source_info)
           HV *file_source_info_hv;
           SV *file_source_info_sv;
           char *filename = file_source_info->filename;
+          SV *filename_sv = newSVpv_utf8 (filename, 0);
 
           file_source_info_hv = newHV ();
           file_source_info_sv = newRV_noinc ((SV *) file_source_info_hv);
 
-          hv_store (hv, filename, strlen (filename), file_source_info_sv, 0);
+          hv_store_ent (hv, filename_sv, file_source_info_sv, 0);
 
           STORE("file_info_type", newSVpv_utf8 (file_source_info->type, 0));
           if (file_source_info->name)
             STORE("file_info_name", newSVpv_utf8 (file_source_info->name, 0));
+          /* not actually used in downstream code, but present also in perl */
           if (file_source_info->path)
-            /* FIXME check encoding */
-            STORE("file_info_path", newSVpv (file_source_info->path,
-                                             strlen (file_source_info->path)));
+            STORE("file_info_path", newSVpv_utf8 (file_source_info->path, 0));
           else
             STORE("file_info_path", newSV(0));
 
@@ -1686,9 +1686,10 @@ build_html_elements_in_file_count (
           FILE_NAME_PATH_COUNTER *output_unit_file
             = &output_unit_files->list[i];
           char *filename = output_unit_file->filename;
+          SV *filename_sv = newSVpv_utf8 (filename, 0);
 
-          hv_store (hv, filename, strlen (filename),
-                    newSViv (output_unit_file->elements_in_file_count), 0);
+          hv_store_ent (hv, filename_sv,
+                        newSViv (output_unit_file->elements_in_file_count), 0);
         }
     }
 
@@ -1712,10 +1713,10 @@ build_filenames (FILE_NAME_PATH_COUNTER_LIST 
*output_unit_files)
           FILE_NAME_PATH_COUNTER *output_unit_file
             = &output_unit_files->list[i];
           char *normalized_filename = output_unit_file->normalized_filename;
+          SV *normalized_filename_sv = newSVpv_utf8 (normalized_filename, 0);
 
-          hv_store (hv, normalized_filename, strlen (normalized_filename),
-                    newSVpv (output_unit_file->filename,
-                             strlen (output_unit_file->filename)), 0);
+          hv_store_ent (hv, normalized_filename_sv,
+                    newSVpv_utf8 (output_unit_file->filename, 0), 0);
         }
     }
 
@@ -1739,9 +1740,9 @@ build_file_counters (FILE_NAME_PATH_COUNTER_LIST 
*output_unit_files)
           FILE_NAME_PATH_COUNTER *output_unit_file
             = &output_unit_files->list[i];
           char *filename = output_unit_file->filename;
+          SV *filename_sv = newSVpv_utf8 (filename, 0);
 
-          hv_store (hv, filename, strlen (filename),
-                    newSViv (output_unit_file->counter), 0);
+          hv_store_ent (hv, filename_sv, newSViv (output_unit_file->counter), 
0);
         }
     }
 
@@ -1765,10 +1766,10 @@ build_out_filepaths (FILE_NAME_PATH_COUNTER_LIST 
*output_unit_files)
           FILE_NAME_PATH_COUNTER *output_unit_file
             = &output_unit_files->list[i];
           char *filename = output_unit_file->filename;
+          SV *filename_sv = newSVpv_utf8 (filename, 0);
 
-          hv_store (hv, filename, strlen (filename),
-                    newSVpv (output_unit_file->filepath,
-                             strlen (output_unit_file->filepath)), 0);
+          hv_store_ent (hv, filename_sv,
+                        newSVpv_utf8 (output_unit_file->filepath, 0), 0);
         }
     }
 



reply via email to

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