texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Decode init file names in messages


From: Patrice Dumas
Subject: branch master updated: Decode init file names in messages
Date: Sat, 05 Mar 2022 19:06:23 -0500

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 ce907a782c Decode init file names in messages
ce907a782c is described below

commit ce907a782c8867a2c76e5841c5f4aeff1bd6a43b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Mar 6 01:04:36 2022 +0100

    Decode init file names in messages
    
    * tp/Texinfo/Config.pm (_GNUT_decode_input, GNUT_load_init_file),
    tp/texi2any.pl (locate_and_load_init_file): add _GNUT_decode_input()
    in Texinfo::Config duplicating _decode_input() from texi2any.pl.
    Decode init file names in messages both in texi2any.pl and
    Texinfo::Config.
    
    Changes in comments in other files.
---
 ChangeLog                  | 12 ++++++++++++
 tp/TODO                    |  8 --------
 tp/Texinfo/Common.pm       |  5 +++--
 tp/Texinfo/Config.pm       | 23 ++++++++++++++++++++---
 tp/Texinfo/Convert/HTML.pm |  1 +
 tp/t/test_utils.pl         |  4 ++++
 tp/texi2any.pl             | 32 ++++++++++++++++++--------------
 7 files changed, 58 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0497e81864..0bd4c52217 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2022-03-06  Patrice Dumas  <pertusus@free.fr>
+
+       Decode init file names in messages
+
+       * tp/Texinfo/Config.pm (_GNUT_decode_input, GNUT_load_init_file),
+       tp/texi2any.pl (locate_and_load_init_file): add _GNUT_decode_input()
+       in Texinfo::Config duplicating _decode_input() from texi2any.pl.
+       Decode init file names in messages both in texi2any.pl and
+       Texinfo::Config.
+
+       Changes in comments in other files.
+
 2022-03-05  Gavin Smith  <gavinsmith0123@gmail.com>
 
        * tp/init/latex2html.pm (l2h_to_html): Do not call
diff --git a/tp/TODO b/tp/TODO
index 3f7479ea8e..dd8ad808c3 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -29,14 +29,6 @@ bytes.  To check that they can never be upgraded + document
  MACRO_EXPAND
  INTERNAL_LINKS
 
-
-
-
-Associated code to check, requires bytes in input both for directory and
-file name and return bytes
-locate_init_file
-
-
 Document bytes in input:
 create_destination_directory
 output_files_register_closed
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 3be5934289..0c438574b0 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1160,10 +1160,11 @@ foreach my $formattable_or_formatted_misc_command (
 
 
 # functions for main program.  Should not be called in user-defined code.
+# locate_init_file() is called in HTML Converter for htmlxref files.
 
-# file:        file name to locate. It can be a file path.
+# file:        file name to locate. It can be a file path. Binary string.
 # directories: a reference on a array containing a list of directories to
-#              search the file in.
+#              search the file in. Binary strings.
 # all_files:   if true collect all the files with that name, otherwise stop
 #              at first match.
 sub locate_init_file($$$)
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index dc06aa664d..4cccd92bf9 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -95,6 +95,19 @@ sub _GNUT_encode_message($)
   }
 }
 
+# duplicated from texi2any.pl
+sub _GNUT_decode_input($)
+{
+  my $text = shift;
+
+  my $encoding = texinfo_get_conf('DATA_INPUT_ENCODING_NAME');
+  if (defined($encoding)) {
+    return decode($encoding, $text);
+  } else {
+    return $text;
+  }
+}
+
 # duplicated from texi2any.pl
 sub _GNUT_document_warn($) {
   return if (texinfo_get_conf('NO_WARN'));
@@ -106,14 +119,18 @@ sub _GNUT_document_warn($) {
 }
 
 # called from texi2any.pl main program.
-# eval init file in the Texinfo::Config namespace.
+# eval $FILE in the Texinfo::Config namespace. $FILE should be a binary string.
 sub GNUT_load_init_file($) {
   my $file = shift;
   eval { require($file) ;};
   my $e = $@;
   if ($e ne '') {
-    _GNUT_document_warn(sprintf(__("error loading %s: %s\n"),
-                                 $file, $e));
+    # $e may not be correctly encoded, but it is not clear what is to
+    # be expected.  In the eval documentation there is only information
+    # on the string eval case, not the block eval used here, and the
+    # information is not particularly clear.
+    _GNUT_document_warn(sprintf(__("error loading %s: %s"),
+                _GNUT_decode_input($file), $e));
   }
 }
 
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index bba4f1cfba..9414e12bf1 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -6529,6 +6529,7 @@ my %htmlxref_entries = (
  'mono' => [ 'mono', 'chapter', 'section', 'node' ],
 );
 
+# $FILES is an array reference of file names binary strings.
 sub _parse_htmlxref_files($$)
 {
   my $self = shift;
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index fd39573000..97cdb91f2c 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -877,6 +877,10 @@ sub test($$)
   }
 
   my $init_file_directories = [$srcdir.'init/', $srcdir.'t/init/'];
+  # the init file names are supposed to be binary strings.  Since they
+  # are not encoded anywhere, probably only non ascii file names should
+  # be used.
+  # FIXME what if srcdir is non ascii (srcdir is truly a binary string).
   if ($parser_options and $parser_options->{'init_files'}) {
     foreach my $filename (@{$parser_options->{'init_files'}}) {
       my $file = Texinfo::Common::locate_init_file($filename,
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 7be6892c68..6e24d33886 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -321,9 +321,10 @@ my $main_program_default_options = {
 
 # determine configuration directories.
 
+# used as part of binary strings
 my $conf_file_name = 'Config' ;
 
-# directories for texinfo configuration files
+# directories for texinfo configuration files, used as part of binary strings.
 my @language_config_dirs = File::Spec->catdir($curdir, '.texinfo');
 push @language_config_dirs, File::Spec->catdir($ENV{'HOME'}, '.texinfo') 
                                 if (defined($ENV{'HOME'}));
@@ -333,6 +334,7 @@ push @language_config_dirs, File::Spec->catdir($datadir, 
'texinfo')
                                if (defined($datadir));
 my @texinfo_config_dirs = ($curdir, @language_config_dirs);
 
+# these variables are used as part of binary strings.
 my @program_config_dirs;
 my @program_init_dirs;
 
@@ -377,6 +379,19 @@ sub document_warn($) {
                    "%s: warning: %s\n"), $real_command_name, $text)));
 }
 
+sub _decode_input($)
+{
+  my $text = shift;
+
+  my $encoding = get_conf('DATA_INPUT_ENCODING_NAME');
+  if (defined($encoding)) {
+    return decode($encoding, $text);
+  } else {
+    return $text;
+  }
+}
+
+# arguments are binary strings.
 sub locate_and_load_init_file($$)
 {
   my $filename = shift;
@@ -387,7 +402,8 @@ sub locate_and_load_init_file($$)
     # evaluate the code in the Texinfo::Config namespace
     Texinfo::Config::GNUT_load_init_file($file);
   } else {
-    document_warn(sprintf(__("could not read init file %s"), $filename));
+    document_warn(sprintf(__("could not read init file %s"),
+                          _decode_input($filename)));
   }
 }
 
@@ -686,18 +702,6 @@ sub _get_converter_default($)
   return undef;
 }
 
-sub _decode_input($)
-{
-  my $text = shift;
-
-  my $encoding = get_conf('DATA_INPUT_ENCODING_NAME');
-  if (defined($encoding)) {
-    return decode($encoding, $text);
-  } else {
-    return $text;
-  }
-}
-
 # translation related todo to be done when the string change anyway to
 # avoid requiring translation
 sub makeinfo_help()



reply via email to

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