texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/Common.pm (_parent_string, debug_pri


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (_parent_string, debug_print_element_short) (debug_print_element): add an optional argument to debug_print_element_short to show the parent element name or type.
Date: Tue, 06 Dec 2022 13:23:41 -0500

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 076ec15917 * tp/Texinfo/Common.pm (_parent_string, 
debug_print_element_short) (debug_print_element): add an optional argument to 
debug_print_element_short to show the parent element name or type.
076ec15917 is described below

commit 076ec15917858c7884369f07fb2c0845fd97290b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Dec 6 19:23:30 2022 +0100

    * tp/Texinfo/Common.pm (_parent_string, debug_print_element_short)
    (debug_print_element): add an optional argument to
    debug_print_element_short to show the parent element name or type.
---
 ChangeLog            |  6 ++++++
 tp/Texinfo/Common.pm | 39 ++++++++++++++++++++++++++++-----------
 2 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dd0d4a3bfd..7b7505e3d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-12-06  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (_parent_string, debug_print_element_short)
+       (debug_print_element): add an optional argument to
+       debug_print_element_short to show the parent element name or type.
+
 2022-12-05  Patrice Dumas  <pertusus@free.fr>
 
        * layout/list-of-tests: add layout formatting_info_disable_encoding
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index f90fae82b2..24ed0358c9 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -2200,10 +2200,26 @@ sub register_label($$$)
 # functions used for debugging.  May be used in other modules.
 # Not documented.
 
+sub _parent_string($)
+{
+  my $current = shift;
+  my $parent_string;
+  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";
+  }
+  return $parent_string
+}
+
 # informations on a tree element, short version
-sub debug_print_element_short($)
+sub debug_print_element_short($;$)
 {
   my $current = shift;
+  my $print_parent = shift;
 
   if (!defined($current)) {
     return "debug_print_element_simply: UNDEF\n";
@@ -2213,7 +2229,6 @@ sub debug_print_element_short($)
   }
   my $type = '';
   my $cmd = '';
-  my $parent_string = '';
   my $text = '';
   $type = "($current->{'type'})" if (defined($current->{'type'}));
   # specific of HTML
@@ -2227,7 +2242,12 @@ sub debug_print_element_short($)
   $args = "[A".scalar(@{$current->{'args'}}).']' if $current->{'args'};
   $contents = "[C".scalar(@{$current->{'contents'}}).']'
     if $current->{'contents'};
-  return "$cmd$type$text$args$contents";
+  my $parent_string = '';
+  if ($print_parent) {
+    $parent_string = _parent_string($current);
+    $parent_string = '' if (!defined($parent_string));
+  }
+  return "$cmd$type$text$args$contents$parent_string";
 }
 
 # informations on a tree element, long version
@@ -2239,7 +2259,6 @@ sub debug_print_element($)
   }
   my $type = '';
   my $cmd = '';
-  my $parent_string = '';
   my $text = '';
   $type = "($current->{'type'})" if (defined($current->{'type'}));
   # specific of HTML
@@ -2254,13 +2273,11 @@ sub debug_print_element($)
     $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 $parent_string = _parent_string($current);
+  if (defined($parent_string)) {
+    $parent_string .= "\n";
+  } else {
+    $parent_string = '';
   }
   my $args = '';
   my $contents = '';



reply via email to

[Prev in Thread] Current Thread [Next in Thread]