[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 30 Mar 2024 05:57:24 -0400 (EDT) |
branch: master
commit 73c340f329f43682557e6fdd644e2a124f96ca05
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Mar 30 10:03:57 2024 +0100
* tp/Texinfo/Convert/HTML.pm (_convert_printindex_command),
tp/Texinfo/XS/convert/convert_html.c (convert_printindex_command): do not
setup a subentry tree for conversion with empty contents.
* tp/Texinfo/Convert/HTML.pm (_convert_heading_command)
(_convert_printindex_command, _convert_def_line_type)
(_default_format_end_file, _default_format_node_redirection_page),
tp/Texinfo/XS/convert/convert_html.c (html_default_format_end_file)
(html_default_format_node_redirection_page, convert_heading_command)
(printindex_letters_head_foot_internal, convert_printindex_command)
(convert_def_line_type): add explanation argument to tree conversion.
* tp/Texinfo/XS/convert/converter.c
(register_normalize_case_filename): same debug message as in Perl.
* tp/Texinfo/XS/main/convert_to_texinfo.c
(root_heading_command_to_texinfo): also check that there are contents
to set a tree for output.
---
ChangeLog | 21 +++++++
tp/Texinfo/Convert/HTML.pm | 70 +++++++++++++++-------
tp/Texinfo/ParserNonXS.pm | 2 +-
tp/Texinfo/XS/convert/convert_html.c | 101 ++++++++++++++++++++------------
tp/Texinfo/XS/convert/converter.c | 8 +++
tp/Texinfo/XS/main/convert_to_texinfo.c | 3 +-
6 files changed, 143 insertions(+), 62 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7cf324c433..3455632a80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2024-03-30 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_convert_printindex_command),
+ tp/Texinfo/XS/convert/convert_html.c (convert_printindex_command): do
not
+ setup a subentry tree for conversion with empty contents.
+
+ * tp/Texinfo/Convert/HTML.pm (_convert_heading_command)
+ (_convert_printindex_command, _convert_def_line_type)
+ (_default_format_end_file, _default_format_node_redirection_page),
+ tp/Texinfo/XS/convert/convert_html.c (html_default_format_end_file)
+ (html_default_format_node_redirection_page, convert_heading_command)
+ (printindex_letters_head_foot_internal, convert_printindex_command)
+ (convert_def_line_type): add explanation argument to tree conversion.
+
+ * tp/Texinfo/XS/convert/converter.c
+ (register_normalize_case_filename): same debug message as in Perl.
+
+ * tp/Texinfo/XS/main/convert_to_texinfo.c
+ (root_heading_command_to_texinfo): also check that there are contents
+ to set a tree for output.
+
2024-03-29 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index e8763162a7..87d2573bbb 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4854,7 +4854,8 @@ sub _convert_heading_command($$$$$)
= Texinfo::Structuring::new_complete_menu_master_menu($self,
$identifiers_target, $node);
if ($menu_node) {
- $mini_toc_or_auto_menu = $self->convert_tree($menu_node);
+ $mini_toc_or_auto_menu = $self->convert_tree($menu_node,
+ 'master menu');
}
}
}
@@ -6436,19 +6437,27 @@ sub _convert_printindex_command($$$$)
while ($subentry->{'extra'} and $subentry->{'extra'}->{'subentry'}
and $subentry_level <= $subentries_max_level) {
$subentry = $subentry->{'extra'}->{'subentry'};
- my $subentry_tree = {'contents' => []};
- $subentry_tree->{'type'} = '_code' if ($in_code);
+ my $subentry_tree;
if ($subentry->{'args'} and $subentry->{'args'}->[0]
and $subentry->{'args'}->[0]->{'contents'}) {
- push @{$subentry_tree->{'contents'}}, $subentry->{'args'}->[0];
+ $subentry_tree = {'contents' => [$subentry->{'args'}->[0]]};
+ $subentry_tree->{'type'} = '_code' if ($in_code);
}
if ($subentry_level >= $subentries_max_level) {
# at the max, concatenate the remaining subentries
- my $other_subentries_tree =
$self->comma_index_subentries_tree($subentry);
- push @{$subentry_tree->{'contents'}},
- @{$other_subentries_tree->{'contents'}}
- if defined($other_subentries_tree);
- } else {
+ my $other_subentries_tree
+ = $self->comma_index_subentries_tree($subentry);
+ if ($other_subentries_tree) {
+ if ($subentry_tree) {
+ push @{$subentry_tree->{'contents'}},
+ @{$other_subentries_tree->{'contents'}};
+ } else {
+ $subentry_tree
+ = {'contents' => [@{$other_subentries_tree->{'contents'}}]};
+ $subentry_tree->{'type'} = '_code' if ($in_code);
+ }
+ }
+ } elsif ($subentry_tree) {
push @new_normalized_entry_levels,
uc(Texinfo::Convert::NodeNameNormalization::convert_to_normalized(
$subentry_tree));
@@ -6603,14 +6612,20 @@ sub _convert_printindex_command($$$$)
@prev_normalized_entry_levels = @new_normalized_entry_levels;
} else {
my $entry;
- my $convert_info = "index $index_name l $letter index entry $entry_nr";
- if ($formatted_index_entry_nr > 1) {
- # call with multiple_pass argument
- $entry = $self->convert_tree_new_formatting_context($entry_tree,
+ if (!defined($entry_tree)) {
+ # can happen at least with an empty subentry
+ $entry = '';
+ } else {
+ my $convert_info
+ = "index $index_name l $letter index entry $entry_nr";
+ if ($formatted_index_entry_nr > 1) {
+ # call with multiple_pass argument
+ $entry = $self->convert_tree_new_formatting_context($entry_tree,
$convert_info,
"index-formatted-$formatted_index_entry_nr");
- } else {
- $entry = $self->convert_tree($entry_tree, $convert_info);
+ } else {
+ $entry = $self->convert_tree($entry_tree, $convert_info);
+ }
}
next if ($entry !~ /\S/ and $last_entry_level == 0);
@@ -6798,7 +6813,8 @@ sub _convert_printindex_command($$$$)
my $summary_header = $self->html_attribute_class('table',
["$index_name-letters-header-$cmdname"]).'><tr><th>'
# TRANSLATORS: before list of letters and symbols grouping index
entries
- . $self->convert_tree($self->cdt('Jump to')) .": $non_breaking_space
</th><td>" .
+ . $self->convert_tree($self->cdt('Jump to'), 'Tr letters header text')
+ . ": $non_breaking_space </th><td>" .
$non_alpha_text . $join . $alpha_text . "</td></tr></table>\n";
$result .= $summary_header;
@@ -6810,10 +6826,11 @@ sub _convert_printindex_command($$$$)
." border=\"0\">\n" . '<tr><td></td>'
. $self->html_attribute_class('th', ["entries-header-$cmdname"]).'>'
# TRANSLATORS: index entries column header in index formatting
- . $self->convert_tree($self->cdt('Index Entry'), 'th idx entries 1')
.'</th>'
+ . $self->convert_tree($self->cdt('Index Entry'), 'Tr th idx entries 1')
+ .'</th>'
. $self->html_attribute_class('th', ["sections-header-$cmdname"]).'>'
# TRANSLATORS: section of index entry column header in index formatting
- . $self->convert_tree($self->cdt('Section'), 'th idx entries 2')
+ . $self->convert_tree($self->cdt('Section'), 'Tr th idx entries 2')
."</th></tr>\n"
. "<tr><td colspan=\"3\">".$self->get_conf('DEFAULT_RULE')
."</td></tr>\n";
@@ -6826,7 +6843,7 @@ sub _convert_printindex_command($$$$)
my $summary_footer = $self->html_attribute_class('table',
["$index_name-letters-footer-$cmdname"]).'><tr><th>'
# TRANSLATORS: before list of letters and symbols grouping index
entries
- . $self->convert_tree($self->cdt('Jump to'))
+ . $self->convert_tree($self->cdt('Jump to'), 'Tr letters footer text')
. ": $non_breaking_space </th><td>"
. $non_alpha_text . $join . $alpha_text . "</td></tr></table>\n";
$result .= $summary_footer
@@ -7746,8 +7763,10 @@ sub _convert_def_line_type($$$$)
my $def_call = '';
if ($type_element) {
+ my $explanation = "DEF_TYPE $def_command";
my $type_text = $self->convert_tree({'type' => '_code',
- 'contents' => [$type_element]});
+ 'contents' => [$type_element]},
+ $explanation);
if ($type_text ne '') {
$def_call .= $self->html_attribute_class('code', ['def-type']).'>'.
$type_text .'</code>';
@@ -10987,7 +11006,8 @@ sub _default_format_end_file($$$)
and ($js_setting eq 'generate' or $js_setting eq 'reference')) {
$result .=
'<a href="'.$self->url_protect_url_text($js_path).'"
rel="jslicense"><small>'
- .$self->convert_tree($self->cdt('JavaScript license information'))
+ .$self->convert_tree($self->cdt('JavaScript license information'),
+ 'Tr JS license header')
.'</small></a>';
}
}
@@ -11260,7 +11280,8 @@ sub _default_format_node_redirection_page($$;$)
my $direction = "<a href=\"$href\">$name</a>";
my $string = $self->convert_tree(
$self->cdt('The node you are looking for is at {href}.',
- { 'href' => {'type' => '_converted', 'text' => $direction }}));
+ { 'href' => {'type' => '_converted', 'text' => $direction }}),
+ 'Tr redirection sentence');
my ($title, $description, $encoding, $date, $css_lines,
$doctype, $root_html_element_attributes, $bodytext, $copying_comment,
@@ -13529,6 +13550,11 @@ sub _convert($$;$)
return $result;
# no type, no cmdname, but contents.
} elsif ($element->{'contents'}) {
+ # empty contents should be a bug, but it should not have consequences
+ if ($self->get_conf('TEST')
+ and !scalar(@{$element->{'contents'}})) {
+ cluck("Empty contents in UNNAMED HOLDER");
+ }
# this happens inside accents, for section/node names, for @images.
my $content_formatted = '';
my $content_idx = 0;
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 7e524ec06f..b6ab1faff6 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -3539,7 +3539,7 @@ sub _end_line_misc_line($$$)
my $arg_spec = $self->{'line_commands'}->{$data_cmdname};
print STDERR "MISC END $command\n" #: $arg_spec"
- if ($self->{'DEBUG'});
+ if ($self->{'DEBUG'});
if ($arg_spec eq 'specific') {
my $args = _parse_line_command_args($self, $current, $source_info);
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 8f81b03b19..ee5248e0d1 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -6682,7 +6682,7 @@ html_default_format_end_file (CONVERTER *self, const char
*filename,
text_append_n (&result, "\" rel=\"jslicense\"><small>", 25);
tree = html_cdt_tree ("JavaScript license information",
- self, 0, 0);
+ self, 0, "Tr JS license header");
add_tree_to_build (self, tree);
convert_to_html_internal (self, tree, &result, 0);
remove_tree_to_build (self, tree);
@@ -8248,7 +8248,7 @@ html_default_format_node_redirection_page (CONVERTER
*self,
text_init (&body);
translate_convert_to_html_internal (
"The node you are looking for is at {href}.",
- self, substrings, 0, &body, 0);
+ self, substrings, 0, &body, "Tr redirection sentence");
destroy_named_string_element_list (substrings);
begin_info = file_header_information (self, element, filename);
@@ -9987,7 +9987,8 @@ convert_heading_command (CONVERTER *self, const enum
command_id cmd,
{
add_tree_to_build (self, menu_node);
convert_to_html_internal (self, menu_node,
- &mini_toc_or_auto_menu, 0);
+ &mini_toc_or_auto_menu,
+ "master menu");
remove_tree_to_build (self, menu_node);
/* there are only new or copied elements in the menu */
destroy_element_and_children (menu_node);
@@ -12426,7 +12427,9 @@ static void
printindex_letters_head_foot_internal (CONVERTER *self, const char *index_name,
const enum command_id cmd,
STRING_LIST *entry_classes,
- const char *head_or_foot, const char *alpha_text,
+ const char *head_or_foot,
+ const char *letters_header_explanation,
+ const char *alpha_text,
const char *non_alpha_text, TEXT *result)
{
char *index_name_cmd_class;
@@ -12443,7 +12446,8 @@ printindex_letters_head_foot_internal (CONVERTER *self,
const char *index_name,
text_append_n (result, "><tr><th>", 9);
/* TRANSLATORS: before list of letters and symbols grouping index entries */
- translate_convert_to_html_internal ("Jump to", self, 0, 0, result, 0);
+ translate_convert_to_html_internal ("Jump to", self, 0, 0, result,
+ letters_header_explanation);
text_append_n (result, ": ", 2);
text_append_n (result,
self->special_character[SC_non_breaking_space].string,
@@ -12651,7 +12655,6 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
char *new_normalized_entry_levels[SUBENTRIES_MAX_LEVEL +1];
ELEMENT *entry_trees[SUBENTRIES_MAX_LEVEL +1];
int last_entry_level;
- char *entry;
char *convert_info;
ELEMENT *target_element;
const ELEMENT *associated_command = 0;
@@ -12732,21 +12735,23 @@ convert_printindex_command (CONVERTER *self, const
enum command_id cmd,
{
ELEMENT *new_subentry = lookup_extra_element (subentry,
"subentry");
- ELEMENT *subentry_tree;
+ ELEMENT *subentry_tree = 0;
if (!new_subentry)
break;
subentry = new_subentry;
- if (in_code)
- subentry_tree = new_element (ET__code);
- else
- subentry_tree = new_element (ET_NONE);
-
if (subentry->args.number > 0
&& subentry->args.list[0]->contents.number > 0)
- add_to_contents_as_array (subentry_tree,
- subentry->args.list[0]);
+ {
+ if (in_code)
+ subentry_tree = new_element (ET__code);
+ else
+ subentry_tree = new_element (ET_NONE);
+
+ add_to_contents_as_array (subentry_tree,
+ subentry->args.list[0]);
+ }
if (subentry_level >= SUBENTRIES_MAX_LEVEL)
{
@@ -12754,12 +12759,21 @@ convert_printindex_command (CONVERTER *self, const
enum command_id cmd,
other_subentries_tree
= comma_index_subentries_tree (subentry, 0);
if (other_subentries_tree)
- insert_list_slice_into_contents (subentry_tree,
+ {
+ if (!subentry_tree)
+ {
+ if (in_code)
+ subentry_tree = new_element (ET__code);
+ else
+ subentry_tree = new_element (ET_NONE);
+ }
+ insert_list_slice_into_contents (subentry_tree,
subentry_tree->contents.number,
other_subentries_tree, 0,
other_subentries_tree->number);
+ }
}
- else
+ else if (subentry_tree)
{
new_normalized_entry_levels[subentry_level]
= normalized_upper_case (subentry_tree);
@@ -13021,26 +13035,30 @@ convert_printindex_command (CONVERTER *self, const
enum command_id cmd,
}
else
{
- xasprintf (&convert_info, "index %s l %s index entry %zu",
- index_name, letter, entry_nr -1);
-
- if (last_entry_level > 0)
- add_tree_to_build (self, entry_tree);
- if (*formatted_index_entry_nr > 1)
+ char *entry = 0;
+ if (entry_tree)
{
- /* call with multiple_pass argument */
- entry = convert_tree_new_formatting_context (self,
- entry_tree, convert_info,
- multiple_pass_str, 0, 0);
- }
- else
- {
- entry = html_convert_tree (self, entry_tree,
- convert_info);
+ xasprintf (&convert_info, "index %s l %s index entry %zu",
+ index_name, letter, entry_nr -1);
+
+ if (last_entry_level > 0)
+ add_tree_to_build (self, entry_tree);
+ if (*formatted_index_entry_nr > 1)
+ {
+ /* call with multiple_pass argument */
+ entry = convert_tree_new_formatting_context (self,
+ entry_tree, convert_info,
+ multiple_pass_str, 0, 0);
+ }
+ else
+ {
+ entry = html_convert_tree (self, entry_tree,
+ convert_info);
+ }
+ if (last_entry_level > 0)
+ remove_tree_to_build (self, entry_tree);
+ free (convert_info);
}
- if (last_entry_level > 0)
- remove_tree_to_build (self, entry_tree);
- free (convert_info);
if (last_entry_level == 0
&& (!entry
@@ -13209,7 +13227,7 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
}
}
- if (last_entry_level > 0)
+ if (last_entry_level > 0 && entry_tree)
destroy_element (entry_tree);
if (other_subentries_tree)
@@ -13410,6 +13428,7 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
/* format the summary */
printindex_letters_head_foot_internal (self, index_name, cmd,
entry_classes, "header",
+ "Tr letters header text",
alpha_text, non_alpha_text, result);
}
@@ -13449,7 +13468,7 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
text_append_n (result, ">", 1);
/* TRANSLATORS: index entries column header in index formatting */
translate_convert_to_html_internal ("Index Entry", self, 0, 0, result,
- "th idx entries 1");
+ "Tr th idx entries 1");
text_append_n (result, "</th>", 5);
xasprintf (&index_name_cmd_class, "sections-header-%s",
@@ -13463,7 +13482,7 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
text_append_n (result, ">", 1);
/* TRANSLATORS: section of index entry column header in index formatting */
translate_convert_to_html_internal ("Section", self, 0, 0, result,
- "th idx entries 2");
+ "Tr th idx entries 2");
text_append_n (result, "</th></tr>\n", 11);
text_append_n (result, "<tr><td colspan=\"3\">", 20);
text_append (result, self->conf->DEFAULT_RULE.string);
@@ -13478,6 +13497,7 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
{
printindex_letters_head_foot_internal (self, index_name, cmd,
entry_classes, "footer",
+ "Tr letters footer text",
alpha_text, non_alpha_text, result);
if (non_alpha_nr > 0)
@@ -14810,16 +14830,21 @@ convert_def_line_type (CONVERTER *self, const enum
element_type type,
char *type_text;
size_t type_text_len;
ELEMENT *root_code = new_element (ET__code);
+ char *explanation;
+
+ xasprintf (&explanation, "DEF_TYPE %s", builtin_command_name(def_cmd));
add_to_contents_as_array (root_code, parsed_def->type);
add_tree_to_build (self, root_code);
- type_text = html_convert_tree (self, root_code, 0);
+ type_text = html_convert_tree (self, root_code, explanation);
remove_tree_to_build (self, root_code);
destroy_element (root_code);
+ free (explanation);
+
type_text_len = strlen (type_text);
if (type_text_len > 0)
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index aef0653c9d..90b2283c01 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -792,9 +792,13 @@ register_normalize_case_filename (CONVERTER *self, const
char *filename)
{
FILE_NAME_PATH_COUNTER *output_unit_file
= &self->output_unit_files.list[output_unit_file_idx];
+ fprintf (stderr, "Reusing case-insensitive %s for %s\n",
+ output_unit_file->filename, filename);
+ /*
fprintf (stderr, "Reusing case-insensitive %s(%zu) for %s\n",
output_unit_file->filename, output_unit_file_idx,
filename);
+ */
}
free (lc_filename);
}
@@ -815,9 +819,13 @@ register_normalize_case_filename (CONVERTER *self, const
char *filename)
{
FILE_NAME_PATH_COUNTER *output_unit_file
= &self->output_unit_files.list[output_unit_file_idx];
+ fprintf (stderr, "Reusing %s for %s\n",
+ output_unit_file->filename, filename);
+ /*
fprintf (stderr, "Reusing %s(%zu) for %s\n",
output_unit_file->filename, output_unit_file_idx,
filename);
+ */
}
}
else
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.c
b/tp/Texinfo/XS/main/convert_to_texinfo.c
index cb652aa6b5..5f03d2b150 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.c
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.c
@@ -315,7 +315,8 @@ root_heading_command_to_texinfo (const ELEMENT *element)
{
if ((data_cmd == CM_node
|| (builtin_command_data[data_cmd].flags & CF_sectioning_heading))
- && element->args.number > 0)
+ && element->args.number > 0
+ && element->args.list[0]->contents.number > 0)
tree = element->args.list[0];
}
else
- master updated (4fc7ad11f2 -> b87ffbf4e3), Patrice Dumas, 2024/03/30
- [no subject], Patrice Dumas, 2024/03/30
- [no subject], Patrice Dumas, 2024/03/30
- [no subject], Patrice Dumas, 2024/03/30
- [no subject], Patrice Dumas, 2024/03/30
- [no subject], Patrice Dumas, 2024/03/30
- [no subject],
Patrice Dumas <=