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 (parse_node_manual), tp/Te


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (parse_node_manual), tp/Texinfo/ParserNonXS.pm (_end_line_misc_line), tp/Texinfo/Structuring.pm (new_node_menu_entry): add an argument to control whether the element argument is modified or not as in the XS parser. Remove _parse_node_manual and call directly parse_node_manual instead.
Date: Tue, 28 Feb 2023 09:17: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 99976dc747 * tp/Texinfo/Common.pm (parse_node_manual), 
tp/Texinfo/ParserNonXS.pm (_end_line_misc_line), tp/Texinfo/Structuring.pm 
(new_node_menu_entry): add an argument to control whether the element argument 
is modified or not as in the XS parser.  Remove _parse_node_manual and call 
directly parse_node_manual instead.
99976dc747 is described below

commit 99976dc7472ab5da03c6cedadbb9b854ffe1e9cd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 28 15:17:37 2023 +0100

    * tp/Texinfo/Common.pm (parse_node_manual), tp/Texinfo/ParserNonXS.pm
    (_end_line_misc_line), tp/Texinfo/Structuring.pm
    (new_node_menu_entry): add an argument to control whether the element
    argument is modified or not as in the XS parser.  Remove
    _parse_node_manual and call directly parse_node_manual instead.
---
 ChangeLog                 |  8 ++++++++
 tp/Texinfo/Common.pm      | 39 ++++++++++++++++++++++-----------------
 tp/Texinfo/ParserNonXS.pm | 30 ++++++------------------------
 tp/Texinfo/Structuring.pm |  6 ++----
 4 files changed, 38 insertions(+), 45 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6f29f78e84..b8bd8aec02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-02-28  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (parse_node_manual), tp/Texinfo/ParserNonXS.pm
+       (_end_line_misc_line), tp/Texinfo/Structuring.pm
+       (new_node_menu_entry): add an argument to control whether the element
+       argument is modified or not as in the XS parser.  Remove
+       _parse_node_manual and call directly parse_node_manual instead.
+
 2023-02-28  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/parsetexi/end_line.c
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index cd3f99a0be..ed14ba7558 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1010,9 +1010,10 @@ sub _count_opened_tree_braces($$)
 #
 # Could be documented, but only if there is evidence that this function
 # is useful in user-defined code.
-sub parse_node_manual($)
+sub parse_node_manual($;$)
 {
   my $label_contents_container = shift;
+  my $modify_node = shift;
 
   return (undef, undef)
      if (!$label_contents_container->{'contents'});
@@ -1089,24 +1090,28 @@ sub parse_node_manual($)
     $result->{'manual_content'} = $manual if ($manual and scalar(@$manual));
   }
 
-  # Return the contents array in which all the elements in 'manual_content'
-  # and 'node_content' have been put.
-  my $new_contents = [];
-  if (defined($result) and defined($result->{'manual_content'})) {
-    @$new_contents = ({ 'text' => '(', 'parent' => $label_contents_container },
-                      @$manual);
-    push @$new_contents, {  'text' => ')',
-                            'parent' => $label_contents_container }
-      if $end_paren;
-    push @$new_contents, { 'text' => $spaces_after,
-                           'parent' => $label_contents_container }
-      if $spaces_after;
-  }
-  if (@contents) {
-    @$new_contents = (@$new_contents, @contents);
+  if ($modify_node) {
+    # contents array in which all the elements in 'manual_content'
+    # and 'node_content' have been put, replacing the argument
+    # element contents.
+    my $new_contents = [];
+    if (defined($result) and defined($result->{'manual_content'})) {
+      @$new_contents = ({ 'text' => '(', 'parent' => $label_contents_container 
},
+                        @$manual);
+      push @$new_contents, {  'text' => ')',
+                              'parent' => $label_contents_container }
+        if $end_paren;
+      push @$new_contents, { 'text' => $spaces_after,
+                             'parent' => $label_contents_container }
+        if $spaces_after;
+    }
+    if (@contents) {
+      @$new_contents = (@$new_contents, @contents);
+    }
+    $label_contents_container->{'contents'} = $new_contents;
   }
 
-  return $result, $new_contents;
+  return $result;
 }
 
 
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 23c6b5f533..ecb0518a19 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2847,27 +2847,6 @@ sub _isolate_last_space
   }
 }
 
-# $LABEL_CONTENTS_CONTAINER->{'contents'} is the Texinfo for the
-# specification of a node.
-# Returned $parsed_node_manual object is a hash with two fields:
-#
-#     manual_content - Texinfo tree for a manual name extracted from the
-#                      node specification.
-#     node_content - Texinfo tree for the node name on its own
-#
-# retrieve a leading manual name in parentheses, if there is one
-# and modify the $LABEL_CONTENTS_CONTAINER contents to be consistent
-# with $parsed_node_manual.
-sub _parse_node_manual($)
-{
-  my $label_contents_container = shift;
-  my ($parsed_node_manual, $modified_node_content)
-    = Texinfo::Common::parse_node_manual($label_contents_container);
-  $label_contents_container->{'contents'} = $modified_node_content
-     if ($modified_node_content);
-  return $parsed_node_manual;
-}
-
 # relocate $SOURCE_MARKS source marks with position between
 # $BEGIN_POSITION and $END_POSITION to be relative to $BEGIN_POSITION,
 # and move to element $E.
@@ -3469,7 +3448,8 @@ sub _end_line_misc_line($$$)
   } elsif ($command eq 'node') {
     for (my $i = 1; $i < scalar(@{$current->{'args'}}); $i++) {
       my $arg = $current->{'args'}->[$i];
-      my $arg_label_manual_info = _parse_node_manual($arg);
+      my $arg_label_manual_info
+        = Texinfo::Common::parse_node_manual($arg, 1);
       if (defined($arg_label_manual_info)) {
         # 'node_content' 'manual_content'
         foreach my $label_info (keys(%$arg_label_manual_info)) {
@@ -4416,7 +4396,8 @@ sub _register_extra_menu_entry_information($$;$)
         }
       } else {
         $menu_entry_node = $arg;
-        my $parsed_entry_node = _parse_node_manual($arg);
+        my $parsed_entry_node
+          = Texinfo::Common::parse_node_manual($arg, 1);
         if (defined($parsed_entry_node)) {
           foreach my $label_info (keys(%$parsed_entry_node)) {
             $arg->{'extra'} = {} if (!$arg->{'extra'});
@@ -6314,7 +6295,8 @@ sub _process_remaining_on_line($$$$)
                                     $closed_command), $source_info);
             } else {
               my $arg_label = $ref->{'args'}->[0];
-              my $ref_label_info = _parse_node_manual($arg_label);
+              my $ref_label_info
+                = Texinfo::Common::parse_node_manual($arg_label, 1);
               if (defined $ref_label_info) {
                 foreach my $label_info (keys(%$ref_label_info)) {
                   $arg_label->{'extra'} = {} if (!$arg_label->{'extra'});
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 6f468ea692..8dd947d1d2 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -1689,10 +1689,8 @@ sub new_node_menu_entry
     $arg->{'parent'} = $entry;
   }
 
-  my ($parsed_node_manual, $modified_node_content)
-    = Texinfo::Common::parse_node_manual($menu_entry_node);
-  $menu_entry_node->{'contents'} = $modified_node_content
-    if ($modified_node_content);
+  my $parsed_node_manual
+    = Texinfo::Common::parse_node_manual($menu_entry_node, 1);
   if (defined($parsed_node_manual)) {
     foreach my $label_info (keys(%$parsed_node_manual)) {
       $menu_entry_node->{'extra'} = {} if (!$menu_entry_node->{'extra'});



reply via email to

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