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 (debug_command_name, debug


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (debug_command_name, debug_print_element), tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/debug.c (debug_command_name) (print_element_debug), tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): escape \n and \t in command name in debug messages for better readability.
Date: Sat, 08 Jul 2023 08:21:50 -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 63cc88edac * tp/Texinfo/Common.pm (debug_command_name, 
debug_print_element), tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), 
tp/Texinfo/XS/parsetexi/debug.c (debug_command_name) (print_element_debug), 
tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): escape \n and \t 
in command name in debug messages for better readability.
63cc88edac is described below

commit 63cc88edac1c8d12e2d0ddc9723a26805758a3cf
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jul 8 14:21:40 2023 +0200

    * tp/Texinfo/Common.pm (debug_command_name, debug_print_element),
    tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
    tp/Texinfo/XS/parsetexi/debug.c (debug_command_name)
    (print_element_debug), tp/Texinfo/XS/parsetexi/parser.c
    (process_remaining_on_line): escape \n and \t in command name in
    debug messages for better readability.
---
 ChangeLog                        |  9 +++++++++
 tp/Texinfo/Common.pm             | 16 +++++++++++++++-
 tp/Texinfo/ParserNonXS.pm        |  3 ++-
 tp/Texinfo/XS/parsetexi/debug.c  | 13 ++++++++++++-
 tp/Texinfo/XS/parsetexi/debug.h  |  1 +
 tp/Texinfo/XS/parsetexi/parser.c |  2 +-
 6 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 524a3cef8e..e6612a9250 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-07-08  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (debug_command_name, debug_print_element),
+       tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+       tp/Texinfo/XS/parsetexi/debug.c (debug_command_name)
+       (print_element_debug), tp/Texinfo/XS/parsetexi/parser.c
+       (process_remaining_on_line): escape \n and \t in command name in
+       debug messages for better readability.
+
 2023-07-08  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_debug_show_source_mark)
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 5ed966895b..2e473a70da 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -2472,6 +2472,18 @@ sub _parent_string($)
   return $parent_string
 }
 
+sub debug_command_name($)
+{
+  my $cmdname = shift;
+  if ($cmdname eq "\n") {
+    return '\n';
+  } elsif ($cmdname eq "\t") {
+    return '\t';
+  } else {
+    return $cmdname;
+  }
+}
+
 # informations on a tree element, short version
 sub debug_print_element($;$)
 {
@@ -2492,7 +2504,9 @@ sub debug_print_element($;$)
   $type .= '{'.$current->{'extra'}->{'special_element_type'}.'}'
     if (defined($current->{'extra'})
       and defined($current->{'extra'}->{'special_element_type'}));
-  $cmd = "\@$current->{'cmdname'}" if (defined($current->{'cmdname'}));
+  if (defined($current->{'cmdname'})) {
+    $cmd = '@' . debug_command_name($current->{'cmdname'});
+  }
   if (defined($current->{'text'}) and $current->{'text'} ne '') {
     my $text_str = $current->{'text'};
     $text_str =~ s/\n/\\n/g;
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index cc77ddce12..a133a980f2 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -6813,7 +6813,8 @@ sub _process_remaining_on_line($$$$)
       substr($line, 0, $at_command_length) = '';
     }
 
-    print STDERR "COMMAND $command\n" if ($self->{'DEBUG'});
+    print STDERR "COMMAND \@".Texinfo::Common::debug_command_name($command)
+                  ."\n" if ($self->{'DEBUG'});
 
     # @value not expanded (expansion is done above), and @txiinternalvalue
     if ($command eq 'value' or $command eq 'txiinternalvalue') {
diff --git a/tp/Texinfo/XS/parsetexi/debug.c b/tp/Texinfo/XS/parsetexi/debug.c
index 0f01386067..1c5d92bfd0 100644
--- a/tp/Texinfo/XS/parsetexi/debug.c
+++ b/tp/Texinfo/XS/parsetexi/debug.c
@@ -47,6 +47,17 @@ debug_nonl (char *s, ...)
   vfprintf (stderr, s, v);
 }
 
+char *
+debug_command_name (enum command_id cmd)
+{
+  if (cmd == CM_TAB)
+    return "\\t";
+  else if (cmd == CM_NEWLINE)
+    return "\\n";
+  else
+    return command_name(cmd);
+}
+
 char *
 print_element_debug (ELEMENT *e, int print_parent)
 {
@@ -56,7 +67,7 @@ print_element_debug (ELEMENT *e, int print_parent)
   text_init (&text);
   text_append (&text, "");
   if (e->cmd)
-    text_printf (&text, "@%s", command_name(e->cmd));
+    text_printf (&text, "@%s", debug_command_name(e->cmd));
   if (e->type)
     text_printf (&text, "(%s)", element_type_names[e->type]);
   if (e->text.end > 0)
diff --git a/tp/Texinfo/XS/parsetexi/debug.h b/tp/Texinfo/XS/parsetexi/debug.h
index 46f362dc18..780d7139c3 100644
--- a/tp/Texinfo/XS/parsetexi/debug.h
+++ b/tp/Texinfo/XS/parsetexi/debug.h
@@ -12,5 +12,6 @@ void debug_nonl (char *s, ...);
 extern int debug_output;
 void debug_print_element (ELEMENT *e, int print_parent);
 char *print_element_debug (ELEMENT *e, int print_parent);
+char *debug_command_name (enum command_id cmd);
 
 #endif
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 5a0154714f..1a7b1bb5b4 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2027,7 +2027,7 @@ process_remaining_on_line (ELEMENT **current_inout, char 
**line_inout)
       enum command_id data_cmd = cmd;
       ELEMENT *command_element;
 
-      debug ("COMMAND %s", command_name(cmd));
+      debug ("COMMAND @%s", debug_command_name(cmd));
 
       line = line_after_command;
 



reply via email to

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