texinfo-commits
[Top][All Lists]
Advanced

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

[8120] reorder some code


From: gavinsmith0123
Subject: [8120] reorder some code
Date: Sat, 25 Aug 2018 12:33:25 -0400 (EDT)

Revision: 8120
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8120
Author:   gavin
Date:     2018-08-25 12:33:25 -0400 (Sat, 25 Aug 2018)
Log Message:
-----------
reorder some code

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Parser.pm

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2018-08-25 16:17:50 UTC (rev 8119)
+++ trunk/ChangeLog     2018-08-25 16:33:25 UTC (rev 8120)
@@ -1,5 +1,18 @@
 2018-08-25  Gavin Smith  <address@hidden>
 
+       * tp/Texinfo/Parser.pm (_parse_def): Reorder some code.
+
+2018-08-25  Gavin Smith  <address@hidden>
+
+       * tp/Texinfo/Parser.pm (_split_def_args): New function.
+       (_parse_def): Use "map" with _split_def_args to create the
+       array of def line contents.  This does all at once what
+       _next_bracketed_or_word did across all the times it was called.
+       (_next_bracketed_or_word): Collect elements from the array that
+       has already been processed.
+
+2018-08-25  Gavin Smith  <address@hidden>
+
        * tp/Texinfo/Structuring.pm (new_block_command)
        * tp/Texinfo/Parser.pm (_parse_texi, _end_line):
        Do not set 'command' extra value on 'empty_line_after_command'

Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm  2018-08-25 16:17:50 UTC (rev 8119)
+++ trunk/tp/Texinfo/Parser.pm  2018-08-25 16:33:25 UTC (rev 8120)
@@ -2355,13 +2355,22 @@
     $command = $def_aliases{$command};
   }
   @contents = map (_split_def_args($self, $_), @contents );
+  @new_contents = @contents;
+  if (@prepended_content) {
+    # Remove the @prepended_content added above.
+    splice @new_contents, 0, scalar (@prepended_content);
+  }
+  unshift @new_contents, $empty_spaces_after_command
+    if $empty_spaces_after_command; 
+  foreach (my $i = 0; $i < scalar(@new_contents); $i++) {
+    # copy, to avoid changing in the code below.
+    $new_contents[$i] = { %{$new_contents[$i]} }
+     if $new_contents[$i]->{'text'}
+         and (!$new_contents[$i]->{'type'}
+              or $new_contents[$i]->{'type'} ne 'empty_spaces_after_command');
+  }
+  $current->{'contents'} = address@hidden;
   
-  my @result;
-  my @args = @{$def_map{$command}};
-  my $arg_type;
-  # Even when $arg_type is not set, that is for def* that is not documented
-  # to take args, everything is as is arg_type was set to arg.
-  $arg_type = pop @args if ($args[-1] eq 'arg' or $args[-1] eq 'argtype');
   my @def_line = ();
   # tokenize the line.  We need to do that in order to be able to 
   # look ahead for spaces.
@@ -2373,7 +2382,6 @@
     # it here.
     if (defined($spaces)) {
       push @def_line, ['spaces', $spaces] if scalar(@def_line) != 0;
-      push @new_contents, $spaces;
     }
     last if (!defined($next));
     if ($next->{'type'} and $next->{'type'} eq 'bracketed_def_content') {
@@ -2381,23 +2389,17 @@
     } else {
       push @def_line, ['text_or_cmd', $next];
     }
-    push @new_contents, $next;
   }
-  if (@prepended_content) {
-    # Remove the @prepended_content added above.
-    splice @new_contents, 0, scalar (@prepended_content);
-  }
-  unshift @new_contents, $empty_spaces_after_command
-    if $empty_spaces_after_command; 
-  foreach (my $i = 0; $i < scalar(@new_contents); $i++) {
-    # copy, to avoid changing in the code below.
-    $new_contents[$i] = { %{$new_contents[$i]} }
-     if $new_contents[$i]->{'text'}
-         and (!$new_contents[$i]->{'type'}
-              or $new_contents[$i]->{'type'} ne 'empty_spaces_after_command');
-  }
-  $current->{'contents'} = address@hidden;
 
+  my @result;
+  my @args = @{$def_map{$command}};
+  my $arg_type;
+
+
+  $arg_type = pop @args if ($args[-1] eq 'arg' or $args[-1] eq 'argtype');
+  # If $arg_type is not set (for @def* commands that are not documented
+  # to take args), everything happens as if arg_type was set to 'arg'.
+
   my $argument_content = [];
   my $arg = shift (@args);
   while (@def_line) {




reply via email to

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