[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Common.pm (element_extra_encoding_fo
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Common.pm (element_extra_encoding_for_perl) (set_output_encodings), tp/Texinfo/Convert/Converter.pm (txt_image_text), tp/Texinfo/Convert/IXIN.pm (output_ixin), tp/Texinfo/Convert/Plaintext.pm (converter_initialize), tp/Texinfo/Translations.pm (gdt): check if encoding name is not defined, or not empty, but not that it is not '0'. |
Date: |
Sat, 22 Jul 2023 07:11:54 -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 4d7deb548e * tp/Texinfo/Common.pm (element_extra_encoding_for_perl)
(set_output_encodings), tp/Texinfo/Convert/Converter.pm (txt_image_text),
tp/Texinfo/Convert/IXIN.pm (output_ixin), tp/Texinfo/Convert/Plaintext.pm
(converter_initialize), tp/Texinfo/Translations.pm (gdt): check if encoding
name is not defined, or not empty, but not that it is not '0'.
4d7deb548e is described below
commit 4d7deb548e75b3636d3137394fc49fc7306a3016
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jul 22 13:11:44 2023 +0200
* tp/Texinfo/Common.pm (element_extra_encoding_for_perl)
(set_output_encodings), tp/Texinfo/Convert/Converter.pm
(txt_image_text), tp/Texinfo/Convert/IXIN.pm (output_ixin),
tp/Texinfo/Convert/Plaintext.pm (converter_initialize),
tp/Texinfo/Translations.pm (gdt): check if encoding name
is not defined, or not empty, but not that it is not '0'.
* tp/Texinfo/Convert/Converter.pm (txt_image_text),
tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/Info.pm
(format_image), tp/Texinfo/Convert/Plaintext.pm (format_image): do not
remove last end of line in txt_image_text, but in callers.
* tp/ext/highlight_syntax.pm (highlight_process): check close()
errors.
---
ChangeLog | 17 +++++++++++++++++
tp/Texinfo/Common.pm | 9 +++++----
tp/Texinfo/Convert/Converter.pm | 13 ++++++-------
tp/Texinfo/Convert/DocBook.pm | 5 ++++-
tp/Texinfo/Convert/IXIN.pm | 5 +++--
tp/Texinfo/Convert/Info.pm | 2 ++
tp/Texinfo/Convert/Plaintext.pm | 4 +++-
tp/Texinfo/Convert/Text.pm | 1 +
tp/Texinfo/Convert/Utils.pm | 3 ++-
tp/Texinfo/Translations.pm | 2 +-
tp/ext/highlight_syntax.pm | 13 +++++++++++--
tp/t/test_utils.pl | 5 +++--
12 files changed, 58 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c972d522f6..c0e33e4f69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2023-07-22 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm (element_extra_encoding_for_perl)
+ (set_output_encodings), tp/Texinfo/Convert/Converter.pm
+ (txt_image_text), tp/Texinfo/Convert/IXIN.pm (output_ixin),
+ tp/Texinfo/Convert/Plaintext.pm (converter_initialize),
+ tp/Texinfo/Translations.pm (gdt): check if encoding name
+ is not defined, or not empty, but not that it is not '0'.
+
+ * tp/Texinfo/Convert/Converter.pm (txt_image_text),
+ tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/Info.pm
+ (format_image), tp/Texinfo/Convert/Plaintext.pm (format_image): do not
+ remove last end of line in txt_image_text, but in callers.
+
+ * tp/ext/highlight_syntax.pm (highlight_process): check close()
+ errors.
+
2023-07-22 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/Converter.pm (txt_image_text): decode file name
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 8fc5b9328f..d79a84f1cb 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1275,7 +1275,8 @@ sub element_extra_encoding_for_perl($)
my $Encode_encoding_object = Encode::find_encoding($encoding);
if (defined($Encode_encoding_object)) {
$perl_encoding = $Encode_encoding_object->name();
- $perl_encoding = undef if (!$perl_encoding);
+ $perl_encoding = undef if (defined($perl_encoding)
+ and $perl_encoding eq '');
}
}
@@ -1513,8 +1514,8 @@ sub set_output_encodings($$)
$parser_information->{'input_encoding_name'})
if ($parser_information
and $parser_information->{'input_encoding_name'});
- if (!$customization_information->get_conf('OUTPUT_PERL_ENCODING')
- and $customization_information->get_conf('OUTPUT_ENCODING_NAME')) {
+ if (not defined($customization_information->get_conf('OUTPUT_PERL_ENCODING'))
+ and
defined($customization_information->get_conf('OUTPUT_ENCODING_NAME'))) {
my $conversion_encoding
= $customization_information->get_conf('OUTPUT_ENCODING_NAME');
if (defined($encoding_name_conversion_map{$conversion_encoding})) {
@@ -1522,7 +1523,7 @@ sub set_output_encodings($$)
= $encoding_name_conversion_map{$conversion_encoding};
}
my $perl_encoding = Encode::resolve_alias($conversion_encoding);
- if ($perl_encoding) {
+ if (defined($perl_encoding) and $perl_encoding ne '') {
$customization_information->set_conf('OUTPUT_PERL_ENCODING',
$perl_encoding);
}
}
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index bf266f66a5..6f00350094 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1206,12 +1206,13 @@ sub txt_image_text($$$)
my $txt_file = Texinfo::Common::locate_include_file($self, $text_file_name);
if (!defined($txt_file)) {
- return undef;
+ return undef, undef;
} else {
my $filehandle = do { local *FH };
if (open ($filehandle, $txt_file)) {
- my $perl_encoding =
Texinfo::Common::element_extra_encoding_for_perl($element);
- if ($perl_encoding) {
+ my $perl_encoding
+ = Texinfo::Common::element_extra_encoding_for_perl($element);
+ if (defined($perl_encoding)) {
binmode($filehandle, ":encoding($perl_encoding)");
}
my $result = '';
@@ -1223,8 +1224,6 @@ sub txt_image_text($$$)
}
$result .= $_;
}
- # remove last end of line
- chomp ($result);
if (!close ($filehandle)) {
my $decoded_file = $txt_file;
$decoded_file = Encode::decode($file_name_encoding, $txt_file)
@@ -1233,7 +1232,7 @@ sub txt_image_text($$$)
sprintf(__("error on closing image text file %s: %s"),
$decoded_file, $!));
}
- return ($result, $max_width);
+ return $result, $max_width;
} else {
my $decoded_file = $txt_file;
$decoded_file = Encode::decode($file_name_encoding, $txt_file)
@@ -1243,7 +1242,7 @@ sub txt_image_text($$$)
$decoded_file, $!), $element->{'source_info'});
}
}
- return undef;
+ return undef, undef;
}
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 87bd87d982..1bad169992 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -1281,8 +1281,11 @@ sub _convert($$;$)
.$self->xml_protect_text($file->[0])
."\" format=\"$file->[1]\"></imagedata></imageobject>";
}
- my ($image_text, $image_width) = $self->txt_image_text($element,
$basefile);
+ my ($image_text, $image_width)
+ = $self->txt_image_text($element, $basefile);
if (defined($image_text)) {
+ # remove last end of line
+ chomp($image_text);
$result .= "<textobject><literallayout>"
.$self->_protect_text($image_text)
.'</literallayout></textobject>';
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 716606c335..c6cc771c9f 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -922,7 +922,7 @@ sub output_ixin($$)
if ($extension eq 'txt') {
my $perl_encoding
= Texinfo::Common::element_extra_encoding_for_perl($command);
- if ($perl_encoding) {
+ if (defined($perl_encoding)) {
binmode($filehandle, ":encoding($perl_encoding)");
}
}
@@ -932,6 +932,7 @@ sub output_ixin($$)
} else {
$file_content = <$filehandle>;
}
+ # FIXME error on close should be tested here
my $encoded_file = encode_base64($file_content);
$blobs .= $encoded_file;
my $blob_len = $self->_count_bytes($encoded_file);
@@ -944,7 +945,7 @@ sub output_ixin($$)
$blobs_index .= $self->ixin_element('blobentry',
[['bloblen', $blob_len], ['encoding', 'base64'],
['mimetype', $mime_type], ['filename', $file_name_text]]) ."\n";
- }
+ } # FIXME error on open should be tested here
}
}
#print STDERR "$basefile\n";
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index 9ea94c3b3f..32929d5840 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -575,6 +575,8 @@ sub format_image($$)
}
}
my ($text, $width) = $self->txt_image_text($element, $basefile);
+ # remove last end of line
+ chomp($text) if (defined($text));
my $alt;
if (defined($element->{'args'}->[3])
and $element->{'args'}->[3]->{'contents'}
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 6bc9b59fba..fe0cf7387c 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -517,7 +517,7 @@ sub converter_initialize($)
# This needs to be here to take into account $self->{'fillcolumn'}.
$self->push_top_formatter('_Root_context');
# some caching to avoid calling get_conf
- if ($self->get_conf('OUTPUT_PERL_ENCODING')) {
+ if (defined($self->get_conf('OUTPUT_PERL_ENCODING'))) {
$self->{'output_perl_encoding'} = $self->get_conf('OUTPUT_PERL_ENCODING');
} else {
$self->{'output_perl_encoding'} = '';
@@ -1688,6 +1688,8 @@ sub format_image($$)
{'contents' => $element->{'args'}->[0]->{'contents'}},
{'code' => 1, %{$self->{'convert_text_options'}}});
my ($text, $width) = $self->txt_image_text($element, $basefile);
+ # remove last end of line
+ chomp($text) if (defined($text));
my $result = $self->image_formatted_text($element, $basefile, $text);
my $lines_count = ($result =~ tr/\n/\n/);
if (!defined($width)) {
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 6784a2b265..ce3b6c8c08 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -732,6 +732,7 @@ sub converter($)
and defined($element->{'extra'}->{'input_encoding_name'})) {
$converter->{'OUTPUT_ENCODING_NAME'}
= $element->{'extra'}->{'input_encoding_name'};
+ # can be undef
$converter->{'OUTPUT_PERL_ENCODING'}
= Texinfo::Common::element_extra_encoding_for_perl($element);
}
diff --git a/tp/Texinfo/Convert/Utils.pm b/tp/Texinfo/Convert/Utils.pm
index 0d7c7f5f7f..5ac23bf4d7 100644
--- a/tp/Texinfo/Convert/Utils.pm
+++ b/tp/Texinfo/Convert/Utils.pm
@@ -237,7 +237,8 @@ sub expand_verbatiminclude($$$)
and defined($current->{'extra'}->{'text_arg'}));
my $file_name_text = $current->{'extra'}->{'text_arg'};
- my $input_encoding =
Texinfo::Common::element_extra_encoding_for_perl($current);
+ my $input_encoding
+ = Texinfo::Common::element_extra_encoding_for_perl($current);
my ($file_name, $file_name_encoding)
= encoded_input_file_name($customization_information,
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index 364cf6f9d6..d9fbb98281 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -132,7 +132,7 @@ sub gdt($$;$$$$)
if ($self->get_conf('OUTPUT_ENCODING_NAME')) {
$encoding = $self->get_conf('OUTPUT_ENCODING_NAME');
}
- if ($self->get_conf('OUTPUT_PERL_ENCODING')) {
+ if (defined($self->get_conf('OUTPUT_PERL_ENCODING'))) {
$perl_encoding = $self->get_conf('OUTPUT_PERL_ENCODING');
}
} else {
diff --git a/tp/ext/highlight_syntax.pm b/tp/ext/highlight_syntax.pm
index 364fe3e4e5..5a73900ca1 100644
--- a/tp/ext/highlight_syntax.pm
+++ b/tp/ext/highlight_syntax.pm
@@ -448,7 +448,12 @@ sub highlight_process($$)
$highlight_lang_in_line_nr += 2 + $text_lines_nr;
$counter ++;
}
- close(HIGHLIGHT_LANG_IN);
+ if (! close(HIGHLIGHT_LANG_IN)) {
+ $self->document_warn($self,
+ sprintf(__("highlight_syntax.pm: error on closing %s: %s"),
+ $input_language_path_name, $!));
+ return 1;
+ }
# call source highlighting program
my $version_option='';
@@ -541,7 +546,11 @@ sub highlight_process($$)
"highlight_syntax.pm: %s: retrieved %d items in HTML; expected %d"),
$language, $got_count, $language_fragments_nr));
}
- close (HIGHLIGHT_LANG_OUT);
+ if (!close (HIGHLIGHT_LANG_OUT)) {
+ $self->document_warn($self,
+ sprintf(__("highlight_syntax.pm: error on closing %s: %s"),
+ $html_result_path_name, $!));
+ }
}
return 0;
}
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 2f1ce9afbd..28efdb5e74 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1261,8 +1261,9 @@ sub test($$)
} else {
# Texinfo::Convert::Converter::converter() calls
# Texinfo::Common::set_output_encodings, so OUTPUT_PERL_ENCODING
- # should be set in all the formats converters.
- my $output_file_encoding =
$converter->get_conf('OUTPUT_PERL_ENCODING');
+ # should be set if possible in all the formats converters.
+ my $output_file_encoding
+ = $converter->get_conf('OUTPUT_PERL_ENCODING');
if (defined($output_file_encoding)
and $output_file_encoding ne '') {
binmode(OUTFILE, ":encoding($output_file_encoding)");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Common.pm (element_extra_encoding_for_perl) (set_output_encodings), tp/Texinfo/Convert/Converter.pm (txt_image_text), tp/Texinfo/Convert/IXIN.pm (output_ixin), tp/Texinfo/Convert/Plaintext.pm (converter_initialize), tp/Texinfo/Translations.pm (gdt): check if encoding name is not defined, or not empty, but not that it is not '0'.,
Patrice Dumas <=