texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Revert "Revert commit afca9f95f8dcca047ad9." and


From: Patrice Dumas
Subject: branch master updated: Revert "Revert commit afca9f95f8dcca047ad9." and fix
Date: Fri, 04 Aug 2023 05:07:10 -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 1a21355dd1 Revert "Revert commit afca9f95f8dcca047ad9." and fix
1a21355dd1 is described below

commit 1a21355dd1b50a796e35d9fc55c76b94424b126e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Aug 4 11:01:27 2023 +0200

    Revert "Revert commit afca9f95f8dcca047ad9." and fix
    
    Readd the change
    2023-07-28  Patrice Dumas  <pertusus@free.fr>
    
      * tp/texi2any.pl (set_translations_encoding): reset translations
      encoding when COMMAND_LINE_ENCODING is reset.
      * tp/texi2any.pl: move code around for a more logical organization.
    
    with a fix of the bug that lead to the error, by really passing
    set_translations_encoding argument.
---
 ChangeLog            |  16 ----
 tp/Texinfo/Config.pm |   5 +-
 tp/texi2any.pl       | 202 ++++++++++++++++++++++++++++++---------------------
 3 files changed, 121 insertions(+), 102 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aaaca6300a..195ba6a5df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,19 +1,3 @@
-2023-08-03  Gavin Smith <gavinsmith0123@gmail.com>
-
-       Revert commit afca9f95f8dcca047ad9.
-
-       This reverts the following change:
-
-       2023-07-28  Patrice Dumas  <pertusus@free.fr>
-
-         * tp/texi2any.pl (set_translations_encoding): reset translations
-         encoding when COMMAND_LINE_ENCODING is reset.
-         * tp/texi2any.pl: move code around for a more logical organization.
-
-       Werner Lemberg reported incorrectly encoded output for
-       "makeinfo --help" for LANG=en_US.UTF-8 LANGUAGE=de and tracked it
-       down to this commit.
-
 2023-08-03  Gavin Smith <gavinsmith0123@gmail.com>
 
        * doc/texinfo.texi: Use trailing comma before 'or' more
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 2f5149e0e0..5655be02d5 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -121,6 +121,7 @@ sub _GNUT_document_warn($) {
                    "%s: warning: %s"), $real_command_name, $text)."\n"));
 }
 
+# used to register messages by the user with texinfo_register_init_loading_*
 my @init_file_loading_messages;
 # called from texi2any.pl main program and t/test_utils.pl.
 # eval $FILE in the Texinfo::Config namespace. $FILE should be a binary string.
@@ -170,7 +171,7 @@ sub texinfo_register_init_loading_error($) {
                                             'text' => $message};
 }
 
-# called from init files in case for warnings during loading.
+# called from init files in case of warnings at loading.
 sub texinfo_register_init_loading_warning($) {
   my $message = shift;
   push @{$init_file_loading_messages[-1]}, {'type' => 'warning',
@@ -353,7 +354,7 @@ my @possible_stages = ('setup', 'structure', 'init', 
'finish');
 
 my $default_priority = 'default';
 
-# FIXME add another level with format?  Not needed now as HTML is
+# TODO add another level with format?  Not needed now as HTML is
 # the only customizable format for now.
 my $GNUT_stage_handlers;
 
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 7c55efd351..3f8710191e 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -25,7 +25,7 @@ require 5.00405;
 
 use strict;
 
-# Through rules in Makefile.am directory paths set through configure are
+# Through rules in Makefile.am, directory paths set through configure are
 # substituted directly in strings in the code, for example
 #   my $datadir = '@datadir@';
 # We always use these strings as byte string, therefore we explicitly
@@ -133,6 +133,7 @@ my $path_separator = $Config{'path_sep'};
 $path_separator = ':' if (!defined($path_separator));
 my $quoted_path_separator = quotemeta($path_separator);
 
+
 # Paths and file names
 my $curdir = File::Spec->curdir();
 my $updir = File::Spec->updir();
@@ -171,14 +172,6 @@ if ('@datadir@' ne '@' . 'datadir@' and '@PACKAGE@' ne '@' 
. 'PACKAGE@') {
   $pkgdatadir = File::Spec->catdir($datadir, 'texinfo');
 }
 
-# work-around in case libintl-perl do not do it itself
-# see 
http://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable
-
-if ((defined($ENV{"LC_ALL"}) and $ENV{"LC_ALL"} =~ /^(C|POSIX)$/)
-     or (defined($ENV{"LANG"}) and $ENV{"LANG"} =~ /^(C|POSIX)$/)) {
-  delete $ENV{"LANGUAGE"} if defined($ENV{"LANGUAGE"});
-}
-
 my $extensions_dir;
 if ($Texinfo::ModulePath::texinfo_uninstalled) {
   $extensions_dir = File::Spec->catdir($Texinfo::ModulePath::top_srcdir,
@@ -189,6 +182,16 @@ if ($Texinfo::ModulePath::texinfo_uninstalled) {
 
 my $internal_extension_dirs = [$extensions_dir];
 
+
+# initial setup of messages internalisation framework
+# work-around in case libintl-perl do not do it itself
+# see 
http://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable
+
+if ((defined($ENV{"LC_ALL"}) and $ENV{"LC_ALL"} =~ /^(C|POSIX)$/)
+     or (defined($ENV{"LANG"}) and $ENV{"LANG"} =~ /^(C|POSIX)$/)) {
+  delete $ENV{"LANGUAGE"} if defined($ENV{"LANGUAGE"});
+}
+
 #my $messages_textdomain = 'texinfo';
 my $messages_textdomain = '@PACKAGE@';
 $messages_textdomain = 'texinfo' if ($messages_textdomain eq '@'.'PACKAGE@');
@@ -196,7 +199,6 @@ my $strings_textdomain = '@PACKAGE@' . '_document';
 $strings_textdomain = 'texinfo_document'
    if ($strings_textdomain eq '@'.'PACKAGE@' . '_document');
 
-
 # we want a reliable way to switch locale, so we don't use the system
 # gettext.
 Locale::Messages->select_package('gettext_pp');
@@ -219,6 +221,8 @@ Locale::Messages::bindtextdomain($messages_textdomain,
                                 File::Spec->catdir($datadir, 'locale'));
 
 
+# Set initial configuration
+
 # Version setting is complicated, because we cope with
 # * script with configure values substituted or not
 # * script shipped as part of texinfo or as a standalone perl module
@@ -272,7 +276,6 @@ if ($configured_version ne $Texinfo::Common::VERSION
   die "Your installation of Texinfo is broken; aborting.\n";
 }
 
-
 my $configured_package = '@PACKAGE@';
 $configured_package = 'Texinfo' if ($configured_package eq '@' . 'PACKAGE@');
 my $configured_name = '@PACKAGE_NAME@';
@@ -363,6 +366,7 @@ my $main_program_default_options = {
   %Texinfo::Common::default_main_program_customization_options,
 };
 
+
 # determine configuration directories.
 
 # used as part of binary strings
@@ -400,6 +404,7 @@ foreach my $texinfo_config_dir (@language_config_dirs) {
 # can also be loaded as regular init files.
 push @program_init_dirs, $extensions_dir;
 
+
 sub _decode_i18n_string($$)
 {
   my $string = shift;
@@ -493,15 +498,27 @@ sub remove_from_option_list($$) {
   return &Texinfo::Config::texinfo_remove_from_option_list(@_);
 }
 
-my @input_file_suffixes = ('.txi','.texinfo','.texi','.txinfo','');
+sub set_translations_encoding($)
+{
+  my $translations_encoding = shift;
+
+  if (defined($translations_encoding)
+      and $translations_encoding ne 'us-ascii') {
+    my $Encode_encoding_object = find_encoding($translations_encoding);
+    my $perl_translations_encoding = $Encode_encoding_object->name();
+
+    Locale::Messages::bind_textdomain_codeset($messages_textdomain,
+                                              $translations_encoding);
+    if (defined($perl_translations_encoding)) {
+      Locale::Messages::bind_textdomain_filter($messages_textdomain,
+                    \&_decode_i18n_string, $perl_translations_encoding);
+    }
+  }
+}
 
-my @texi2dvi_args = ();
 
-my %possible_split = (
-  'chapter' => 1,
-  'section' => 1,
-  'node' => 1,
-);
+# Setup customization and read customization files processed each time
+# the program is run
 
 # this associates the command line options to the arrays set during
 # command line parsing.
@@ -541,19 +558,9 @@ my $parser_options = {'values' => 
{'txicommandconditionals' => 1}};
 my $init_files_options = Texinfo::Config::GNUT_initialize_config(
       $real_command_name, $main_program_default_options, $cmdline_options);
 
-# FIXME should we reset the messages encoding if 'COMMAND_LINE_ENCODING'
-# is reset?
-my $messages_encoding = get_conf('COMMAND_LINE_ENCODING');
-if (defined($messages_encoding) and $messages_encoding ne 'us-ascii') {
-  my $Encode_encoding_object = find_encoding($messages_encoding);
-  my $perl_messages_encoding = $Encode_encoding_object->name();
-  Locale::Messages::bind_textdomain_codeset($messages_textdomain,
-                                            $messages_encoding);
-  if ($perl_messages_encoding) {
-    Locale::Messages::bind_textdomain_filter($messages_textdomain,
-                          \&_decode_i18n_string, $perl_messages_encoding);
-  }
-}
+# Need to do that early for early messages
+my $translations_encoding = get_conf('COMMAND_LINE_ENCODING');
+set_translations_encoding($translations_encoding);
 
 # read initialization files.  Better to do that after
 # Texinfo::Config::GNUT_initialize_config() in case loaded
@@ -563,6 +570,18 @@ foreach my $file 
(Texinfo::Common::locate_init_file($conf_file_name,
   Texinfo::Config::GNUT_load_init_file($file);
 }
 
+# reset translations encodings if COMMAND_LINE_ENCODING was reset
+my $set_translations_encoding = get_conf('COMMAND_LINE_ENCODING');
+if (defined($set_translations_encoding)
+    and (not defined($translations_encoding)
+         or $set_translations_encoding ne $translations_encoding)) {
+  $translations_encoding = $set_translations_encoding;
+  set_translations_encoding($translations_encoding);
+}
+
+
+# Parse command line
+
 sub set_expansion($$) {
   my $region = shift;
   my $set = shift;
@@ -576,6 +595,12 @@ sub set_expansion($$) {
   }
 }
 
+my %possible_split = (
+  'chapter' => 1,
+  'section' => 1,
+  'node' => 1,
+);
+
 my $format_from_command_line = 0;
 
 my %format_command_line_names = (
@@ -674,6 +699,7 @@ my %formats_table = (
 );
 
 my $call_texi2dvi = 0;
+my @texi2dvi_args = ();
 
 # previous_format should be in argument if there is a possibility of error.
 # as a fallback, the $format global variable is used.
@@ -721,58 +747,6 @@ sub set_format($;$$)
   return $new_format;
 }
 
-sub _exit($$)
-{
-  my $error_count = shift;
-  my $opened_files = shift;
-
-  if ($error_count and $opened_files and !get_conf('FORCE')) {
-    while (@$opened_files) {
-      my $opened_file = shift (@$opened_files);
-      unlink ($opened_file);
-    }
-  }
-  exit (1) if ($error_count and (!get_conf('FORCE')
-     or $error_count > get_conf('ERROR_LIMIT')));
-}
-
-sub handle_errors($$$)
-{
-  my $self = shift;
-  my $error_count = shift;
-  my $opened_files = shift;
-
-  my ($errors, $new_error_count) = $self->errors();
-  $error_count += $new_error_count if ($new_error_count);
-  foreach my $error_message (@$errors) {
-    if ($error_message->{'type'} eq 'error' or !get_conf('NO_WARN')) {
-      my $s = '';
-      if ($error_message->{'file_name'}) {
-        my $file = $error_message->{'file_name'};
-
-        if (get_conf('TEST')) {
-          # otherwise out of source build fail since the file names
-          # are different
-          my ($directories, $suffix);
-          ($file, $directories, $suffix) = fileparse($file);
-        }
-        $s .= "$file:";
-      }
-      if (defined($error_message->{'line_nr'})) {
-        $s .= $error_message->{'line_nr'} . ':';
-      }
-      $s .= ' ' if ($s ne '');
-
-      $s .= _encode_message($error_message->{'error_line'});
-      warn $s;
-    }
-  }
-
-  _exit($error_count, $opened_files);
-  return $error_count;
-}
-
-
 sub _get_converter_default($)
 {
   my $option = shift;
@@ -1124,7 +1098,6 @@ There is NO WARRANTY, to the extent permitted by 
law.\n"), "2022");
                    push @texi2dvi_args, '--'.$_[0]; },
 );
 
-
 exit 1 if (!$result_options);
 
 # those are strings combined with output so decode
@@ -1132,6 +1105,15 @@ my $ref_css_refs = get_conf('CSS_REFS');
 my @input_css_refs = @{$ref_css_refs};
 @$ref_css_refs = map {_decode_input($_)} @input_css_refs;
 
+# reset translations encoding if COMMAND_LINE_ENCODING was reset
+$set_translations_encoding = get_conf('COMMAND_LINE_ENCODING');
+if (defined($set_translations_encoding)
+    and (not defined($translations_encoding)
+         or $set_translations_encoding ne $translations_encoding)) {
+  $translations_encoding = $set_translations_encoding;
+  set_translations_encoding($translations_encoding);
+}
+
 # Change some options depending on the settings of other ones set formats
 sub process_config {
   my $conf = shift;
@@ -1180,6 +1162,7 @@ if (get_conf('TEST')) {
   }
 }
 
+my @input_file_suffixes = ('.txi','.texinfo','.texi','.txinfo','');
 
 my %format_names = (
  'info' => 'Info',
@@ -1228,6 +1211,57 @@ if ($call_texi2dvi) {
   document_warn(__('--Xopt option without printed output'));
 }
 
+sub _exit($$)
+{
+  my $error_count = shift;
+  my $opened_files = shift;
+
+  if ($error_count and $opened_files and !get_conf('FORCE')) {
+    while (@$opened_files) {
+      my $opened_file = shift (@$opened_files);
+      unlink ($opened_file);
+    }
+  }
+  exit (1) if ($error_count and (!get_conf('FORCE')
+     or $error_count > get_conf('ERROR_LIMIT')));
+}
+
+sub handle_errors($$$)
+{
+  my $self = shift;
+  my $error_count = shift;
+  my $opened_files = shift;
+
+  my ($errors, $new_error_count) = $self->errors();
+  $error_count += $new_error_count if ($new_error_count);
+  foreach my $error_message (@$errors) {
+    if ($error_message->{'type'} eq 'error' or !get_conf('NO_WARN')) {
+      my $s = '';
+      if ($error_message->{'file_name'}) {
+        my $file = $error_message->{'file_name'};
+
+        if (get_conf('TEST')) {
+          # otherwise out of source build fail since the file names
+          # are different
+          my ($directories, $suffix);
+          ($file, $directories, $suffix) = fileparse($file);
+        }
+        $s .= "$file:";
+      }
+      if (defined($error_message->{'line_nr'})) {
+        $s .= $error_message->{'line_nr'} . ':';
+      }
+      $s .= ' ' if ($s ne '');
+
+      $s .= _encode_message($error_message->{'error_line'});
+      warn $s;
+    }
+  }
+
+  _exit($error_count, $opened_files);
+  return $error_count;
+}
+
 require Texinfo::Parser;
 require Texinfo::Structuring;
 require Texinfo::Transformations;



reply via email to

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