[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Wed, 2 Oct 2024 11:42:48 -0400 (EDT) |
branch: master
commit e4bce32157ab63eb65e15ad38dfd8e933588b477
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Aug 1 11:39:56 2024 +0200
* tp/Texinfo/Convert/Utils.pm (output_files_initialize)
(output_files_disable_output_encoding, output_files_open_out)
(output_files_register_closed, output_files_opened_files)
(output_files_unclosed_files), tp/Texinfo/Common.pm: move output files
open/close API from Common.pm to Convert/Utils.pm.
* tp/Texinfo/Convert/Converter.pm (_internal_converter_initialize):
initialize error_warning_messages in _internal_converter_initialize.
---
ChangeLog | 11 +++
tp/Texinfo/Common.pm | 133 -----------------------------------
tp/Texinfo/Convert/Converter.pm | 12 ++--
tp/Texinfo/Convert/HTML.pm | 12 ++--
tp/Texinfo/Convert/IXIN.pm | 4 +-
tp/Texinfo/Convert/Info.pm | 6 +-
tp/Texinfo/Convert/LaTeX.pm | 4 +-
tp/Texinfo/Convert/Plaintext.pm | 10 +--
tp/Texinfo/Convert/Text.pm | 6 +-
tp/Texinfo/Convert/Utils.pm | 133 +++++++++++++++++++++++++++++++++++
tp/Texinfo/XS/main/build_perl_info.c | 2 +-
tp/ext/epub3.pm | 16 ++---
tp/init/chm.pm | 15 ++--
tp/t/test_utils.pl | 2 +-
tp/texi2any.pl | 30 ++++----
15 files changed, 206 insertions(+), 190 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5e0b9c01f1..183a7f1ae2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,17 @@
Add TODO item from Bruno CI.
+2024-08-01 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Utils.pm (output_files_initialize)
+ (output_files_disable_output_encoding, output_files_open_out)
+ (output_files_register_closed, output_files_opened_files)
+ (output_files_unclosed_files), tp/Texinfo/Common.pm: move output files
+ open/close API from Common.pm to Convert/Utils.pm.
+
+ * tp/Texinfo/Convert/Converter.pm (_internal_converter_initialize):
+ initialize error_warning_messages in _internal_converter_initialize.
+
2024-08-01 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/utils.c (html_get_direction_index),
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index e98cf0d835..aa7b9afe7b 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1019,139 +1019,6 @@ sub parse_node_manual($;$)
# misc functions used in diverse contexts and useful in converters
-# 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();
-
-# TODO next four functions not documented anywhere, probably relevant to
-# document both in POD and in HTML Customization API.
-sub output_files_initialize
-{
- return {'unclosed_files' => {}, 'opened_files' => {}};
-}
-
-sub output_files_disable_output_encoding($$)
-{
- my ($self, $no_output_encoding) = @_;
-
- $self->{'output_encoding_disabled'} = $no_output_encoding;
-}
-
-# All the opened files are registered, except for stdout,
-# and the closing of files should be registered too with
-# output_files_register_closed() below. This makes possible to
-# unlink all the opened files and close the files not already
-# closed.
-#
-# $FILE_PATH is the file path, it should be a binary string.
-# If $USE_BINMODE is set, call binmode() to set binary mode.
-# $OUTPUT_ENCODING argument overrides the output encoding.
-# Returns
-# - the opened filehandle, or undef if opening failed,
-# - the $! error message or undef if opening succeeded.
-# - 1 if the $FILE_PATH was already opened, which means overwritting.
-sub output_files_open_out($$$;$$)
-{
- my $self = shift;
- my $customization_information = shift;
- my $file_path = shift;
- my $use_binmode = shift;
- my $output_encoding = shift;
-
- #if (!defined($file_path)) {
- # cluck('output_files_open_out: file_path undef');
- #}
-
- my $encoding;
- if ($self->{'output_encoding_disabled'}) {
- # leave $encoding undefined
- } elsif (defined($output_encoding)) {
- $encoding = $output_encoding;
- } elsif (defined(
- $customization_information->get_conf('OUTPUT_PERL_ENCODING'))) {
- $encoding = $customization_information->get_conf('OUTPUT_PERL_ENCODING');
- }
-
- if ($file_path eq '-') {
- binmode(STDOUT) if $use_binmode;
- binmode(STDOUT, ":encoding($encoding)") if (defined($encoding));
- if ($self) {
- $self->{'unclosed_files'}->{$file_path} = \*STDOUT;
- }
- return \*STDOUT, undef;
- }
-
- # Check that this file has not already been registered
- # as opened_file. If yes, it will be overwritten if open succeeds.
- # It is not possible to use the file name twice in converters
- # for regular output as files are only closed when all the output
- # units have been written. It could be possible in HTML with js
- # scripts licence file set by the user to the same name as an output
- # file.
- my $overwritten_file = 0;
- # NOTE paths are not normalized, therefore different paths names
- # that refers to the same file will not be found.
- if (exists($self->{'opened_files'}->{$file_path})) {
- $overwritten_file = 1;
- }
- my $filehandle = do { local *FH };
- if (!open($filehandle, '>', $file_path)) {
- my $error_message = $!;
- return undef, $error_message, $overwritten_file;
- }
- # If $use_binmode is true, we run binmode to turn off outputting LF as CR LF
- # under MS-Windows, so that Info tag tables will have correct offsets. This
- # must be done before setting the encoding filters with binmode.
- binmode($filehandle) if $use_binmode;
- if ($encoding) {
- binmode($filehandle, ":encoding($encoding)");
- }
- if ($self) {
- if ($self->{'unclosed_files'}->{$file_path}) {
- warn "BUG: already open: $file_path\n";
- } else {
- $self->{'opened_files'}->{$file_path} = 1;
- }
- $self->{'unclosed_files'}->{$file_path} = $filehandle;
- }
- return $filehandle, undef, $overwritten_file;
-}
-
-# see the description of $SELF in comment above output_files_open_out.
-#
-# $FILE_PATH is the file path, it should be a binary string.
-sub output_files_register_closed($$)
-{
- my $self = shift;
- my $file_path = shift;
- if ($self->{'unclosed_files'}->{$file_path}) {
- delete $self->{'unclosed_files'}->{$file_path};
- } else {
- cluck "BUG: $file_path not opened\n";
- }
-}
-
-# The next two functions should not be called from user-defined
-# code, only from the main program. They are defined here for
-# consistency of the API and clarity of the code.
-#
-# see the description of $SELF in comment above output_files_open_out.
-sub output_files_opened_files($)
-{
- my $self = shift;
- return $self->{'opened_files'};
-}
-
-# see the description of $SELF in comment above output_files_open_out.
-sub output_files_unclosed_files($)
-{
- my $self = shift;
- return $self->{'unclosed_files'};
-}
-# end of output_files API
-
-
# Used in main program, tests and HTML Converter.
# TODO document?
#
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 052e5da367..abe74f3d16 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -257,7 +257,7 @@ sub set_document($$)
}
# In general, OUTPUT_PERL_ENCODING set below is needed for the output()
- # entry point through Texinfo::Common::output_files_open_out. It is
+ # entry point through Texinfo::Convert::Utils::output_files_open_out. It is
# also sometime needed for the converter itself. If not, in general it
# is not needed for the convert() entry point, so the call could also be
# done more finely in converters, but it is not really important.
@@ -277,6 +277,8 @@ sub _internal_converter_initialize($)
$converter->{'expanded_formats'}->{$expanded_format} = 1;
}
}
+
+ $converter->{'error_warning_messages'} = [];
}
# this function is designed so as to be used in specific Converters
@@ -324,9 +326,7 @@ sub converter($;$)
# used for output files information, to register opened
# and not closed files. Accessed through output_files_information()
- $converter->{'output_files'} = Texinfo::Common::output_files_initialize();
-
- $converter->{'error_warning_messages'} = [];
+ $converter->{'output_files'} =
Texinfo::Convert::Utils::output_files_initialize();
# if with XS, XS converter initialization.
# NOTE get_conf should not be used before that point, such that the conf is
@@ -401,7 +401,7 @@ sub output_tree($$)
my $error_message;
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
- ($fh, $error_message) = Texinfo::Common::output_files_open_out(
+ ($fh, $error_message) = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_output_file);
if (!$fh) {
@@ -425,7 +425,7 @@ sub output_tree($$)
$result .= $self->write_or_return($output_end, $fh);
if ($fh and $output_file ne '-') {
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_output_file);
if (!close ($fh)) {
$self->converter_document_error(
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index ed8be4165d..4456053417 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -11752,7 +11752,7 @@ sub _do_jslicenses_file {
my ($licence_file_path, $path_encoding)
= $self->encoded_output_file_name($license_file);
my ($fh, $error_message_licence_file, $overwritten_file)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$licence_file_path);
if ($overwritten_file) {
@@ -11762,7 +11762,7 @@ sub _do_jslicenses_file {
}
if (defined($fh)) {
print $fh $a;
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $licence_file_path);
if (!close ($fh)) {
$self->converter_document_error(
@@ -12739,7 +12739,7 @@ sub _html_convert_output($$$$$$$$)
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
my ($file_fh, $error_message)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_out_filepath);
if (!$file_fh) {
@@ -12760,7 +12760,7 @@ sub _html_convert_output($$$$$$$$)
# NOTE do not close STDOUT here to avoid a perl warning
if ($out_filepath ne '-') {
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_out_filepath);
if (!close($file_fh)) {
$self->converter_document_error(
@@ -12937,7 +12937,7 @@ sub _node_redirections($$$$)
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
my ($file_fh, $error_message)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_out_filepath);
if (!$file_fh) {
@@ -12946,7 +12946,7 @@ sub _node_redirections($$$$)
$out_filepath, $error_message));
} else {
print $file_fh $redirection_page;
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_out_filepath);
if (!close ($file_fh)) {
$self->converter_document_error(sprintf(__(
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index d97292c023..62d8d2da96 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -347,7 +347,7 @@ sub output_ixin($$)
my $error_message;
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
- ($fh, $error_message) = Texinfo::Common::output_files_open_out(
+ ($fh, $error_message) = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_output_file);
if (!$fh) {
@@ -1016,7 +1016,7 @@ sub output_ixin($$)
$output .= $self->write_or_return($blobs, $fh);
if ($fh and $output_file ne '-') {
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_output_file);
if (!close ($fh)) {
$self->converter_document_error(
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index 9c842a9a3d..19fd67e449 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -370,7 +370,7 @@ sub output($$)
return $result;
}
-# Wrapper around Texinfo::Common::output_files_open_out. Open the file
+# Wrapper around Texinfo::Convert::Utils::output_files_open_out. Open the file
# with any CR-LF conversion disabled. We need this for tag tables to
# be correct under MS-Windows. Return filehandle or undef on failure.
sub _open_info_file($$)
@@ -383,7 +383,7 @@ sub _open_info_file($$)
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
- my ($fh, $error_message) = Texinfo::Common::output_files_open_out(
+ my ($fh, $error_message) = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_filename, 'use_binmode');
@@ -404,7 +404,7 @@ sub _register_closed_info_file($$)
my ($encoded_filename, $path_encoding)
= $self->encoded_output_file_name($filename);
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_filename)
}
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 114b1a9342..98a2eba6d3 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -1094,7 +1094,7 @@ sub output($$)
my $error_message;
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
- ($fh, $error_message) = Texinfo::Common::output_files_open_out(
+ ($fh, $error_message) = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_output_file);
if (!$fh) {
@@ -1164,7 +1164,7 @@ sub output($$)
#print STDERR "OUTPUT fh:$fh|F:$output_file|$result";
if ($fh and $output_file ne '-') {
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_output_file);
if (!close ($fh)) {
$self->converter_document_error(
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 7c62f45bf4..2ffc00a0fe 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -448,7 +448,7 @@ sub conversion_initialization($;$)
%{$self->{'style_map'}} = %style_map;
- Texinfo::Common::output_files_disable_output_encoding
+ Texinfo::Convert::Utils::output_files_disable_output_encoding
($self->{'output_files'}, 1);
if ($self->get_conf('ENABLE_ENCODING')
@@ -738,7 +738,7 @@ sub output($$)
my $error_message;
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
- ($fh, $error_message) = Texinfo::Common::output_files_open_out(
+ ($fh, $error_message) = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_outfile_name);
if (!$fh) {
@@ -760,7 +760,7 @@ sub output($$)
# NOTE do not close STDOUT now to avoid a perl warning.
# TODO is it still true that there is such a warning?
if ($fh and $outfile_name ne '-') {
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_outfile_name);
if (!close($fh)) {
$self->converter_document_error(
@@ -785,7 +785,7 @@ sub output($$)
# open the file and output the elements
if (!exists($files_filehandle{$output_unit_filename})) {
my $error_message;
- ($file_fh, $error_message) = Texinfo::Common::output_files_open_out(
+ ($file_fh, $error_message) =
Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$out_filepath);
if (!$file_fh) {
@@ -805,7 +805,7 @@ sub output($$)
if ($self->{'file_counters'}->{$output_unit_filename} == 0) {
# NOTE do not close STDOUT here to avoid a perl warning
if ($out_filepath ne '-') {
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $out_filepath);
if (!close($file_fh)) {
$self->converter_document_error(
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 63b8501635..fd4d953b99 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -1007,7 +1007,7 @@ sub output($$)
}
}
my $fh;
- $self->{'output_files'} = Texinfo::Common::output_files_initialize();
+ $self->{'output_files'} = Texinfo::Convert::Utils::output_files_initialize();
my ($encoded_outfile, $outfile_encoding);
if (defined($outfile)) {
($encoded_outfile, $outfile_encoding)
@@ -1015,7 +1015,7 @@ sub output($$)
my $error_message;
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
- ($fh, $error_message) = Texinfo::Common::output_files_open_out(
+ ($fh, $error_message) = Texinfo::Convert::Utils::output_files_open_out(
$self->{'output_files'}, $self,
$encoded_outfile);
if (!$fh) {
@@ -1038,7 +1038,7 @@ sub output($$)
if ($fh) {
print $fh $result;
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->{'output_files'}, $encoded_outfile);
return undef if (!close($fh));
$result = '';
diff --git a/tp/Texinfo/Convert/Utils.pm b/tp/Texinfo/Convert/Utils.pm
index e7cbb725f8..2303f4abba 100644
--- a/tp/Texinfo/Convert/Utils.pm
+++ b/tp/Texinfo/Convert/Utils.pm
@@ -59,6 +59,139 @@ add_heading_number
our $VERSION = '7.1.90';
+# 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();
+
+# TODO next four functions not documented anywhere, probably relevant to
+# document both in POD and in HTML Customization API.
+sub output_files_initialize
+{
+ return {'unclosed_files' => {}, 'opened_files' => {}};
+}
+
+sub output_files_disable_output_encoding($$)
+{
+ my ($self, $no_output_encoding) = @_;
+
+ $self->{'output_encoding_disabled'} = $no_output_encoding;
+}
+
+# All the opened files are registered, except for stdout,
+# and the closing of files should be registered too with
+# output_files_register_closed() below. This makes possible to
+# unlink all the opened files and close the files not already
+# closed.
+#
+# $FILE_PATH is the file path, it should be a binary string.
+# If $USE_BINMODE is set, call binmode() to set binary mode.
+# $OUTPUT_ENCODING argument overrides the output encoding.
+# Returns
+# - the opened filehandle, or undef if opening failed,
+# - the $! error message or undef if opening succeeded.
+# - 1 if the $FILE_PATH was already opened, which means overwritting.
+sub output_files_open_out($$$;$$)
+{
+ my $self = shift;
+ my $customization_information = shift;
+ my $file_path = shift;
+ my $use_binmode = shift;
+ my $output_encoding = shift;
+
+ #if (!defined($file_path)) {
+ # cluck('output_files_open_out: file_path undef');
+ #}
+
+ my $encoding;
+ if ($self->{'output_encoding_disabled'}) {
+ # leave $encoding undefined
+ } elsif (defined($output_encoding)) {
+ $encoding = $output_encoding;
+ } elsif (defined(
+ $customization_information->get_conf('OUTPUT_PERL_ENCODING'))) {
+ $encoding = $customization_information->get_conf('OUTPUT_PERL_ENCODING');
+ }
+
+ if ($file_path eq '-') {
+ binmode(STDOUT) if $use_binmode;
+ binmode(STDOUT, ":encoding($encoding)") if (defined($encoding));
+ if ($self) {
+ $self->{'unclosed_files'}->{$file_path} = \*STDOUT;
+ }
+ return \*STDOUT, undef;
+ }
+
+ # Check that this file has not already been registered
+ # as opened_file. If yes, it will be overwritten if open succeeds.
+ # It is not possible to use the file name twice in converters
+ # for regular output as files are only closed when all the output
+ # units have been written. It could be possible in HTML with js
+ # scripts licence file set by the user to the same name as an output
+ # file.
+ my $overwritten_file = 0;
+ # NOTE paths are not normalized, therefore different paths names
+ # that refers to the same file will not be found.
+ if (exists($self->{'opened_files'}->{$file_path})) {
+ $overwritten_file = 1;
+ }
+ my $filehandle = do { local *FH };
+ if (!open($filehandle, '>', $file_path)) {
+ my $error_message = $!;
+ return undef, $error_message, $overwritten_file;
+ }
+ # If $use_binmode is true, we run binmode to turn off outputting LF as CR LF
+ # under MS-Windows, so that Info tag tables will have correct offsets. This
+ # must be done before setting the encoding filters with binmode.
+ binmode($filehandle) if $use_binmode;
+ if ($encoding) {
+ binmode($filehandle, ":encoding($encoding)");
+ }
+ if ($self) {
+ if ($self->{'unclosed_files'}->{$file_path}) {
+ warn "BUG: already open: $file_path\n";
+ } else {
+ $self->{'opened_files'}->{$file_path} = 1;
+ }
+ $self->{'unclosed_files'}->{$file_path} = $filehandle;
+ }
+ return $filehandle, undef, $overwritten_file;
+}
+
+# see the description of $SELF in comment above output_files_open_out.
+#
+# $FILE_PATH is the file path, it should be a binary string.
+sub output_files_register_closed($$)
+{
+ my $self = shift;
+ my $file_path = shift;
+ if ($self->{'unclosed_files'}->{$file_path}) {
+ delete $self->{'unclosed_files'}->{$file_path};
+ } else {
+ cluck "BUG: $file_path not opened\n";
+ }
+}
+
+# The next two functions should not be called from user-defined
+# code, only from the main program. They are defined here for
+# consistency of the API and clarity of the code.
+#
+# see the description of $SELF in comment above output_files_open_out.
+sub output_files_opened_files($)
+{
+ my $self = shift;
+ return $self->{'opened_files'};
+}
+
+# see the description of $SELF in comment above output_files_open_out.
+sub output_files_unclosed_files($)
+{
+ my $self = shift;
+ return $self->{'unclosed_files'};
+}
+# end of output_files API
+
+
our @month_name =
(
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 69d85d3dec..3a33e551c9 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -2608,7 +2608,7 @@ build_output_files_unclosed_files (HV *hv,
}
/* input hv should be an output_files hv, in general setup by
- $converter->{'output_files'} = Texinfo::Common::output_files_initialize(); */
+ $converter->{'output_files'} =
Texinfo::Convert::Utils::output_files_initialize(); */
void
build_output_files_opened_files (HV *hv,
const OUTPUT_FILES_INFORMATION *output_files_information)
diff --git a/tp/ext/epub3.pm b/tp/ext/epub3.pm
index 446b37acca..b3c9b86bc2 100644
--- a/tp/ext/epub3.pm
+++ b/tp/ext/epub3.pm
@@ -622,7 +622,7 @@ sub epub_finish($$)
my ($encoded_container_file_path_name, $container_path_encoding)
= $self->encoded_output_file_name($container_file_path_name);
my ($container_fh, $error_message_container)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_container_file_path_name, undef, 'utf-8');
if (!defined($container_fh)) {
@@ -648,7 +648,7 @@ sub epub_finish($$)
</container>
EOT
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_container_file_path_name);
if (!close ($container_fh)) {
$self->converter_document_error(
@@ -663,7 +663,7 @@ EOT
my ($encoded_mimetype_file_path_name, $mimetype_path_encoding)
= $self->encoded_output_file_name($mimetype_file_path_name);
my ($mimetype_fh, $error_message_mimetype)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_mimetype_file_path_name, undef, 'utf-8');
if (!defined($mimetype_fh)) {
@@ -676,7 +676,7 @@ EOT
# example files demonstrate clearly that there should not be end of lines.
print $mimetype_fh 'application/epub+zip';
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_mimetype_file_path_name);
if (!close ($mimetype_fh)) {
$self->converter_document_error(
@@ -699,7 +699,7 @@ EOT
my ($encoded_nav_file_path_name, $nav_path_encoding)
= $self->encoded_output_file_name($nav_file_path_name);
my ($nav_fh, $error_message_nav)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_nav_file_path_name, undef, 'utf-8');
if (!defined($nav_fh)) {
@@ -788,7 +788,7 @@ EOT
# TODO add landmarks?
print $nav_fh '</body>'."\n".'</html>'."\n";
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_nav_file_path_name);
if (!close ($nav_fh)) {
$self->converter_document_error(
@@ -831,7 +831,7 @@ EOT
my ($encoded_opf_file_path_name, $opf_path_encoding)
= $self->encoded_output_file_name($opf_file_path_name);
my ($opf_fh, $error_message_opf)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_opf_file_path_name, undef, 'utf-8');
if (!defined($opf_fh)) {
@@ -985,7 +985,7 @@ EOT
</package>
EOT
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_opf_file_path_name);
if (!close ($opf_fh)) {
$self->converter_document_error(
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index e52014cc92..c63e4509bc 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -217,7 +217,8 @@ sub chm_init($)
my $hhk_file_path_name = File::Spec->catfile($outdir, $hhk_filename);
my ($encoded_hhk_file_path_name, $hhk_path_encoding)
= $self->encoded_output_file_name($hhk_file_path_name);
- my ($hhk_fh, $hhk_error_message) = Texinfo::Common::output_files_open_out(
+ my ($hhk_fh, $hhk_error_message)
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_hhk_file_path_name);
if (!defined($hhk_fh)) {
@@ -285,7 +286,7 @@ sub chm_init($)
}
}
print $hhk_fh "</BODY>\n</HTML>\n";
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_hhk_file_path_name);
if (!close ($hhk_fh)) {
$self->converter_document_error(
@@ -298,7 +299,8 @@ sub chm_init($)
my $hhc_file_path_name = File::Spec->catfile($outdir, $hhc_filename);
my ($encoded_hhc_file_path_name, $hhc_path_encoding)
= $self->encoded_output_file_name($hhc_file_path_name);
- my ($hhc_fh, $hhc_error_message) = Texinfo::Common::output_files_open_out(
+ my ($hhc_fh, $hhc_error_message)
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_hhc_file_path_name);
if (!defined($hhc_fh)) {
@@ -366,7 +368,7 @@ sub chm_init($)
}
}
print $hhc_fh "</HTML>\n</BODY>\n";
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_hhc_file_path_name);
if (!close ($hhc_fh)) {
$self->converter_document_error(
@@ -379,7 +381,8 @@ sub chm_init($)
my $hhp_file_path_name = File::Spec->catfile($outdir, $hhp_filename);
my ($encoded_hhp_file_path_name, $hhp_path_encoding)
= $self->encoded_output_file_name($hhp_file_path_name);
- my ($hhp_fh, $hhp_error_message) = Texinfo::Common::output_files_open_out(
+ my ($hhp_fh, $hhp_error_message)
+ = Texinfo::Convert::Utils::output_files_open_out(
$self->output_files_information(), $self,
$encoded_hhp_file_path_name);
if (!defined($hhp_fh)) {
@@ -432,7 +435,7 @@ EOT
}
}
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$self->output_files_information(), $encoded_hhp_file_path_name);
if (!close ($hhp_fh)) {
$self->converter_document_error(
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 469659f58c..0324816293 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -424,7 +424,7 @@ sub close_files($)
{
my $converter = shift;
my $converter_unclosed_files
- = Texinfo::Common::output_files_unclosed_files(
+ = Texinfo::Convert::Utils::output_files_unclosed_files(
$converter->output_files_information());
if ($converter_unclosed_files) {
my $close_error_nr = 0;
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 731508e227..5efc919617 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1495,6 +1495,8 @@ require Texinfo::Structuring;
Texinfo::Structuring->import();
require Texinfo::Transformations;
Texinfo::Transformations->import();
+require Texinfo::Convert::Utils;
+Texinfo::Convert::Utils->import();
if ($Texinfo::ModulePath::texinfo_uninstalled) {
my $locales_dir = File::Spec->catdir($Texinfo::ModulePath::tp_builddir,
@@ -1788,17 +1790,17 @@ while(@input_files) {
my $encoded_macro_expand_file_name = get_conf('MACRO_EXPAND');
my $macro_expand_file_name =
_decode_input($encoded_macro_expand_file_name);
my $macro_expand_files_information
- = Texinfo::Common::output_files_initialize();
+ = Texinfo::Convert::Utils::output_files_initialize();
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
my ($macro_expand_fh, $error_message)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$macro_expand_files_information, $document,
$encoded_macro_expand_file_name);
my $error_macro_expand_file;
if (defined($macro_expand_fh)) {
print $macro_expand_fh $texinfo_text;
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$macro_expand_files_information,
$encoded_macro_expand_file_name);
if (!close($macro_expand_fh)) {
@@ -1812,7 +1814,7 @@ while(@input_files) {
$error_macro_expand_file = 1;
}
my $macro_expand_opened_file =
- Texinfo::Common::output_files_opened_files(
+ Texinfo::Convert::Utils::output_files_opened_files(
$macro_expand_files_information);
$error_macro_expand_file
= merge_opened_files($error_macro_expand_file, \%opened_files,
@@ -1973,13 +1975,13 @@ while(@input_files) {
}
my $converter_opened_files
- = Texinfo::Common::output_files_opened_files(
+ = Texinfo::Convert::Utils::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(
+ = Texinfo::Convert::Utils::output_files_unclosed_files(
$converter->output_files_information());
if ($converter_unclosed_files) {
foreach my $unclosed_file (keys(%$converter_unclosed_files)) {
@@ -2019,11 +2021,11 @@ while(@input_files) {
my $internal_links_file_name
= _decode_input($encoded_internal_links_file_name);
my $internal_links_files_information
- = Texinfo::Common::output_files_initialize();
+ = Texinfo::Convert::Utils::output_files_initialize();
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
my ($internal_links_fh, $error_message)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$internal_links_files_information, $converter,
$encoded_internal_links_file_name);
my $error_internal_links_file;
@@ -2035,7 +2037,7 @@ while(@input_files) {
$real_command_name, $internal_links_file_name, $!));
$error_internal_links_file = 1;
}
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$internal_links_files_information,
$encoded_internal_links_file_name);
} else {
@@ -2046,7 +2048,7 @@ while(@input_files) {
}
my $internal_links_opened_file
- = Texinfo::Common::output_files_opened_files(
+ = Texinfo::Convert::Utils::output_files_opened_files(
$internal_links_files_information);
$error_internal_links_file
= merge_opened_files($error_internal_links_file,
@@ -2102,11 +2104,11 @@ while(@input_files) {
= $converter_element_count->encoded_output_file_name(
$sort_element_count_file_name);
my $sort_elem_files_information
- = Texinfo::Common::output_files_initialize();
+ = Texinfo::Convert::Utils::output_files_initialize();
# the third return information, set if the file has already been used
# in this files_information is not checked as this cannot happen.
my ($sort_element_count_fh, $error_message)
- = Texinfo::Common::output_files_open_out(
+ = Texinfo::Convert::Utils::output_files_open_out(
$sort_elem_files_information, $converter_element_count,
$encoded_sort_element_count_file_name);
my $error_sort_element_count_file;
@@ -2118,7 +2120,7 @@ while(@input_files) {
$real_command_name, $sort_element_count_file_name, $!));
$error_sort_element_count_file = 1;
}
- Texinfo::Common::output_files_register_closed(
+ Texinfo::Convert::Utils::output_files_register_closed(
$sort_elem_files_information,
$encoded_sort_element_count_file_name);
} else {
@@ -2128,7 +2130,7 @@ while(@input_files) {
}
my $sort_element_count_file_opened_file
- = Texinfo::Common::output_files_opened_files(
+ = Texinfo::Convert::Utils::output_files_opened_files(
$sort_elem_files_information);
$error_sort_element_count_file
= merge_opened_files($error_sort_element_count_file,