texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Tue, 9 Jan 2024 08:08:18 -0500 (EST)

branch: master
commit 1d315262f22514ce13c639010c4b6b6127018260
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jan 9 13:51:14 2024 +0100

    * tp/Texinfo/Convert/Text.pm (copy_options_for_convert_text): replace
    the $enable_encoding_if_not_ascii argument by additional options
    argument.  Change return to be a reference on an hash, not an hash.
    Update callers.
---
 tp/Texinfo/Convert/Converter.pm |  2 +-
 tp/Texinfo/Convert/Text.pm      | 30 +++++++++++++++++-------------
 tp/Texinfo/Structuring.pm       | 12 +++++++-----
 tp/t/convert_to_text.t          |  2 +-
 4 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 1f6f7a7f0c..0afa2985ca 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -332,7 +332,7 @@ sub converter($;$)
   $converter->converter_initialize();
 
   $converter->{'convert_text_options'}
-      = {Texinfo::Convert::Text::copy_options_for_convert_text($converter)};
+      = Texinfo::Convert::Text::copy_options_for_convert_text($converter);
 
 
   return $converter;
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index ec80099f04..317e08f555 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -390,19 +390,14 @@ my @text_indicator_converter_options = 
('NUMBER_SECTIONS', 'ASCII_GLYPH', 'TEST'
 # $SELF is typically a converter object.
 # Setup options as used by Texinfo::Convert::Text::convert_to_text
 # based on the converter information.
-# if $ENABLE_ENCODING_IF_NOT_ASCII is set, enabled_encoding is set
-# unless the encoding is ascii, even if ENABLE_ENCODING is not set.
 # This is relevant for file names, for instance.
 sub copy_options_for_convert_text($;$)
 {
   my $self = shift;
-  my $enable_encoding_if_not_ascii = shift;
+  my $options_in = shift;
   my %options;
-  if (($self->get_conf('ENABLE_ENCODING')
-       and $self->get_conf('OUTPUT_ENCODING_NAME'))
-      or ($enable_encoding_if_not_ascii
-          and $self->get_conf('OUTPUT_ENCODING_NAME')
-          and $self->get_conf('OUTPUT_ENCODING_NAME') ne 'us-ascii')) {
+  if ($self->get_conf('ENABLE_ENCODING')
+       and $self->get_conf('OUTPUT_ENCODING_NAME')) {
     $options{'enabled_encoding'} = $self->get_conf('OUTPUT_ENCODING_NAME');
   }
 
@@ -419,7 +414,13 @@ sub copy_options_for_convert_text($;$)
   $options{'INCLUDE_DIRECTORIES'} = $self->get_conf('INCLUDE_DIRECTORIES');
 
   $options{'converter'} = $self;
-  return %options;
+
+  if ($options_in) {
+    foreach my $option (keys(%$options_in)) {
+      $options{$option} = $options_in->{$option};
+    }
+  }
+  return \%options;
 }
 
 sub set_options_code($)
@@ -434,6 +435,8 @@ sub reset_options_code($)
   $options->{'_code_state'}--;
 }
 
+# set enabled_encoding unless the encoding is ascii, even if
+# ENABLE_ENCODING is not set.
 sub set_options_encoding_if_not_ascii($$)
 {
   my $self = shift;
@@ -458,7 +461,8 @@ sub set_options_encoding($$)
   my $encoding = shift;
   if (defined($options->{'_saved_enabled_encoding'})) {
      print STDERR "BUG: _saved_enabled_encoding set: "
-                          .$options->{'_saved_enabled_encoding'}."\n";
+                          .$options->{'_saved_enabled_encoding'}." / ".
+                            $encoding."\n";
   }
   $options->{'_saved_enabled_encoding'} = $options->{'enabled_encoding'};
   $options->{'enabled_encoding'} = $encoding;
@@ -995,13 +999,13 @@ sub output($$)
     }
   }
   # mostly relevant for 'enabled_encoding', other options should be the same.
-  my %options = copy_options_for_convert_text($self);
+  my $options = copy_options_for_convert_text($self);
   # remove $self Text converter without translation nor error reporting.
-  delete $options{'converter'};
+  delete $options->{'converter'};
   # Some functions call $self->get_conf(), so the options need to be a blessed
   # reference, merge specific Text options with $self (possibly
   # overwriting/ignoring but values should be the same).
-  %$self = (%$self, %options);
+  %$self = (%$self, %$options);
 
   my $result;
   # Interface with XS converter.
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 94a9c20af9..5ffb9e17e2 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -2272,15 +2272,17 @@ sub setup_index_entry_keys_formatting($)
 {
   my $customization_info = shift;
 
-  my $options = {
-     Texinfo::Convert::Text::copy_options_for_convert_text(
-                                  $customization_info)};
+  my $additional_options = {};
+
   if (not $customization_info->get_conf('ENABLE_ENCODING')
       or lc($customization_info->get_conf('OUTPUT_ENCODING_NAME')) ne 'utf-8') 
{
-    $options->{'sort_string'} = 1;
+    $additional_options->{'sort_string'} = 1;
   }
 
-  return $options;
+  my $text_options
+    = 
Texinfo::Convert::Text::copy_options_for_convert_text($customization_info,
+                                                           
$additional_options);
+  return $text_options;
 }
 
 # can be used for subentries.
diff --git a/tp/t/convert_to_text.t b/tp/t/convert_to_text.t
index 56a4095bdb..63b425b1e3 100644
--- a/tp/t/convert_to_text.t
+++ b/tp/t/convert_to_text.t
@@ -92,7 +92,7 @@ $converter->set_global_document_commands('preamble_or_first',
 #print STDERR "DOCUMENTLANGUAGE 
".$converter->get_conf('documentlanguage')."\n";
 
 my $text_options
- = {Texinfo::Convert::Text::copy_options_for_convert_text($converter)};
+ = Texinfo::Convert::Text::copy_options_for_convert_text($converter);
 
 my $result_text
  = Texinfo::Convert::Text::convert_to_text($document->tree(), $text_options);



reply via email to

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