[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8206] _isolate_last_space simplify
From: |
gavinsmith0123 |
Subject: |
[8206] _isolate_last_space simplify |
Date: |
Sat, 22 Sep 2018 13:01:02 -0400 (EDT) |
Revision: 8206
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8206
Author: gavin
Date: 2018-09-22 13:01:02 -0400 (Sat, 22 Sep 2018)
Log Message:
-----------
_isolate_last_space simplify
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Parser.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2018-09-22 13:47:47 UTC (rev 8205)
+++ trunk/ChangeLog 2018-09-22 17:01:02 UTC (rev 8206)
@@ -1,5 +1,10 @@
2018-09-22 Gavin Smith <address@hidden>
+ * tp/Texinfo/Parser.pm (_isolate_last_space): Simplify code by
+ taking out conditionals that are common to two blocks.
+
+2018-09-22 Gavin Smith <address@hidden>
+
* tp/Texinfo/Parser.pm (_parse_texi) <@sortas>: Don't call
_trim_spaces_comment_from_content.
Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm 2018-09-22 13:47:47 UTC (rev 8205)
+++ trunk/tp/Texinfo/Parser.pm 2018-09-22 17:01:02 UTC (rev 8206)
@@ -2182,24 +2182,21 @@
= pop @{$current->{'contents'}};
}
- return if (address@hidden>{'contents'}});
+ return if address@hidden>{'contents'}}
+ or !defined($current->{'contents'}->[-1]->{'text'})
+ or $current->{'contents'}->[-1]->{'type'}
+ or $current->{'contents'}->[-1]->{'text'} !~ /\s+$/;
if ($current->{'type'} and $current->{'type'} eq 'menu_entry_node') {
- if (defined($current->{'contents'}->[-1]->{'text'})
- and !$current->{'contents'}->[-1]->{'type'}
- and $current->{'contents'}->[-1]->{'text'} =~ /\s+$/) {
- if ($current->{'contents'}->[-1]->{'text'} !~ /\S/) {
- $current->{'contents'}->[-1]->{'type'} = 'space_at_end_menu_node';
- } else {
- $current->{'contents'}->[-1]->{'text'} =~ s/(\s+)$//;
- my $new_spaces = { 'text' => $1, 'parent' => $current,
- 'type' => 'space_at_end_menu_node' };
- push @{$current->{'contents'}}, $new_spaces;
- }
+ if ($current->{'contents'}->[-1]->{'text'} !~ /\S/) {
+ $current->{'contents'}->[-1]->{'type'} = 'space_at_end_menu_node';
+ } else {
+ $current->{'contents'}->[-1]->{'text'} =~ s/(\s+)$//;
+ my $new_spaces = { 'text' => $1, 'parent' => $current,
+ 'type' => 'space_at_end_menu_node' };
+ push @{$current->{'contents'}}, $new_spaces;
}
- } elsif (defined($current->{'contents'}->[-1]->{'text'})
- and !$current->{'contents'}->[-1]->{'type'}
- and $current->{'contents'}->[-1]->{'text'} =~ /\s+$/) {
+ } else {
# Store final spaces in 'spaces_after_argument'.
if ($current->{'contents'}->[-1]->{'text'} !~ /\S/) {
my $end_spaces = $current->{'contents'}->[-1]->{'text'};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8206] _isolate_last_space simplify,
gavinsmith0123 <=