[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Common.pm (locate_file_in_dirs): if
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Common.pm (locate_file_in_dirs): if the input file path contains directories, returns it if it is found but do not search it in directories. |
Date: |
Sun, 25 Aug 2024 10:01:36 -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 b8d026cc70 * tp/Texinfo/Common.pm (locate_file_in_dirs): if the input
file path contains directories, returns it if it is found but do not search it
in directories.
b8d026cc70 is described below
commit b8d026cc70c242c9090cb1e0c0a8588e1fb9851f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 25 16:01:36 2024 +0200
* tp/Texinfo/Common.pm (locate_file_in_dirs): if the input file path
contains directories, returns it if it is found but do not search it
in directories.
* doc/texi2any_api.texi (Loading Init Files), doc/texinfo.texi (File
Names and Links Customization for HTML): update documentation.
---
ChangeLog | 11 ++++++++++-
doc/texi2any_api.texi | 10 ++++++----
doc/texinfo.texi | 7 ++++---
tp/Texinfo/Common.pm | 38 ++++++++++++++++++++++++--------------
4 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 46ff610423..72baa7719f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,16 @@
+2024-08-25 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm (locate_file_in_dirs): if the input file path
+ contains directories, returns it if it is found but do not search it
+ in directories.
+
+ * doc/texi2any_api.texi (Loading Init Files), doc/texinfo.texi (File
+ Names and Links Customization for HTML): update documentation.
+
2024-08-25 Patrice Dumas <pertusus@free.fr>
* doc/texinfo.texi (HTML Xref Link Basics, HTML Xref Configuration):
- remove teh "HTML Xref Mismatch" node, it is not the best way to go and
+ remove the "HTML Xref Mismatch" node, it is not the best way to go and
somewhat obsolete. Keep the information in tp/TODO. Add some
information on mismatched cross-references in the last paragraphs of
"HTML Xref Link Basics".
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index e9cd961cbb..583b9537ce 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -133,10 +133,12 @@ Thus, @file{./texi2any-config.pm} can override entries
in, say,
@c @opindex --init-file
@cindex @option{--init-file}
-However, the most common way to load an initialization file is with
-the @option{--init-file} option, explicitly specifying the file to be
-loaded. By default the following directories are searched, in the
-following order. Only the first file found is used:
+However, the most common way to load an initialization file path is with
+the @option{--init-file} option, explicitly specifying the file path to be
+loaded. If the initialization file path contains directories, it is loaded
+if found. Otherwise, if the file path is a simple file name, the following
+directories are searched, in the following order by default. Only the first
+file found is used:
@enumerate
@item The current directory @file{./};
diff --git a/doc/texinfo.texi b/doc/texinfo.texi
index f03777aa0f..9538814e1c 100644
--- a/doc/texinfo.texi
+++ b/doc/texinfo.texi
@@ -18230,9 +18230,10 @@ as the source of information. If @code{HTMLXREF_MODE}
is set to @samp{none}
no information is used. The default case is obtained with @code{HTMLXREF_MODE}
not defined or set to any other value. The @code{HTMLXREF_FILE} customization
variable sets the file used for HTML Xref configuration to another value than
-the default, @file{htmlxref.cnf}. By default, the distant manual
-is considered to be split or monolithic based on the splitting of the manual
-being output. You can set it explicitely, instead, by setting
+the default, @file{htmlxref.cnf}. If @code{HTMLXREF_FILE} contains
directories,
+it is loaded if found, but is not searched for in directories. By default, the
+distant manual is considered to be split or monolithic based on the splitting
+of the manual being output. You can set it explicitely, instead, by setting
@code{EXTERNAL_CROSSREF_SPLIT}.
@cindex Cross-references customization, in HTML
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index f37da48086..6af9bc4ae2 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1141,32 +1141,42 @@ sub output_files_unclosed_files($)
# Used in main program, tests and HTML Converter.
# TODO document?
#
-# $FILE: file name to locate. It can be a file path. Binary string.
+# $INPUT_FILE_PATH: file name to locate. Binary string. If it is a file
+# path, it is not searched for in directories.
# $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 $input_file_path = shift;
my $directories = shift;
my $all_files = shift;
- if (File::Spec->file_name_is_absolute($file)) {
- return $file if (-e $file and -r $file);
+ if (File::Spec->file_name_is_absolute($input_file_path)) {
+ return $input_file_path if (-e $input_file_path and -r $input_file_path);
} 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);
+ my ($volume, $path_directories, $file)
+ = File::Spec->splitpath($input_file_path);
+ my @path_directories = File::Spec->splitdir($path_directories);
+ if (scalar(@path_directories) > 0) {
+ # do not search in directories if the file name already contains
+ # directories.
+ return $input_file_path if (-e $input_file_path and -r $input_file_path);
+ } else {
+ my @files;
+ foreach my $dir (@$directories) {
+ next unless (-d $dir);
+ my $possible_file = File::Spec->catfile($dir, $input_file_path);
+ 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 @files if ($all_files);
}
return undef;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Common.pm (locate_file_in_dirs): if the input file path contains directories, returns it if it is found but do not search it in directories.,
Patrice Dumas <=