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): retur


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (parse_node_manual): return directly undef if there is no contents. Code stylistic and variable names changes.
Date: Sun, 18 Sep 2022 16:28:52 -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 235ac8a5e1 * tp/Texinfo/Common.pm (parse_node_manual): return directly 
undef if there is no contents.  Code stylistic and variable names changes.
235ac8a5e1 is described below

commit 235ac8a5e1165d64b7abd1c68fa3ffc58d0f8489
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 18 22:28:41 2022 +0200

    * tp/Texinfo/Common.pm (parse_node_manual): return directly undef
    if there is no contents.  Code stylistic and variable names changes.
---
 ChangeLog            |  5 +++++
 man/pod2texi.1       |  2 +-
 tp/Texinfo/Common.pm | 36 +++++++++++++++++-------------------
 3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5d06a15b19..e9d37dcf52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-09-18  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (parse_node_manual): return directly undef
+       if there is no contents.  Code stylistic and variable names changes.
+
 2022-09-18  Patrice Dumas  <pertusus@free.fr>
 
        * Pod-Simple-Texinfo/pod2texi.pl (_parsed_manual_tree): update/fix
diff --git a/man/pod2texi.1 b/man/pod2texi.1
index 2801ebb50c..8898dc5c01 100644
--- a/man/pod2texi.1
+++ b/man/pod2texi.1
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "POD2TEXI 1"
-.TH POD2TEXI 1 "2022-08-13" "perl v5.34.0" "User Contributed Perl 
Documentation"
+.TH POD2TEXI 1 "2022-09-18" "perl v5.34.0" "User Contributed Perl 
Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index e2961851e4..299705940a 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1466,36 +1466,33 @@ sub _count_opened_tree_braces($$)
 #
 # Could be documented, but only is there is evidence that this function
 # is useful in user-defined code.
-#
-# FIXME need to clean the code, simply returning undef if there are
-# no contents does not work, this is not normal.
 sub parse_node_manual($)
 {
   my $label_contents_container = shift;
 
-  #return ($label_contents_container, undef)
-  #   if (!$label_contents_container->{'contents'});
+  return (undef, undef)
+     if (!$label_contents_container->{'contents'});
 
-  my @contents;
-  @contents = @{$label_contents_container->{'contents'}}
-     if ($label_contents_container->{'contents'});
+  # the elements are not modified, when modifications are needed new elements
+  # are setup.
+  my @contents = @{$label_contents_container->{'contents'}};
 
   my $manual;
   my $result;
   my ($end_paren, $spaces_after);
 
   if ($contents[0] and $contents[0]->{'text'} and $contents[0]->{'text'} =~ 
/^\(/) {
-    # remove the leading (, it is not in manual_content
+    # remove the leading ( from @contents, it is not in manual_content.
     my $braces_count = 1;
-    if ($contents[0]->{'text'} !~ /^\($/) {
-      my $brace = shift @contents;
-      my $brace_text = $brace->{'text'};
+    if ($contents[0]->{'text'} ne '(') {
+      my $first_element = shift @contents;
+      my $brace_text = $first_element->{'text'};
       $brace_text =~ s/^\(//;
-      if ($brace_text ne '') {
-        my $added_content = { 'text' => $brace_text, 'parent' => 
$brace->{'parent'} };
-        $added_content->{'type'} = $brace->{'type'} if 
defined($brace->{'type'});
-        unshift @contents, $added_content;
-      }
+      my $new_element = { 'text' => $brace_text,
+                          'parent' => $first_element->{'parent'} };
+      $new_element->{'type'} = $first_element->{'type'}
+         if defined($first_element->{'type'});
+      unshift @contents, $new_element;
     } else {
       shift @contents;
     }
@@ -1532,10 +1529,11 @@ sub parse_node_manual($)
     if ($braces_count == 0) {
       $result->{'manual_content'} = $manual if (defined($manual));
     } else {
-      @contents = ({ 'text' => '(', 'parent' => $label_contents_container }, 
@$manual);
+      # unclosed brace, reset @contents
+      @contents = @{$label_contents_container->{'contents'}};
     }
   }
-  if (@contents) {
+  if (scalar(@contents) > 0) {
     $result->{'node_content'} = \@contents;
   }
 



reply via email to

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