texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Con


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/TexinfoXML.pm (_collect_leading_trailing_spaces_arg): move to Texinfo::Convert::TexinfoXML as it is only used there.
Date: Sat, 11 Sep 2021 06:29:34 -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 d02ca35  * tp/Texinfo/Convert/Converter.pm, 
tp/Texinfo/Convert/TexinfoXML.pm (_collect_leading_trailing_spaces_arg): move 
to Texinfo::Convert::TexinfoXML as it is only used there.
d02ca35 is described below

commit d02ca35e69c4ad81f34c24bc380d1047fd905310
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Sep 11 12:29:26 2021 +0200

    * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/TexinfoXML.pm
    (_collect_leading_trailing_spaces_arg): move to
    Texinfo::Convert::TexinfoXML as it is only used there.
---
 ChangeLog                        |  6 +++++
 tp/Texinfo/Convert/Converter.pm  | 50 -------------------------------------
 tp/Texinfo/Convert/TexinfoXML.pm | 53 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 50 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 82214b3..909d3f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2021-09-11  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/TexinfoXML.pm
+       (_collect_leading_trailing_spaces_arg): move to
+       Texinfo::Convert::TexinfoXML as it is only used there.
+
+2021-09-11  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Convert/TexinfoXML.pm (_leading_trailing_spaces_arg):
        avoid code duplication.
 
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 69342ae..d627521 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1106,56 +1106,6 @@ sub _end_line_or_comment($$)
   return $end_line;
 }
 
-sub _collect_leading_trailing_spaces_arg($$)
-{
-  my $self = shift;
-  my $arg = shift;
-  #print STDERR "$arg->{'type'}: @{$arg->{'contents'}}\n";
-  my @result;
-  if ($arg->{'extra'} and
-      $arg->{'extra'}->{'spaces_before_argument'}) {
-    $result[0] = $arg->{'extra'}->{'spaces_before_argument'};
-  } elsif ($arg->{'contents'} and $arg->{'contents'}->[0] 
-      and defined($arg->{'contents'}->[0]->{'text'})
-      and $arg->{'contents'}->[0]->{'text'} !~ /\S/
-      and defined($arg->{'contents'}->[0]->{'type'})) {
-    #print STDERR "$arg->{'contents'}->[0]->{'type'}\n";
-    warn "Unknown leading space type $arg->{'contents'}->[0]->{'type'}\n"
-      if ($arg->{'contents'}->[0]->{'type'} ne 'empty_spaces_after_command'
-          and $arg->{'contents'}->[0]->{'type'} ne 
'empty_spaces_before_argument'
-          # FIXME should we really catch this too?
-          and $arg->{'contents'}->[0]->{'type'} ne 'empty_line_after_command'
-         );
-    $result[0] = $arg->{'contents'}->[0]->{'text'};
-    return @result if (scalar(@{$arg->{'contents'}}) == 1);
-  }
-
-  if ($arg->{'extra'} and
-      $arg->{'extra'}->{'spaces_after_argument'}) {
-    $result[1] = $arg->{'extra'}->{'spaces_after_argument'};
-  } elsif ($arg->{'contents'}) {
-    my $index = -1;
-    $index-- if ($arg->{'contents'}->[-1] 
-                 and $arg->{'contents'}->[-1]->{'cmdname'}
-                 and ($arg->{'contents'}->[-1]->{'cmdname'} eq 'c'
-                      or $arg->{'contents'}->[-1]->{'cmdname'} eq 'comment'));
-    if (scalar(@{$arg->{'contents'}}) + $index > 0) {
-      if ($arg->{'contents'}->[$index] 
-          and defined($arg->{'contents'}->[$index]->{'text'})
-          and $arg->{'contents'}->[$index]->{'text'} !~ /\S/
-          and defined($arg->{'contents'}->[$index]->{'type'})) {
-      #print STDERR "$arg->{'contents'}->[$index]->{'type'}\n";
-        warn "Unknown trailing space type 
$arg->{'contents'}->[$index]->{'type'}\n"
-          if ($arg->{'contents'}->[$index]->{'type'} ne 'spaces_at_end'
-              and $arg->{'contents'}->[$index]->{'type'} ne 
'space_at_end_block_command'
-             );
-        $result[1] = $arg->{'contents'}->[$index]->{'text'};
-      }
-    }
-  }
-  return @result;
-}
-
 sub _table_item_content_tree($$$)
 {
   my $self = shift;
diff --git a/tp/Texinfo/Convert/TexinfoXML.pm b/tp/Texinfo/Convert/TexinfoXML.pm
index e16e8fe..e46fbb6 100644
--- a/tp/Texinfo/Convert/TexinfoXML.pm
+++ b/tp/Texinfo/Convert/TexinfoXML.pm
@@ -619,6 +619,59 @@ sub _arg_line($)
   return ();
 }
 
+# more generic than what is actually used, as the leading spaces
+# are never used.  But it is relevant to collect them here in case
+# there are only spaces.
+sub _collect_leading_trailing_spaces_arg($$)
+{
+  my $self = shift;
+  my $arg = shift;
+  #print STDERR "$arg->{'type'}: @{$arg->{'contents'}}\n";
+  my @result;
+  if ($arg->{'extra'} and
+      $arg->{'extra'}->{'spaces_before_argument'}) {
+    $result[0] = $arg->{'extra'}->{'spaces_before_argument'};
+  } elsif ($arg->{'contents'} and $arg->{'contents'}->[0]
+      and defined($arg->{'contents'}->[0]->{'text'})
+      and $arg->{'contents'}->[0]->{'text'} !~ /\S/
+      and defined($arg->{'contents'}->[0]->{'type'})) {
+    #print STDERR "$arg->{'contents'}->[0]->{'type'}\n";
+    warn "Unknown leading space type $arg->{'contents'}->[0]->{'type'}\n"
+      if ($arg->{'contents'}->[0]->{'type'} ne 'empty_spaces_after_command'
+          and $arg->{'contents'}->[0]->{'type'} ne 
'empty_spaces_before_argument'
+          # FIXME should we really catch this too?
+          and $arg->{'contents'}->[0]->{'type'} ne 'empty_line_after_command'
+         );
+    $result[0] = $arg->{'contents'}->[0]->{'text'};
+    return @result if (scalar(@{$arg->{'contents'}}) == 1);
+  }
+
+  if ($arg->{'extra'} and
+      $arg->{'extra'}->{'spaces_after_argument'}) {
+    $result[1] = $arg->{'extra'}->{'spaces_after_argument'};
+  } elsif ($arg->{'contents'}) {
+    my $index = -1;
+    $index-- if ($arg->{'contents'}->[-1]
+                 and $arg->{'contents'}->[-1]->{'cmdname'}
+                 and ($arg->{'contents'}->[-1]->{'cmdname'} eq 'c'
+                      or $arg->{'contents'}->[-1]->{'cmdname'} eq 'comment'));
+    if (scalar(@{$arg->{'contents'}}) + $index > 0) {
+      if ($arg->{'contents'}->[$index]
+          and defined($arg->{'contents'}->[$index]->{'text'})
+          and $arg->{'contents'}->[$index]->{'text'} !~ /\S/
+          and defined($arg->{'contents'}->[$index]->{'type'})) {
+      #print STDERR "$arg->{'contents'}->[$index]->{'type'}\n";
+        warn "Unknown trailing space type 
$arg->{'contents'}->[$index]->{'type'}\n"
+          if ($arg->{'contents'}->[$index]->{'type'} ne 'spaces_at_end'
+              and $arg->{'contents'}->[$index]->{'type'} ne 
'space_at_end_block_command'
+             );
+        $result[1] = $arg->{'contents'}->[$index]->{'text'};
+      }
+    }
+  }
+  return @result;
+}
+
 sub _trailing_spaces_arg($$)
 {
   my $self = shift;



reply via email to

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