texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Common.pm (perl_encoding_name): add


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (perl_encoding_name): add function.
Date: Sat, 19 Oct 2024 17:09:56 -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 1f86a9371c * tp/Texinfo/Common.pm (perl_encoding_name): add function.
1f86a9371c is described below

commit 1f86a9371cf81d4a0ca638aa2511fedc6f16155d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 19 23:09:49 2024 +0200

    * tp/Texinfo/Common.pm (perl_encoding_name): add function.
    
    * tp/Texinfo/ParserNonXS.pm (get_parser_info),
    tp/Texinfo/XS/parsetexi/Parsetexi.pm (_get_parser_info): determine
    Perl encoding based on global_info input_encoding_name by calling
    perl_encoding_name.  Remove get_perl_encoding.  Note that the warning
    in get_perl_encoding was not kept, as it cannot happen since
    input_encoding_name is only set if the perl encoding is known in Perl
    parser, and if in a list of known encoding, all known by Perl in C.
---
 ChangeLog                            | 12 ++++++++++
 tp/Texinfo/Common.pm                 | 44 ++++++++++--------------------------
 tp/Texinfo/ParserNonXS.pm            | 11 +++++----
 tp/Texinfo/XS/parsetexi/Parsetexi.pm |  9 +++++---
 4 files changed, 37 insertions(+), 39 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a53aeef5c5..f734503e5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-10-19  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (perl_encoding_name): add function.
+
+       * tp/Texinfo/ParserNonXS.pm (get_parser_info),
+       tp/Texinfo/XS/parsetexi/Parsetexi.pm (_get_parser_info): determine
+       Perl encoding based on global_info input_encoding_name by calling
+       perl_encoding_name.  Remove get_perl_encoding.  Note that the warning
+       in get_perl_encoding was not kept, as it cannot happen since
+       input_encoding_name is only set if the perl encoding is known in Perl
+       parser, and if in a list of known encoding, all known by Perl in C.
+
 2024-10-19  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Makefile.tres: remove t/test_parser_registrar.t test, the
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index bee20542f1..69aa6fb850 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -669,33 +669,6 @@ sub _add_preamble_before_content($)
   unshift (@{$before_node_section->{'contents'}}, @first_types);
 }
 
-# Called in both Parsetexi.pm and perl parser
-sub get_perl_encoding($$;$)
-{
-  my $commands_info = shift;
-  my $registrar = shift;
-  my $debug = shift;
-
-  my $result;
-  if (defined($commands_info->{'documentencoding'})) {
-    foreach my $element (@{$commands_info->{'documentencoding'}}) {
-      my $perl_encoding = element_associated_processing_encoding($element);
-      if (!defined($perl_encoding)) {
-        my $encoding = $element->{'extra'}->{'input_encoding_name'}
-          if ($element->{'extra'});
-        if (defined($encoding)) {
-          $registrar->line_warn(
-                     sprintf(__("unrecognized encoding name `%s'"), $encoding),
-                                    $element->{'source_info'}, 0, $debug);
-        }
-      } else {
-        $result = $perl_encoding;
-      }
-    }
-  }
-  return $result;
-}
-
 # for Parser and main program
 sub warn_unknown_language($) {
   my $lang = shift;
@@ -1079,15 +1052,12 @@ sub locate_file_in_dirs($$$;$)
   return undef, undef;
 }
 
-sub element_associated_processing_encoding($)
+sub perl_encoding_name($)
 {
-  my $element = shift;
+  my $encoding = shift;
 
   my $perl_encoding;
 
-  my $encoding = $element->{'extra'}->{'input_encoding_name'}
-    if ($element->{'extra'});
-
   if (defined($encoding) and $encoding ne '') {
     $encoding = $encoding_name_conversion_map{$encoding}
       if (defined($encoding_name_conversion_map{$encoding}));
@@ -1102,6 +1072,16 @@ sub element_associated_processing_encoding($)
   return $perl_encoding;
 }
 
+sub element_associated_processing_encoding($)
+{
+  my $element = shift;
+
+  my $encoding = $element->{'extra'}->{'input_encoding_name'}
+    if ($element->{'extra'});
+
+  return perl_encoding_name($encoding);
+}
+
 # Reverse the decoding of the file name from the input encoding.  When
 # dealing with file names, we want Perl strings representing sequences of
 # bytes, not Unicode codepoints.
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 723ac0f152..e58ccc4010 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -914,12 +914,15 @@ sub get_parser_info($)
 
   my $document = $self->{'document'};
 
-  my $perl_encoding
-    = Texinfo::Common::get_perl_encoding($document->{'commands_info'},
-                                         $self->{'registrar'},
-                                         $self->{'conf'}->{'DEBUG'});
+  my $encoding = $document->{'global_info'}->{'input_encoding_name'};
+
+  my $perl_encoding = Texinfo::Common::perl_encoding_name($encoding);
   if (defined($perl_encoding)) {
     $document->{'global_info'}->{'input_perl_encoding'} = $perl_encoding
+  } elsif (defined($encoding)) {
+    $self->{'registrar'}->document_warn(
+      sprintf(__("unrecognized encoding name `%s'"), $encoding),
+        $self->{'conf'}->{'PROGRAM'});
   }
 
   my $global_commands = $document->{'commands_info'};
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm 
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index dc92c77dad..968f04800e 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -193,9 +193,12 @@ sub _get_parser_info($$;$) {
   }
 
   # additional info relevant in perl only.
-  my $perl_encoding
-    = Texinfo::Common::get_perl_encoding($document->{'commands_info'},
-                        $self->{'registrar'}, $self->{'conf'}->{'DEBUG'});
+  my $encoding = $document->{'global_info'}->{'input_encoding_name'};
+
+  my $perl_encoding = Texinfo::Common::perl_encoding_name($encoding);
+  if (defined($perl_encoding)) {
+    $document->{'global_info'}->{'input_perl_encoding'} = $perl_encoding
+  }
   $perl_encoding = 'utf-8' if (!defined($perl_encoding));
   Texinfo::Document::set_document_global_info($document,
                      'input_perl_encoding', $perl_encoding);



reply via email to

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