texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/ParserNonXS.pm (_close_current, _han


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_close_current, _handle_close_brace), tp/Texinfo/XS/parsetexi/close.c (close_current), tp/Texinfo/XS/parsetexi/separator.c (handle_close_brace): separate code handling bracketed_arg and balanced_braces. No functional change.
Date: Sat, 11 Mar 2023 05:26:59 -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 7925b8189f * tp/Texinfo/ParserNonXS.pm (_close_current, 
_handle_close_brace), tp/Texinfo/XS/parsetexi/close.c (close_current), 
tp/Texinfo/XS/parsetexi/separator.c (handle_close_brace): separate code 
handling bracketed_arg and balanced_braces.  No functional change.
7925b8189f is described below

commit 7925b8189fe89b3e203e1771f7444cb7aad7af70
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Mar 11 11:26:50 2023 +0100

    * tp/Texinfo/ParserNonXS.pm (_close_current, _handle_close_brace),
    tp/Texinfo/XS/parsetexi/close.c (close_current),
    tp/Texinfo/XS/parsetexi/separator.c (handle_close_brace): separate
    code handling bracketed_arg and balanced_braces.  No functional
    change.
---
 ChangeLog                           |  8 +++++++
 tp/Texinfo/ParserNonXS.pm           | 42 ++++++++++++++++++-------------------
 tp/Texinfo/XS/parsetexi/close.c     | 22 +++++++++----------
 tp/Texinfo/XS/parsetexi/separator.c | 13 ++++++------
 4 files changed, 45 insertions(+), 40 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 801b12729d..bcf5dbabb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-03-11  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_close_current, _handle_close_brace),
+       tp/Texinfo/XS/parsetexi/close.c (close_current),
+       tp/Texinfo/XS/parsetexi/separator.c (handle_close_brace): separate
+       code handling bracketed_arg and balanced_braces.  No functional
+       change.
+
 2023-03-11  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_handle_open_brace, _handle_close_brace),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index f50c032280..e5768e4592 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2044,24 +2044,25 @@ sub _close_current($$$;$$)
     }
   } elsif ($current->{'type'}) {
     print STDERR "CLOSING type $current->{'type'}\n" if ($self->{'DEBUG'});
-    if ($current->{'type'} eq 'balanced_braces'
-        or $current->{'type'} eq 'bracketed_arg') {
-      # unclosed bracketed
+    if ($current->{'type'} eq 'bracketed_arg') {
+      # unclosed bracketed argument
       $self->_command_error($current, $source_info, __("misplaced {"));
-      if ($current->{'type'} eq 'balanced_braces') {
-        # We prefer adding an element to merging because we may
-        # be at the end of the document after an empty line we
-        # do not want to modify
-        #$current = _merge_text($self, $current, '}');
-        my $close_brace = {'text' => '}', 'parent' => $current};
-        push @{$current->{'contents'}}, $close_brace;
-      } elsif ($current->{'contents'}
-               and $current->{'contents'}->[0]->{'type'}
-               and $current->{'contents'}->[0]->{'type'}
-                              eq 'internal_spaces_before_argument') {
+      if ($current->{'contents'}
+          and $current->{'contents'}->[0]->{'type'}
+          and $current->{'contents'}->[0]->{'type'}
+                        eq 'internal_spaces_before_argument') {
         # remove spaces element from tree and update extra values
         _abort_empty_line($self, $current);
       }
+    } elsif ($current->{'type'} eq 'balanced_braces') {
+      # unclosed braces in contexts accepting lone braces
+      $self->_command_error($current, $source_info, __("misplaced {"));
+      # We prefer adding an element to merging because we may
+      # be at the end of the document after an empty line we
+      # do not want to modify
+      #$current = _merge_text($self, $current, '}');
+      my $close_brace = {'text' => '}', 'parent' => $current};
+      push @{$current->{'contents'}}, $close_brace;
     } elsif ($current->{'type'} eq 'line_arg') {
       #$current = _end_line_misc_line($self, $current, $source_info);
       # We ignore the current returned $current, to be sure that
@@ -5743,14 +5744,11 @@ sub _handle_close_brace($$$)
     $current = _end_paragraph($self, $current, $source_info);
   }
 
-  if ($current->{'type'}
-      and ($current->{'type'} eq 'balanced_braces'
-           or $current->{'type'} eq 'bracketed_arg')) {
-    if ($current->{'type'} eq 'balanced_braces') {
-      $current = _merge_text($self, $current, '}');
-    } else {
-      _abort_empty_line($self, $current);
-    }
+  if ($current->{'type'} and $current->{'type'} eq 'balanced_braces') {
+    $current = _merge_text($self, $current, '}');
+    $current = $current->{'parent'};
+  } elsif ($current->{'type'} eq 'bracketed_arg') {
+    _abort_empty_line($self, $current);
     $current = $current->{'parent'};
   } elsif ($current->{'parent'}
       and $current->{'parent'}->{'cmdname'}
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index dd7da4aa8d..683566feb5 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -425,20 +425,18 @@ close_current (ELEMENT *current,
       switch (current->type)
         {
         case ET_balanced_braces:
+          ELEMENT *close_brace = new_element (ET_NONE);
+          command_error (current, "misplaced {");
+          /* We prefer adding an element to merging because we may
+             be at the end of the document after an empty line we
+             do not want to modify */
+          /* current = merge_text (current, "}", 0); */
+          text_append (&close_brace->text, "}");
+          add_to_element_contents (current, close_brace);
+          break;
         case ET_bracketed_arg:
           command_error (current, "misplaced {");
-          if (current->type == ET_balanced_braces)
-            {
-              /* We prefer adding an element to merging because we may
-                 be at the end of the document after an empty line we
-                do not want to modify */
-              /* current = merge_text (current, "}", 0); */
-              ELEMENT *close_brace = new_element (ET_NONE);
-              text_append (&close_brace->text, "}");
-              add_to_element_contents (current, close_brace);
-
-            }
-          else if (current->contents.number > 0
+          if (current->contents.number > 0
               && current->contents.list[0]->type
                  == ET_internal_spaces_before_argument)
             {
diff --git a/tp/Texinfo/XS/parsetexi/separator.c 
b/tp/Texinfo/XS/parsetexi/separator.c
index c11463c1aa..abf6a671a5 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -251,13 +251,14 @@ handle_close_brace (ELEMENT *current, char **line_inout)
       current = end_paragraph (current, 0, 0);
     }
 
-  if (current->type == ET_balanced_braces
-      || current->type == ET_bracketed_arg)
+  if (current->type == ET_balanced_braces)
     {
-      if (current->type == ET_balanced_braces)
-        current = merge_text (current, "}", 0);
-      else
-        abort_empty_line (&current, NULL);
+      current = merge_text (current, "}", 0);
+      current = current->parent;
+    }
+  else if (current->type == ET_bracketed_arg)
+    {
+      abort_empty_line (&current, NULL);
       current = current->parent;
     }
   else if (command_flags(current->parent) & CF_brace)



reply via email to

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