[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Common.pm (debug_print_element_short
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Common.pm (debug_print_element_short, debug_print_element, debug_print_element_details), tp/Texinfo/Convert/Converter.pm (present_bug_message): rename _print_element_tree_simple() as debug_print_element_short(). Rename _print_current() as debug_print_element() and replace newline by the string \n in text. Move _print_current_keys() from Texinfo::Structuring to Texinfo::Common and rename as debug_print_element_details(). Rename _bug_message() as present_bug_message(). |
Date: |
Fri, 10 Sep 2021 03:13:13 -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 0acfb75 * tp/Texinfo/Common.pm (debug_print_element_short,
debug_print_element, debug_print_element_details),
tp/Texinfo/Convert/Converter.pm (present_bug_message): rename
_print_element_tree_simple() as debug_print_element_short(). Rename
_print_current() as debug_print_element() and replace newline by the string \n
in text. Move _print_current_keys() from Texinfo::Structuring to
Texinfo::Common and rename as debug_print_element_details(). Rename
_bug_message() as present_bug_ [...]
0acfb75 is described below
commit 0acfb75517572298c3187724de331c380d04f608
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Sep 10 09:13:05 2021 +0200
* tp/Texinfo/Common.pm (debug_print_element_short,
debug_print_element, debug_print_element_details),
tp/Texinfo/Convert/Converter.pm (present_bug_message):
rename _print_element_tree_simple() as debug_print_element_short().
Rename _print_current() as debug_print_element() and replace newline
by the string \n in text. Move _print_current_keys() from
Texinfo::Structuring to Texinfo::Common and rename as
debug_print_element_details().
Rename _bug_message() as present_bug_message().
---
ChangeLog | 12 ++++++
tp/Texinfo/Common.pm | 79 ++++++++++++++++++++++------------------
tp/Texinfo/Convert/Converter.pm | 9 ++++-
tp/Texinfo/Convert/DocBook.pm | 4 +-
tp/Texinfo/Convert/HTML.pm | 14 +++----
tp/Texinfo/Convert/IXIN.pm | 2 +-
tp/Texinfo/Convert/LaTeX.pm | 7 ----
tp/Texinfo/Convert/Plaintext.pm | 6 +--
tp/Texinfo/Convert/TexinfoXML.pm | 2 +-
tp/Texinfo/ParserNonXS.pm | 2 +-
tp/Texinfo/Structuring.pm | 20 +---------
tp/Texinfo/Transformations.pm | 2 +-
tp/init/latex2html.pm | 2 +-
13 files changed, 81 insertions(+), 80 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0bbd9bf..97ea384 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2021-09-10 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm (debug_print_element_short,
+ debug_print_element, debug_print_element_details),
+ tp/Texinfo/Convert/Converter.pm (present_bug_message):
+ rename _print_element_tree_simple() as debug_print_element_short().
+ Rename _print_current() as debug_print_element() and replace newline
+ by the string \n in text. Move _print_current_keys() from
+ Texinfo::Structuring to Texinfo::Common and rename as
+ debug_print_element_details().
+ Rename _bug_message() as present_bug_message().
+
2021-09-09 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/Text.pm (_convert): do not replace the
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index c3ff10b..d803c99 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1511,7 +1511,6 @@ sub is_content_empty($;$)
return 1;
}
foreach my $content (@{$tree->{'contents'}}) {
- #print STDERR _print_current($content);
if ($content->{'cmdname'}) {
if ($content->{'type'} and $content->{'type'} eq 'index_entry_command') {
if ($do_not_ignore_index_entries) {
@@ -2020,7 +2019,7 @@ sub _protect_text($$)
my $current = shift;
my $to_protect = shift;
- #print STDERR "$to_protect: $current "._print_current($current)."\n";
+ #print STDERR "$to_protect: $current ".debug_print_element($current)."\n";
if (defined($current->{'text'}) and $current->{'text'} =~ /$to_protect/
and !(defined($current->{'type'}) and $current->{'type'} eq 'raw')) {
my @result = ();
@@ -2139,12 +2138,11 @@ sub find_parent_root_command($$)
return undef;
}
-# for debugging
-sub _print_current($)
-{
+# for debugging. May be used in other modules.
+sub debug_print_element_short($) {
my $current = shift;
if (ref($current) ne 'HASH') {
- return "_print_current: $current not a hash\n";
+ return "debug_print_element_simply: $current not a hash\n";
}
my $type = '';
my $cmd = '';
@@ -2152,40 +2150,21 @@ sub _print_current($)
my $text = '';
$type = "($current->{'type'})" if (defined($current->{'type'}));
$cmd = "\@$current->{'cmdname'}" if (defined($current->{'cmdname'}));
- $cmd .= "($current->{'level'})" if (defined($current->{'level'}));
- $text = "[text: $current->{'text'}]" if (defined($current->{'text'}));
- if ($current->{'parent'}) {
- my $parent = $current->{'parent'};
- my $parent_cmd = '';
- my $parent_type = '';
- $parent_cmd = "\@$parent->{'cmdname'}" if (defined($parent->{'cmdname'}));
- $parent_type = "($parent->{'type'})" if (defined($parent->{'type'}));
- $parent_string = " <- $parent_cmd$parent_type\n";
- }
+ $text = "[T]" if (defined($current->{'text'}));
my $args = '';
my $contents = '';
- $args = "args(".scalar(@{$current->{'args'}}).')' if $current->{'args'};
- if ($current->{'contents'}) {
- if (ref($current->{'contents'}) ne 'ARRAY') {
- # this is most probably a bug
- $contents = "BUG: NOT array contents ".ref($current->{'contents'});
- }
- else {
- $contents = "contents(".scalar(@{$current->{'contents'}}).')';
- }
- }
- if ("$cmd$type" ne '') {
- return "$cmd$type : $text $args $contents\n$parent_string";
- } else {
- return "$text $args $contents\n$parent_string";
- }
+ $args = "[A".scalar(@{$current->{'args'}}).']' if $current->{'args'};
+ $contents = "[C".scalar(@{$current->{'contents'}}).']'
+ if $current->{'contents'};
+ return "$cmd$type$text$args$contents";
}
# for debugging
-sub _print_element_tree_simple($) {
+sub debug_print_element($)
+{
my $current = shift;
if (ref($current) ne 'HASH') {
- return "_print_element_tree_simple: $current not a hash\n";
+ return "debug_print_element: $current not a hash\n";
}
my $type = '';
my $cmd = '';
@@ -2193,13 +2172,43 @@ sub _print_element_tree_simple($) {
my $text = '';
$type = "($current->{'type'})" if (defined($current->{'type'}));
$cmd = "\@$current->{'cmdname'}" if (defined($current->{'cmdname'}));
- $text = "[T]" if (defined($current->{'text'}));
+ $cmd .= "($current->{'level'})" if (defined($current->{'level'}));
+ if (defined($current->{'text'})) {
+ my $text_str = $current->{'text'};
+ $text_str =~ s/\n/\\n/g;
+ $text = "[T: $text_str]";
+ }
+ if ($current->{'parent'}) {
+ my $parent = $current->{'parent'};
+ my $parent_cmd = '';
+ my $parent_type = '';
+ $parent_cmd = "\@$parent->{'cmdname'}" if (defined($parent->{'cmdname'}));
+ $parent_type = "($parent->{'type'})" if (defined($parent->{'type'}));
+ $parent_string = " <- $parent_cmd$parent_type\n";
+ }
my $args = '';
my $contents = '';
$args = "[A".scalar(@{$current->{'args'}}).']' if $current->{'args'};
$contents = "[C".scalar(@{$current->{'contents'}}).']'
if $current->{'contents'};
- return "$cmd$type$text$args$contents";
+ return "$cmd$type$text$args$contents\n$parent_string";
+}
+
+# for debugging
+sub debug_print_element_details($)
+{
+ my $current = shift;
+ my $string = debug_print_element($current);
+ foreach my $key (keys (%$current)) {
+ $string .= " $key: $current->{$key}\n";
+ }
+ if ($current->{'extra'}) {
+ $string .= " EXTRA\n";
+ foreach my $key (keys (%{$current->{'extra'}})) {
+ $string .= " $key: $current->{'extra'}->{$key}\n";
+ }
+ }
+ return $string;
}
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 8955c8d..52087ec 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -869,7 +869,7 @@ sub output($$)
}
}
-sub _bug_message($$;$)
+sub present_bug_message($$;$)
{
my $self = shift;
my $message = shift;
@@ -890,7 +890,7 @@ sub _bug_message($$;$)
}
if ($current) {
$current_element_message = "current: ".
- Texinfo::Common::_print_current($current);
+ Texinfo::Common::debug_print_element($current);
}
}
my $additional_information = '';
@@ -1827,6 +1827,11 @@ transliteration and characters protection. Also returns
I<$filename>
the corresponding filename based on C<$normalized_name> taking into
account additional constraint on file names and adding a file extension.
+=item $converter->present_bug_message($message, $element)
+
+Show a bug message using I<$message> text. Add informations on
+i<$element> tree element if given in argument.
+
=item $converter->set_conf($option_string, $value)
Set the Texinfo configuration option I<$option_string> to I<$value> if
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 1a350fb..52a6b07 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -634,7 +634,7 @@ sub _convert($$;$)
and $element->{'parent'}->{'type'}
and $element->{'parent'}->{'type'} eq 'row') {
warn "BUG: multitable cell command not in a row "
- .Texinfo::Common::_print_current($element);
+ .Texinfo::Common::debug_print_element($element);
}
$result .= "<entry>";
@@ -769,7 +769,7 @@ sub _convert($$;$)
return "";
}
} else {
- $self->_bug_message("unknown misc_command style $type", $element)
+ $self->present_bug_message("unknown misc_command style $type",
$element)
if ($type !~ /^\d$/);
if ($element->{'cmdname'} eq 'printindex') {
if (defined($element->{'extra'})
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 709679a..dc9e593 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -556,7 +556,7 @@ sub command_text($$;$)
} else {
if (!$command->{'args'}->[0]->{'contents'}) {
cluck "No misc_content: "
- .Texinfo::Common::_print_current($command);
+ .Texinfo::Common::debug_print_element($command);
}
if (defined($command->{'number'})
and ($self->get_conf('NUMBER_SECTIONS')
@@ -4006,7 +4006,7 @@ sub _convert_preformatted_type($$$$)
if (!defined($content)) {
cluck "content undef in _convert_preformatted_type "
- .Texinfo::Common::_print_current($command);
+ .Texinfo::Common::debug_print_element($command);
}
my $current = $command;
@@ -6144,7 +6144,7 @@ sub _prepare_tree_units_global_targets($$)
} elsif ($node_top) {
my $tree_unit_top = $node_top->{'parent'};
if (!$tree_unit_top) {
- die "No parent for node_top:
".Texinfo::Common::_print_current($node_top);
+ die "No parent for node_top:
".Texinfo::Common::debug_print_element($node_top);
}
$self->{'global_target_elements'}->{'Top'} = $tree_unit_top;
} else {
@@ -6434,7 +6434,7 @@ sub _element_direction($$$$;$)
######## debug
if (!$element_target->{'type'}) {
die "No type for element_target $direction $element_target: "
- . Texinfo::Structuring::_print_current_keys($element_target)
+ . Texinfo::Common::debug_print_element_details($element_target)
. "directions :".
Texinfo::Structuring::print_element_directions($element);
}
########
@@ -7855,7 +7855,7 @@ sub _convert_contents($$$)
my $content_formatted = '';
if (ref($element->{'contents'}) ne 'ARRAY') {
cluck "for $element contents not an array: $element->{'contents'}";
- print STDERR Texinfo::Common::_print_current($element);
+ print STDERR Texinfo::Common::debug_print_element($element);
}
my $content_idx = 0;
@@ -7863,8 +7863,8 @@ sub _convert_contents($$$)
my $new_content = $self->_convert($content, "$command_type
[$content_idx]");
if (!defined($new_content)) {
cluck "content not defined for $command_type [$content_idx]\n";
- print STDERR "root is: ".Texinfo::Common::_print_current ($element);
- print STDERR "content is: ".Texinfo::Common::_print_current ($content);
+ print STDERR "root is: ".Texinfo::Common::debug_print_element($element);
+ print STDERR "content is:
".Texinfo::Common::debug_print_element($content);
} else {
$content_formatted .= $new_content;
}
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 7b9b8d1..4f2cf89 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -187,7 +187,7 @@ sub _get_element($$)
my ($element, $root_command);
while (1) {
- #print STDERR Texinfo::Common::_print_current($current);
+ #print STDERR Texinfo::Common::debug_print_element($current);
if ($current->{'type'}) {
if ($current->{'type'} eq 'unit') {
return ($current, $root_command);
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index abf3309..15cb021 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -999,10 +999,6 @@ sub convert_tree($$)
my $self = shift;
my $root = shift;
- #print STDERR "* ".Texinfo::Common::_print_current($root)."\n";
- #foreach my $content (@{$root->{'contents'}}) {
- # print STDERR "** ".Texinfo::Common::_print_current($content)."\n";
- #}
return $self->_convert($root);
}
@@ -1677,9 +1673,6 @@ sub _convert($$)
{
my ($self, $element) = @_;
- #print STDERR "C ".Texinfo::Common::_print_current($element)."\n";
- #print STDERR "C
".Texinfo::Common::_print_element_tree_simple($element)."\n";
-
if (($element->{'type'} and $self->{'ignored_types'}->{$element->{'type'}})
or ($element->{'cmdname'}
and ($self->{'ignored_commands'}->{$element->{'cmdname'}}
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 6ac997f..642e704 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -460,7 +460,7 @@ sub count_context_bug_message($$$)
} else {
$element_text = '';
}
- $self->_bug_message("Too much count_context ${precision}(".
+ $self->present_bug_message("Too much count_context ${precision}(".
scalar(@{$self->{'count_context'}}). "): ". $element_text, $element);
die;
}
@@ -940,7 +940,7 @@ sub _align_lines($$$$$$)
}# else {
# Happens in Info with the special construct as, in that
# case, there are no lines! So no error...
- # $self->_bug_message("more than one image with lines on
$image->{'lines'}");
+ # $self->present_bug_message("more than one image with lines on
$image->{'lines'}");
# in that case, the $image->{'lines'} is not in sync with the
# lines count. So the second image will be treated as simple text.
#}
@@ -1562,7 +1562,7 @@ sub _convert($$)
return $element->{'text'};
# ignore text outside of any format, but warn if ignored text not empty
} elsif ($element->{'text'} =~ /\S/) {
- $self->_bug_message("ignored text not empty `$element->{'text'}'",
$element);
+ $self->present_bug_message("ignored text not empty
`$element->{'text'}'", $element);
return '';
} else {
# miscellaneous top-level whitespace - possibly after an @image
diff --git a/tp/Texinfo/Convert/TexinfoXML.pm b/tp/Texinfo/Convert/TexinfoXML.pm
index 50e671e..05a6455 100644
--- a/tp/Texinfo/Convert/TexinfoXML.pm
+++ b/tp/Texinfo/Convert/TexinfoXML.pm
@@ -854,7 +854,7 @@ sub _convert($$;$)
and $element->{'parent'}->{'type'}
and $element->{'parent'}->{'type'} eq 'row') {
print STDERR "BUG: multitable cell command not in a row "
- .Texinfo::Common::_print_current($element);
+ .Texinfo::Common::debug_print_element($element);
}
$result .= $self->open_element('entry', ['command',
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index a01e264..068f0c4 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1073,7 +1073,7 @@ sub registered_errors($)
sub _print_current($)
{
my $current = shift;
- return Texinfo::Common::_print_current($current);
+ return Texinfo::Common::debug_print_element($current);
}
# for debugging
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index ff243f3..df6ab1b 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -1252,24 +1252,6 @@ sub _print_root_command_texi($)
return 'UNDEF @'.$command->{'cmdname'};
}
-# for debugging
-sub _print_current_keys($)
-{
- my $current = shift;
- my $string = Texinfo::Common::_print_current($current);
- foreach my $key (keys (%$current)) {
- $string .= " $key: $current->{$key}\n";
- }
- if ($current->{'extra'}) {
- $string .= " EXTRA\n";
- foreach my $key (keys (%{$current->{'extra'}})) {
- $string .= " $key: $current->{'extra'}->{$key}\n";
- }
- }
- return $string;
-}
-
-# for debugging. Used in other modules.
sub _print_element_command_texi($)
{
my $element = shift;
@@ -1278,7 +1260,7 @@ sub _print_element_command_texi($)
}
if (!$element->{'type'}) {
return "element $element without type: ".
- _print_current_keys($element);
+ Texinfo::Common::debug_print_element_details($element);
}
if ($element->{'type'} eq 'external_node') {
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index a25a6ea..16c0259 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -760,7 +760,7 @@ sub _protect_hashchar_at_line_beginning($$$)
my ($registrar, $configuration_informations) = @$argument;
- #print STDERR "$type $current "._print_current($current)."\n";
+ #print STDERR "$type $current ".debug_print_element($current)."\n";
# if the next is a hash character at line beginning, mark it
if (defined($current->{'text'}) and $current->{'text'} =~ /\n$/
and $current->{'parent'} and $current->{'parent'}->{'contents'}) {
diff --git a/tp/init/latex2html.pm b/tp/init/latex2html.pm
index f13433f..8e063c2 100644
--- a/tp/init/latex2html.pm
+++ b/tp/init/latex2html.pm
@@ -551,7 +551,7 @@ sub l2h_do_tex($$)
} elsif(($count <= 0) or ($count > $latex_count)) {
# counter out of range
$invalid_counter_count++;
- $self->_bug_message("l2h: request of $count out of range
[0,$latex_count]");
+ $self->present_bug_message("l2h: request of $count out of range
[0,$latex_count]");
return ("<!-- l2h: ". __LINE__ . " out of range count $count -->")
if ($debug);
return '';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Common.pm (debug_print_element_short, debug_print_element, debug_print_element_details), tp/Texinfo/Convert/Converter.pm (present_bug_message): rename _print_element_tree_simple() as debug_print_element_short(). Rename _print_current() as debug_print_element() and replace newline by the string \n in text. Move _print_current_keys() from Texinfo::Structuring to Texinfo::Common and rename as debug_print_element_details(). Rename _bug_message() as present_bug_message().,
Patrice Dumas <=