[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Converter.pm (determine_file
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/Converter.pm (determine_files_and_directory), tp/Texinfo/Convert/Text.pm (output), tp/Texinfo/Convert/HTML.pm (_prepare_css): use a different variable for file name string bytes and file name character string. |
Date: |
Fri, 05 Apr 2024 16:12:01 -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 6b19a72c46 * tp/Texinfo/Convert/Converter.pm
(determine_files_and_directory), tp/Texinfo/Convert/Text.pm (output),
tp/Texinfo/Convert/HTML.pm (_prepare_css): use a different variable for file
name string bytes and file name character string.
6b19a72c46 is described below
commit 6b19a72c4683d5f4d32075ff17efb0bb12642899
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Apr 5 22:10:29 2024 +0200
* tp/Texinfo/Convert/Converter.pm (determine_files_and_directory),
tp/Texinfo/Convert/Text.pm (output), tp/Texinfo/Convert/HTML.pm
(_prepare_css): use a different variable for file name string bytes
and file name character string.
* tp/Texinfo/Convert/HTML.pm (_prepare_css): rename variables.
* tp/t/test_utils.pl: change in comments.
---
ChangeLog | 11 +++++++++++
tp/Texinfo/Convert/Converter.pm | 7 +++++--
tp/Texinfo/Convert/HTML.pm | 28 +++++++++++++++-------------
tp/Texinfo/Convert/Text.pm | 7 +++++--
tp/t/test_utils.pl | 29 +++++++++++++++++------------
5 files changed, 53 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f2e70a6025..35de89a96d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-04-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Converter.pm (determine_files_and_directory),
+ tp/Texinfo/Convert/Text.pm (output), tp/Texinfo/Convert/HTML.pm
+ (_prepare_css): use a different variable for file name string bytes
+ and file name character string.
+
+ * tp/Texinfo/Convert/HTML.pm (_prepare_css): rename variables.
+
+ * tp/t/test_utils.pl: change in comments.
+
2024-04-05 Gavin Smith <gavinsmith0123@gmail.com>
* tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_line):
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 2dbfb6c3f4..dfa882c1eb 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -667,12 +667,15 @@ sub determine_files_and_directory($$)
# file which is not decoded either. We want to return only
# decoded character strings such that they can easily be mixed
# with other character strings, so we decode here.
- my $input_file_name = $document_info->{'input_file_name'};
+ my $input_file_name_bytes = $document_info->{'input_file_name'};
my $encoding = $self->get_conf('COMMAND_LINE_ENCODING');
+ my $input_file_name;
if (defined($encoding)) {
- $input_file_name = decode($encoding, $input_file_name, sub { '?' });
+ $input_file_name = decode($encoding, $input_file_name_bytes, sub { '?'
});
# use '?' as replacement character rather than U+FFFD in case it
# is re-encoded to an encoding without this character
+ } else {
+ $input_file_name = $input_file_name_bytes;
}
my ($directories, $suffix);
($input_basefile, $directories, $suffix) = fileparse($input_file_name);
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 7f58948676..47f4e9f579 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9297,26 +9297,28 @@ sub _prepare_css($)
my @css_rule_lines;
my $css_files = $self->get_conf('CSS_FILES');
- foreach my $file (@$css_files) {
+ foreach my $css_file (@$css_files) {
my $css_file_fh;
- my $css_file;
- if ($file eq '-') {
+ my $css_file_path;
+ if ($css_file eq '-') {
$css_file_fh = \*STDIN;
- $css_file = '-';
+ $css_file_path = '-';
} else {
- $css_file = $self->Texinfo::Common::locate_include_file($file);
- unless (defined($css_file)) {
- my $input_file_name = $file;
+ $css_file_path = $self->Texinfo::Common::locate_include_file($css_file);
+ unless (defined($css_file_path)) {
+ my $css_input_file_name;
my $encoding = $self->get_conf('COMMAND_LINE_ENCODING');
if (defined($encoding)) {
- $input_file_name = decode($encoding, $input_file_name);
+ $css_input_file_name = decode($encoding, $css_file);
+ } else {
+ $css_input_file_name = $css_file;
}
$self->converter_document_warn(sprintf(
- __("CSS file %s not found"), $input_file_name));
+ __("CSS file %s not found"), $css_input_file_name));
next;
}
- unless (open (CSSFILE, $css_file)) {
- my $css_file_name = $css_file;
+ unless (open (CSSFILE, $css_file_path)) {
+ my $css_file_name = $css_file_path;
my $encoding = $self->get_conf('COMMAND_LINE_ENCODING');
if (defined($encoding)) {
$css_file_name = decode($encoding, $css_file_name);
@@ -9333,9 +9335,9 @@ sub _prepare_css($)
# binmode($css_file_fh)
my ($import_lines, $rules_lines);
($import_lines, $rules_lines)
- = $self->_process_css_file($css_file_fh, $css_file);
+ = $self->_process_css_file($css_file_fh, $css_file_path);
if (!close($css_file_fh)) {
- my $css_file_name = $css_file;
+ my $css_file_name = $css_file_path;
my $encoding = $self->get_conf('COMMAND_LINE_ENCODING');
if (defined($encoding)) {
$css_file_name = decode($encoding, $css_file_name);
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 2ca74f4586..060771b877 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -897,10 +897,13 @@ sub output($$)
#print STDERR "OUTPUT\n";
my $input_basename;
if ($document_info and defined($document_info->{'input_file_name'})) {
- my $input_file_name = $document_info->{'input_file_name'};
+ my $input_file_name_bytes = $document_info->{'input_file_name'};
my $encoding = $self->{'COMMAND_LINE_ENCODING'};
+ my $input_file_name;
if (defined($encoding)) {
- $input_file_name = decode($encoding, $input_file_name);
+ $input_file_name = decode($encoding, $input_file_name_bytes);
+ } else {
+ $input_file_name = $input_file_name_bytes;
}
my ($directories, $suffix);
($input_basename, $directories, $suffix) = fileparse($input_file_name);
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 743b566193..21592df39b 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -969,10 +969,9 @@ sub test($$)
Texinfo::Config::GNUT_reinitialize_init_files();
my $init_files_options = {};
my $init_file_directories = [$srcdir.'init/', $srcdir.'t/init/'];
- # the init file names are supposed to be binary strings. Since they
- # are not encoded anywhere, probably only ascii file names should
- # be used.
- # FIXME what if srcdir is non ascii (srcdir is truly a binary string).
+ # the init file names should be binary strings. Since they
+ # are not encoded here, ascii file names should be used or they
+ # should be encoded in test specification files.
if ($parser_options and $parser_options->{'init_files'}) {
$symbols_before_init_file = {};
foreach my $symbol (keys(%Texinfo::Config::)) {
@@ -1022,8 +1021,12 @@ sub test($$)
}
}
if (defined($test_input_file_name)) {
- # FIXME should we need to encode or do we assume that
- # $test_input_file_name is already bytes?
+ # argument should be byte strings. In most if not all cases,
+ # 'test_input_file_name' is based on $test_name. $test_name should
+ # only consist of ascii characters as it is used both as a
+ # character string and a byte string (see the comment below on that),
+ # so we do not encode, but we could if needed. If we encode, an
+ # output encoding should be determined.
$document->set_document_global_info('input_file_name',
$test_input_file_name);
}
@@ -1436,11 +1439,12 @@ sub test($$)
print OUT 'use utf8;'."\n\n";
#print STDERR "Generate: ".Data::Dumper->Dump([$tree], ['$res']);
- # NOTE $test_name is in general used for directories and
- # file names, here it is used as a text string. If non ascii, it
+ # NOTE $test_name is in general used for directories, file names,
+ # and in messages. Here it is used as a text string. If non ascii, it
# should be a character string in internal perl codepoints as OUT
- # is encoded as utf8. It should also be encoded to be used as file name
- # in that case.
+ # is encoded as utf8. In that case, it should be encoded to be
+ # used as a file name for the above cases. Since this is not the case,
+ # $test_name should consist of ascii characters only.
my $out_result;
{
local $Data::Dumper::Sortkeys = \&filter_tree_keys;
@@ -1577,8 +1581,9 @@ sub test($$)
ok (Data::Compare::Compare($indices_sorted_sort_strings,
$result_indices_sort_strings{$test_name}),
$test_name.' indices sort');
- # FIXME use PlainTexinfo converter to test the XS converter until
- # convert_to_texinfo goes through XS.
+ # NOTE either a PlainTexinfo converter or a direct call to
+ # convert_to_texinfo can be used to test conversion to raw text,
+ # both for pure Perl and XS.
my $converter_to_texinfo = Texinfo::Convert::PlainTexinfo->converter();
my $texi_result = $converter_to_texinfo->convert($document);
#my $texi_result = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Converter.pm (determine_files_and_directory), tp/Texinfo/Convert/Text.pm (output), tp/Texinfo/Convert/HTML.pm (_prepare_css): use a different variable for file name string bytes and file name character string.,
Patrice Dumas <=