texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 13 Apr 2024 13:56:25 -0400 (EDT)

branch: master
commit 865a9193a3e7d54dd328b8ac4a1be83a3b32f7b6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Apr 13 18:46:26 2024 +0200

    * tp/Texinfo/Common.pm (locate_file_in_dirs): rename locate_init_file
    as locate_file_in_dirs.  Update callers.
---
 ChangeLog                  |  5 ++++
 tp/Texinfo/Common.pm       | 68 +++++++++++++++++++++++-----------------------
 tp/Texinfo/Convert/HTML.pm |  4 +--
 tp/t/test_utils.pl         |  4 +--
 tp/texi2any.pl             |  6 ++--
 5 files changed, 46 insertions(+), 41 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7a56ef9e29..abf5b56508 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-04-13  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (locate_file_in_dirs): rename locate_init_file
+       as locate_file_in_dirs.  Update callers.
+
 2024-04-13  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Common.pm (output_files_opened_files), tp/texi2any.pl
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 574c69194a..8ad9c6bd75 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -593,41 +593,9 @@ foreach my $command (
 }
 
 
-# functions for main program.  Should not be called in user-defined code.
-# FIXME locate_init_file() is also called in HTML Converter for htmlxref files.
-
-# $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. Binary strings.
-# $ALL_FILES:   if true collect all the files with that name, otherwise stop
-#               at first match.
-sub locate_init_file($$$)
-{
-  my $file = shift;
-  my $directories = shift;
-  my $all_files = shift;
-
-  if (File::Spec->file_name_is_absolute($file)) {
-    return $file if (-e $file and -r $file);
-  } else {
-    my @files;
-    foreach my $dir (@$directories) {
-      next unless (-d $dir);
-      my $possible_file = File::Spec->catfile($dir, $file);
-      if ($all_files) {
-        push (@files, $possible_file)
-          if (-e $possible_file and -r $possible_file);
-      } else {
-        return $possible_file if (-e $possible_file and -r $possible_file);
-      }
-    }
-    return @files if ($all_files);
-  }
-  return undef;
-}
-
 
-# API to open, set encoding and register files.
+# API to open, set encoding and register files.  Used in main program
+# and converters.
 # In general $SELF is stored as $converter->{'output_files'}
 # and should be accessed through $converter->output_files_information();
 
@@ -1172,6 +1140,38 @@ sub parse_node_manual($;$)
 
 # misc functions used in diverse contexts and useful in converters
 
+# Not documented, used in main program, tests and HML Converter.
+
+# $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. Binary strings.
+# $ALL_FILES:   if true collect all the files with that name, otherwise stop
+#               at first match.
+sub locate_file_in_dirs($$$)
+{
+  my $file = shift;
+  my $directories = shift;
+  my $all_files = shift;
+
+  if (File::Spec->file_name_is_absolute($file)) {
+    return $file if (-e $file and -r $file);
+  } else {
+    my @files;
+    foreach my $dir (@$directories) {
+      next unless (-d $dir);
+      my $possible_file = File::Spec->catfile($dir, $file);
+      if ($all_files) {
+        push (@files, $possible_file)
+          if (-e $possible_file and -r $possible_file);
+      } else {
+        return $possible_file if (-e $possible_file and -r $possible_file);
+      }
+    }
+    return @files if ($all_files);
+  }
+  return undef;
+}
+
 sub element_associated_processing_encoding($)
 {
   my $element = shift;
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f33425eb23..c3039061b7 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -8634,8 +8634,8 @@ sub _load_htmlxref_files {
       my ($encoded_htmlxref_file_name, $htmlxref_file_encoding)
         = $self->encoded_output_file_name($htmlxref_file_name);
       @htmlxref_files
-        = Texinfo::Common::locate_init_file($encoded_htmlxref_file_name,
-                                          \@htmlxref_dirs, 1);
+        = Texinfo::Common::locate_file_in_dirs($encoded_htmlxref_file_name,
+                                               \@htmlxref_dirs, 1);
     }
   }
 
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index da5831e5b9..d217c2a7f7 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -972,8 +972,8 @@ sub test($$)
       $symbols_before_init_file->{$symbol} = 1;
     }
     foreach my $filename (@{$parser_options->{'init_files'}}) {
-      my $file = Texinfo::Common::locate_init_file($filename,
-                                               $init_file_directories, 0);
+      my $file = Texinfo::Common::locate_file_in_dirs($filename,
+                                            $init_file_directories, 0);
       if (defined($file)) {
         Texinfo::Config::GNUT_load_init_file($file);
       } else {
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index b4b326e178..5991914d0d 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -458,7 +458,7 @@ sub locate_and_load_init_file($$)
   my $filename = shift;
   my $directories = shift;
 
-  my $file = Texinfo::Common::locate_init_file($filename, $directories, 0);
+  my $file = Texinfo::Common::locate_file_in_dirs($filename, $directories, 0);
   if (defined($file)) {
     # evaluate the code in the Texinfo::Config namespace
     Texinfo::Config::GNUT_load_init_file($file);
@@ -476,7 +476,7 @@ sub locate_and_load_extension_file($$)
   my $filename = shift;
   my $directories = shift;
 
-  my $file = Texinfo::Common::locate_init_file($filename, $directories, 0);
+  my $file = Texinfo::Common::locate_file_in_dirs($filename, $directories, 0);
   if (defined($file)) {
     # evaluate the code in the Texinfo::Config namespace
     Texinfo::Config::GNUT_load_init_file($file);
@@ -573,7 +573,7 @@ set_translations_encoding($translations_encoding);
 # read initialization files.  Better to do that after
 # Texinfo::Config::GNUT_initialize_customization() in case loaded
 # files replace default options.
-foreach my $file (Texinfo::Common::locate_init_file($conf_file_name,
+foreach my $file (Texinfo::Common::locate_file_in_dirs($conf_file_name,
                   [ reverse(@program_config_dirs) ], 1)) {
   Texinfo::Config::GNUT_load_init_file($file);
 }



reply via email to

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