texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp DebugTexinfo/DebugTree.pm Texinfo/Co...


From: Patrice Dumas
Subject: texinfo/tp DebugTexinfo/DebugTree.pm Texinfo/Co...
Date: Fri, 28 Oct 2011 21:59:43 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/10/28 21:59:43

Modified files:
        tp/DebugTexinfo: DebugTree.pm 
        tp/Texinfo     : Common.pm Parser.pm 

Log message:
        Translate def like command aliases.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/DebugTexinfo/DebugTree.pm?cvsroot=texinfo&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.319&r2=1.320

Patches:
Index: DebugTexinfo/DebugTree.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/DebugTexinfo/DebugTree.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- DebugTexinfo/DebugTree.pm   20 Oct 2011 20:51:07 -0000      1.4
+++ DebugTexinfo/DebugTree.pm   28 Oct 2011 21:59:43 -0000      1.5
@@ -86,15 +86,16 @@
     $text =~ s/\n/\\n/g;
     $result .= "|$text|";
   }
-  print $result ."\n";
+  $result .= "\n";
   if ($root->{'args'}) {
     foreach my $arg (@{$root->{'args'}}) {
-      _print_tree ($self, $arg, $level +1, 1);
+      $result .= _print_tree ($self, $arg, $level +1, 1);
     }
   }
   if ($root->{'contents'}) {
     foreach my $content (@{$root->{'contents'}}) {
-      _print_tree ($self, $content, $level+1);
+      $result .= _print_tree ($self, $content, $level+1);
     }
   }
+  return $result;
 }

Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- Texinfo/Common.pm   27 Oct 2011 21:53:19 -0000      1.81
+++ Texinfo/Common.pm   28 Oct 2011 21:59:43 -0000      1.82
@@ -466,6 +466,11 @@
 
 $close_paragraph_commands{'exdent'} = 1;
 
+sub gdt($)
+{
+  return $_[0];
+}
+
 our %def_map = (
     # basic commands. 
     # 'arg' and 'argtype' are for everything appearing after the other
@@ -480,18 +485,17 @@
     'defop',     [ 'category', 'class' , 'name', 'arg' ],
     'deftp',     [ 'category', 'name', 'argtype' ],
     # shortcuts
-    # FIXME i18n
-    'defun',         {'deffn'     => 'Function'},
-    'defmac',        {'deffn'     => 'Macro'},
-    'defspec',       {'deffn'     => '{Special Form}'},
-    'defvar',        {'defvr'     => 'Variable'},
-    'defopt',        {'defvr'     => '{User Option}'},
-    'deftypefun',    {'deftypefn' => 'Function'},
-    'deftypevar',    {'deftypevr' => 'Variable'},
-    'defivar',       {'defcv'     => '{Instance Variable}'},
-    'deftypeivar',   {'deftypecv' => '{Instance Variable}'},
-    'defmethod',     {'defop'     => 'Method'},
-    'deftypemethod', {'deftypeop' => 'Method'},
+    'defun',         {'deffn'     => gdt('Function')},
+    'defmac',        {'deffn'     => gdt('Macro')},
+    'defspec',       {'deffn'     => '{'.gdt('Special Form').'}'},
+    'defvar',        {'defvr'     => gdt('Variable')},
+    'defopt',        {'defvr'     => '{'.gdt('User Option').'}'},
+    'deftypefun',    {'deftypefn' => gdt('Function')},
+    'deftypevar',    {'deftypevr' => gdt('Variable')},
+    'defivar',       {'defcv'     => '{'.gdt('Instance Variable').'}'},
+    'deftypeivar',   {'deftypecv' => '{'.gdt('Instance Variable').'}'},
+    'defmethod',     {'defop'     => gdt('Method')},
+    'deftypemethod', {'deftypeop' => gdt('Method')},
 );
 
 # the type of index, f: function, v: variable, t: type

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.319
retrieving revision 1.320
diff -u -b -r1.319 -r1.320
--- Texinfo/Parser.pm   21 Oct 2011 22:59:05 -0000      1.319
+++ Texinfo/Parser.pm   28 Oct 2011 21:59:43 -0000      1.320
@@ -261,28 +261,6 @@
     if ($brace_commands{$brace_command} > 1);
 }
 
-my %def_prepended_content;
-foreach my $def_command(keys %def_map) {
-
-  # prepare what will be prepended when the def command is an alias
-  if (ref($def_map{$def_command}) eq 'HASH') {
-    my ($real_command) = keys (%{$def_map{$def_command}});
-    my $prepended = $def_map{$def_command}->{$real_command};
-    if ($prepended =~ /^\{/) {
-      my $text = $prepended;
-      $text =~ s/\{([^\}]+)\}/$1/;
-      my $bracketed = { 'type' => 'bracketed'};
-      $bracketed->{'contents'} = [ { 'parent' => $bracketed,
-                                     'text' => $text } ];
-      $def_prepended_content{$def_command} = [$bracketed];
-    } else {
-      $def_prepended_content{$def_command} = [{ 'text' => $prepended }];
-    }
-    push @{$def_prepended_content{$def_command}}, { 'text' => ' ' };
-  }
-}
-
-
 my %type_with_paragraph;
 foreach my $type ('before_item', 'text_root', 'document_root',
                   'brace_command_context') {
@@ -2054,7 +2032,34 @@
   shift @contents if ($contents[0] and $contents[0]->{'type'}
                     and $contents[0]->{'type'} eq 
'empty_spaces_after_command');
   if ($def_aliases{$command}) {
-    unshift @contents, @{$def_prepended_content{$command}};
+    my $real_command = $def_aliases{$command};
+    my $prepended = $def_map{$command}->{$real_command};
+    my @prepended_content;
+
+    my $text;
+    my $in_bracketed;
+    if ($prepended =~ /^\{/) {
+      $text = $prepended;
+      $text =~ s/\{([^\}]+)\}/$1/;
+      $in_bracketed = 1;
+    } else {
+      $text = $prepended;
+    }
+    my $tree = $self->gdt($text);
+    if ($in_bracketed or @{$tree->{'contents'}} > 1) {
+      my $bracketed = { 'type' => 'bracketed' };
+      $bracketed->{'contents'} = $tree->{'contents'};
+      foreach my $content (@{$tree->{'contents'}}) {
+        $content->{'parent'} = $bracketed;
+      }
+      @prepended_content = ($bracketed);
+    } else {
+      @prepended_content = (@{$tree->{'contents'}});
+    }
+    push @prepended_content, { 'text' => ' ' };
+
+    unshift @contents, @prepended_content;
+
     $command = $def_aliases{$command};
   }
   foreach (my $i = 0; $i < scalar(@contents); $i++) {



reply via email to

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