[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 13 Apr 2024 09:59:40 -0400 (EDT) |
branch: master
commit 8963c0bf7ec6ce128f0e05a7b825b3af9288f5af
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Apr 13 15:59:15 2024 +0200
* tp/tests/run_parser_all.sh: do not add a / at the end of $testdir,
one is already added in all the uses if needed.
* tp/Texinfo/Common.pm (output_files_opened_files), tp/texi2any.pl
(merge_opened_files): merge opened files with merge_opened_files in
texi2any.pl, not in output_files_opened_files,
output_files_opened_files simply returns the opened_files hash
reference. Warn if a file is opened more than once in
merge_opened_files.
* tp/tests/Makefile.onetst, tp/tests/formatting/list-of-tests
(reuse_macro_expand_file): test --macro-expand with the same name as
output file.
---
ChangeLog | 16 +++++++
tp/Texinfo/Common.pm | 13 +-----
tp/tests/Makefile.onetst | 1 +
tp/tests/formatting/list-of-tests | 3 ++
.../res_parser/reuse_macro_expand_file/simplest.1 | 0
.../res_parser/reuse_macro_expand_file/simplest.2 | 1 +
.../reuse_macro_expand_file/simplest.info | 23 +++++++++
tp/tests/run_parser_all.sh | 3 +-
.../formatting_reuse_macro_expand_file.sh | 19 ++++++++
tp/texi2any.pl | 54 ++++++++++++++++++----
10 files changed, 110 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e2e524cee9..4f096075d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-04-13 Patrice Dumas <pertusus@free.fr>
+
+ * tp/tests/run_parser_all.sh: do not add a / at the end of $testdir,
+ one is already added in all the uses if needed.
+
+ * tp/Texinfo/Common.pm (output_files_opened_files), tp/texi2any.pl
+ (merge_opened_files): merge opened files with merge_opened_files in
+ texi2any.pl, not in output_files_opened_files,
+ output_files_opened_files simply returns the opened_files hash
+ reference. Warn if a file is opened more than once in
+ merge_opened_files.
+
+ * tp/tests/Makefile.onetst, tp/tests/formatting/list-of-tests
+ (reuse_macro_expand_file): test --macro-expand with the same name as
+ output file.
+
2024-04-13 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Common.pm (output_files_open_out),
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 153064ce64..da727948e7 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -741,19 +741,10 @@ sub output_files_register_closed($$)
# consistency of the API and clarity of the code.
#
# see the description of $SELF in comment above output_files_open_out.
-# The $RESULT_OPENED_FILES argument should be an input output hash
-# reference to put opened files in.
-sub output_files_opened_files($$)
+sub output_files_opened_files($)
{
my $self = shift;
- my $result_opened_files = shift;
-
- if (defined($self->{'opened_files'})) {
- foreach my $opened_file (keys(%{$self->{'opened_files'}})) {
- # TODO warn if already exists
- $result_opened_files->{$opened_file} = 1;
- }
- }
+ return $self->{'opened_files'};
}
# see the description of $SELF in comment above output_files_open_out.
diff --git a/tp/tests/Makefile.onetst b/tp/tests/Makefile.onetst
index 51729ada8b..d92f360682 100644
--- a/tp/tests/Makefile.onetst
+++ b/tp/tests/Makefile.onetst
@@ -38,6 +38,7 @@ type_base_one_test_files_generated_list = \
test_scripts/formatting_index_entries_relate_to_item.sh \
test_scripts/formatting_info_extension_warning.sh \
test_scripts/formatting_js_license_reuse_output_file.sh \
+ test_scripts/formatting_reuse_macro_expand_file.sh \
test_scripts/encoded_non_ascii_command_line.sh \
test_scripts/encoded_non_ascii_test_epub.sh \
test_scripts/encoded_non_ascii_test_rawtext.sh \
diff --git a/tp/tests/formatting/list-of-tests
b/tp/tests/formatting/list-of-tests
index 42342b0d53..a2f280eb8a 100644
--- a/tp/tests/formatting/list-of-tests
+++ b/tp/tests/formatting/list-of-tests
@@ -40,3 +40,6 @@ info_extension_warning foo.info
# test JS_WEBLABELS_FILE set to a file already output as part of the manual
# formatting.
js_license_reuse_output_file split_nocopying.texi --html -c
JS_WEBLABELS_FILE=Ch1.html -c INFO_JS_DIR=js
+
+# test --macro-expand with the same name as output file.
+reuse_macro_expand_file simplest.texi --macro-expand=@OUT_DIR@simplest.info
diff --git a/tp/tests/formatting/res_parser/reuse_macro_expand_file/simplest.1
b/tp/tests/formatting/res_parser/reuse_macro_expand_file/simplest.1
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tp/tests/formatting/res_parser/reuse_macro_expand_file/simplest.2
b/tp/tests/formatting/res_parser/reuse_macro_expand_file/simplest.2
new file mode 100644
index 0000000000..3166ee084e
--- /dev/null
+++ b/tp/tests/formatting/res_parser/reuse_macro_expand_file/simplest.2
@@ -0,0 +1 @@
+texi2any: warning: overwritting file:
formatting/out_parser/reuse_macro_expand_file/simplest.info
diff --git
a/tp/tests/formatting/res_parser/reuse_macro_expand_file/simplest.info
b/tp/tests/formatting/res_parser/reuse_macro_expand_file/simplest.info
new file mode 100644
index 0000000000..53e0248258
--- /dev/null
+++ b/tp/tests/formatting/res_parser/reuse_macro_expand_file/simplest.info
@@ -0,0 +1,23 @@
+This is simplest.info, produced by texi2any version from simplest.texi.
+
+
+File: simplest.info, Node: Top, Up: (dir)
+
+top section
+***********
+
+1 Chapter
+*********
+
+This is a very simple texi manual <>.
+
+
+Tag Table:
+Node: Top73
+
+End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:
diff --git a/tp/tests/run_parser_all.sh b/tp/tests/run_parser_all.sh
index 16e8bb900a..070ce74cad 100755
--- a/tp/tests/run_parser_all.sh
+++ b/tp/tests/run_parser_all.sh
@@ -210,8 +210,7 @@ while [ z"$1" = 'z-clean' -o z"$1" = 'z-copy' -o z"$1" =
'z-dir' ]; do
fi
if [ z"$1" = 'z-dir' ]; then
shift
- #mydir=`echo "$1" | sed 's:/*$::'`'/'
- testdir=`echo "$1" | sed 's:/*$::'`'/'
+ testdir=`echo "$1" | sed 's:/*$::'`
shift
fi
done
diff --git a/tp/tests/test_scripts/formatting_reuse_macro_expand_file.sh
b/tp/tests/test_scripts/formatting_reuse_macro_expand_file.sh
new file mode 100755
index 0000000000..d97a859020
--- /dev/null
+++ b/tp/tests/test_scripts/formatting_reuse_macro_expand_file.sh
@@ -0,0 +1,19 @@
+#! /bin/sh
+# This file generated by maintain/regenerate_cmd_tests.sh
+
+if test z"$srcdir" = "z"; then
+ srcdir=.
+fi
+
+one_test_logs_dir=test_log
+
+
+dir=formatting
+name='reuse_macro_expand_file'
+mkdir -p $dir
+
+"$srcdir"/run_parser_all.sh -dir $dir $name
+exit_status=$?
+cat $dir/$one_test_logs_dir/$name.log
+exit $exit_status
+
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index ad61f1f044..88551f5f67 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1273,6 +1273,27 @@ sub _handle_errors($)
}
}
+# If the file overwritting becomes an error, should increase $ERROR_COUNT.
+sub merge_opened_files($$$)
+{
+ my $error_count = shift;
+ my $opened_files = shift;
+ my $newly_opened_files = shift;
+
+ if ($newly_opened_files) {
+ foreach my $opened_file (sort(keys(%$newly_opened_files))) {
+ if (exists($opened_files->{$opened_file})) {
+ document_warn(sprintf(__('overwritting file: %s'),
+ $opened_file));
+ } else {
+ $opened_files->{$opened_file} = 1;
+ }
+ }
+ }
+
+ return $error_count;
+}
+
# Avoid loading these modules until down here to speed up the case
# when they are not needed.
@@ -1598,8 +1619,12 @@ while(@input_files) {
$macro_expand_file_name, $error_message));
$error_macro_expand_file = 1;
}
- Texinfo::Common::output_files_opened_files(
- $macro_expand_files_information, \%opened_files);
+ my $macro_expand_opened_file =
+ Texinfo::Common::output_files_opened_files(
+ $macro_expand_files_information);
+ $error_macro_expand_file
+ = merge_opened_files($error_macro_expand_file, \%opened_files,
+ $macro_expand_opened_file);
# we do not need to go through unclosed files of
# $macro_expand_files_information as we know that the file is
@@ -1746,10 +1771,11 @@ while(@input_files) {
}
}
- # FIXME it is unlikely, but possible that a file registered with
- # MACRO_EXPAND is registered again in a converter
- Texinfo::Common::output_files_opened_files(
- $converter->output_files_information(), \%opened_files);
+ my $converter_opened_files
+ = Texinfo::Common::output_files_opened_files(
+ $converter->output_files_information());
+ $error_count = merge_opened_files($error_count, \%opened_files,
+ $converter_opened_files);
handle_errors($converter_registrar->errors(), $error_count, \%opened_files);
my $converter_unclosed_files
= Texinfo::Common::output_files_unclosed_files(
@@ -1806,8 +1832,12 @@ while(@input_files) {
$error_internal_links_file = 1;
}
- Texinfo::Common::output_files_opened_files(
- $internal_links_files_information, \%opened_files);
+ my $internal_links_opened_file
+ = Texinfo::Common::output_files_opened_files(
+ $internal_links_files_information);
+ $error_internal_links_file
+ = merge_opened_files($error_internal_links_file,
+ \%opened_files, $internal_links_opened_file);
# we do not need to go through unclosed files of
# $internal_links_files_information as we know that the file is
# already closed if needed.
@@ -1886,8 +1916,12 @@ while(@input_files) {
$error_sort_element_count_file = 1;
}
- Texinfo::Common::output_files_opened_files(
- $sort_elem_files_information, \%opened_files);
+ my $sort_element_count_file_opened_file
+ = Texinfo::Common::output_files_opened_files(
+ $sort_elem_files_information);
+ $error_sort_element_count_file
+ = merge_opened_files($error_sort_element_count_file,
+ \%opened_files, $sort_element_count_file_opened_file);
$converter_element_count->destroy();
# we do not need to go through unclosed files of