texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp texi2any.pl Texinfo/Common.pm t/resu...


From: Patrice Dumas
Subject: texinfo/tp texi2any.pl Texinfo/Common.pm t/resu...
Date: Tue, 11 Sep 2012 00:05:36 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        12/09/11 00:05:35

Modified files:
        tp             : texi2any.pl 
        tp/Texinfo     : Common.pm 
        tp/t/results/include: macro_and_commands_in_early_commands.pl 
                              macro_definition_in_include.pl 
                              macro_in_early_commands.pl 
                              value_expansion_in_include.pl 
        tp/t/results/sectioning: raiselowersections.pl 

Log message:
        Use platform independent file and directory handling functions for
        include files location and command name determination.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.138&r2=1.139
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.153&r2=1.154
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/include/macro_and_commands_in_early_commands.pl?cvsroot=texinfo&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/include/macro_definition_in_include.pl?cvsroot=texinfo&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/include/macro_in_early_commands.pl?cvsroot=texinfo&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/include/value_expansion_in_include.pl?cvsroot=texinfo&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/sectioning/raiselowersections.pl?cvsroot=texinfo&r1=1.46&r2=1.47

Patches:
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -b -r1.138 -r1.139
--- texi2any.pl 8 Sep 2012 16:16:11 -0000       1.138
+++ texi2any.pl 11 Sep 2012 00:05:32 -0000      1.139
@@ -29,7 +29,7 @@
 use File::Spec;
 # to determine the path separator and null file
 use Config;
-# for dirname.
+# for dirname and fileparse
 use File::Basename;
 #use Cwd;
 use Getopt::Long qw(GetOptions);
@@ -44,8 +44,8 @@
         and $texinfolibdir ne '@' .'datadir@/@PACKAGE'.'@');
 }
 
-my $real_command_name = $0;
-$real_command_name =~ s/.*\///;
+my ($filename, $directories, $suffix) = fileparse($0);
+my $real_command_name = $filename;
 $real_command_name =~ s/\.pl$//;
 
 # this associates the command line options to the arrays set during
@@ -84,8 +84,8 @@
   $datarootdir = '/usr/local/share';
 }
 if ('@datadir@' ne '@' . 'datadir@') {
-  $pkgdatadir = eval '"@datadir@/@PACKAGE@"';
   $datadir = eval '"@datadir@"';
+  $pkgdatadir = eval '"@datadir@/@PACKAGE@"';
 } else {
   $pkgdatadir = '/usr/local/share/texinfo';
   $datadir = '/usr/local/share';

Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -b -r1.153 -r1.154
--- Texinfo/Common.pm   18 Aug 2012 23:37:00 -0000      1.153
+++ Texinfo/Common.pm   11 Sep 2012 00:05:32 -0000      1.154
@@ -859,8 +859,29 @@
   my $text = shift;
   my $file;
 
+  my $ignore_include_directories = 0;
+
+  my ($volume, $directories, $filename) = File::Spec->splitpath($text);
+  my @directories = File::Spec->splitdir($directories);
+
   #print STDERR "$self $text @{$self->{'include_directories'}}\n";
-  if ($text =~ m,^(/|\./|\.\./),) {
+  # If the path is absolute or begins with . or .., do not search in
+  # include directories.
+  if (File::Spec->file_name_is_absolute($text)) {
+    $ignore_include_directories = 1;
+  } else {
+    foreach my $dir (@directories) {
+      if ($dir eq File::Spec->updir() or $dir eq File::Spec->curdir()) {
+        $ignore_include_directories = 1;
+        last;
+      } elsif ($dir ne '') {
+        last;
+      }
+    }
+  }
+
+  #if ($text =~ m,^(/|\./|\.\./),) {
+  if ($ignore_include_directories) {
     $file = $text if (-e $text and -r $text);
   } else {
     my @dirs;
@@ -870,8 +891,15 @@
       # no object with directory list and not an absolute path, never succeed
       return undef;
     }
-    foreach my $dir (@{$self->{'include_directories'}}) {
-      $file = "$dir/$text" if (-e "$dir/$text" and -r "$dir/$text");
+    foreach my $include_dir (@{$self->{'include_directories'}}) {
+      my ($include_volume, $include_directories, $include_filename) 
+         = File::Spec->splitpath($include_dir, 1);
+      
+      my $possible_file = File::Spec->catpath($include_volume, 
+        File::Spec->catdir(File::Spec->splitdir($include_directories), 
+                           @directories), $filename);
+      #$file = "$include_dir/$text" if (-e "$include_dir/$text" and -r 
"$include_dir/$text");
+      $file = "$possible_file" if (-e "$possible_file" and -r 
"$possible_file");
       last if (defined($file));
     }
   }

Index: t/results/include/macro_and_commands_in_early_commands.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/include/macro_and_commands_in_early_commands.pl,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- t/results/include/macro_and_commands_in_early_commands.pl   23 Aug 2012 
18:14:45 -0000      1.37
+++ t/results/include/macro_and_commands_in_early_commands.pl   11 Sep 2012 
00:05:33 -0000      1.38
@@ -397,7 +397,7 @@
             }
           },
           'line_nr' => {
-            'file_name' => 't/include_dir//macro_included.texi',
+            'file_name' => 't/include_dir/macro_included.texi',
             'line_nr' => 1,
             'macro' => ''
           },

Index: t/results/include/macro_definition_in_include.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/include/macro_definition_in_include.pl,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- t/results/include/macro_definition_in_include.pl    23 Aug 2012 18:14:45 
-0000      1.19
+++ t/results/include/macro_definition_in_include.pl    11 Sep 2012 00:05:34 
-0000      1.20
@@ -45,7 +45,7 @@
         }
       },
       'line_nr' => {
-        'file_name' => 't/include_dir//macro_included.texi',
+        'file_name' => 't/include_dir/macro_included.texi',
         'line_nr' => 1,
         'macro' => ''
       },

Index: t/results/include/macro_in_early_commands.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/include/macro_in_early_commands.pl,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- t/results/include/macro_in_early_commands.pl        23 Aug 2012 18:14:45 
-0000      1.37
+++ t/results/include/macro_in_early_commands.pl        11 Sep 2012 00:05:34 
-0000      1.38
@@ -491,7 +491,7 @@
             }
           },
           'line_nr' => {
-            'file_name' => 't/include_dir//macro_included.texi',
+            'file_name' => 't/include_dir/macro_included.texi',
             'line_nr' => 1,
             'macro' => ''
           },

Index: t/results/include/value_expansion_in_include.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/include/value_expansion_in_include.pl,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- t/results/include/value_expansion_in_include.pl     23 Aug 2012 18:14:45 
-0000      1.35
+++ t/results/include/value_expansion_in_include.pl     11 Sep 2012 00:05:35 
-0000      1.36
@@ -178,7 +178,7 @@
               'cmdname' => 'emph',
               'contents' => [],
               'line_nr' => {
-                'file_name' => 't/include_dir//incl-incl.txi',
+                'file_name' => 't/include_dir/incl-incl.txi',
                 'line_nr' => 1,
                 'macro' => ''
               },
@@ -282,7 +282,7 @@
               'cmdname' => 'emph',
               'contents' => [],
               'line_nr' => {
-                'file_name' => 't/include_dir//incl-incl.txi',
+                'file_name' => 't/include_dir/incl-incl.txi',
                 'line_nr' => 1,
                 'macro' => ''
               },
@@ -386,7 +386,7 @@
               'cmdname' => 'emph',
               'contents' => [],
               'line_nr' => {
-                'file_name' => 't/include_dir//incl-incl.txi',
+                'file_name' => 't/include_dir/incl-incl.txi',
                 'line_nr' => 1,
                 'macro' => ''
               },

Index: t/results/sectioning/raiselowersections.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/sectioning/raiselowersections.pl,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- t/results/sectioning/raiselowersections.pl  24 Aug 2012 20:43:00 -0000      
1.46
+++ t/results/sectioning/raiselowersections.pl  11 Sep 2012 00:05:35 -0000      
1.47
@@ -657,7 +657,7 @@
         'spaces_after_command' => {}
       },
       'line_nr' => {
-        'file_name' => 't/include_dir//section_file.texi',
+        'file_name' => 't/include_dir/section_file.texi',
         'line_nr' => 12,
         'macro' => ''
       },
@@ -760,7 +760,7 @@
                 }
               },
               'line_nr' => {
-                'file_name' => 't/include_dir//section_file.texi',
+                'file_name' => 't/include_dir/section_file.texi',
                 'line_nr' => 16,
                 'macro' => ''
               },
@@ -802,7 +802,7 @@
                 'text_arg' => 'menu'
               },
               'line_nr' => {
-                'file_name' => 't/include_dir//section_file.texi',
+                'file_name' => 't/include_dir/section_file.texi',
                 'line_nr' => 17,
                 'macro' => ''
               },
@@ -814,7 +814,7 @@
             'spaces_after_command' => {}
           },
           'line_nr' => {
-            'file_name' => 't/include_dir//section_file.texi',
+            'file_name' => 't/include_dir/section_file.texi',
             'line_nr' => 15,
             'macro' => ''
           },
@@ -836,7 +836,7 @@
       },
       'level' => 2,
       'line_nr' => {
-        'file_name' => 't/include_dir//section_file.texi',
+        'file_name' => 't/include_dir/section_file.texi',
         'line_nr' => 13,
         'macro' => ''
       },
@@ -886,7 +886,7 @@
         'spaces_after_command' => {}
       },
       'line_nr' => {
-        'file_name' => 't/include_dir//section_file.texi',
+        'file_name' => 't/include_dir/section_file.texi',
         'line_nr' => 19,
         'macro' => ''
       },
@@ -989,7 +989,7 @@
                 }
               },
               'line_nr' => {
-                'file_name' => 't/include_dir//section_file.texi',
+                'file_name' => 't/include_dir/section_file.texi',
                 'line_nr' => 23,
                 'macro' => ''
               },
@@ -1031,7 +1031,7 @@
                 'text_arg' => 'menu'
               },
               'line_nr' => {
-                'file_name' => 't/include_dir//section_file.texi',
+                'file_name' => 't/include_dir/section_file.texi',
                 'line_nr' => 24,
                 'macro' => ''
               },
@@ -1043,7 +1043,7 @@
             'spaces_after_command' => {}
           },
           'line_nr' => {
-            'file_name' => 't/include_dir//section_file.texi',
+            'file_name' => 't/include_dir/section_file.texi',
             'line_nr' => 22,
             'macro' => ''
           },
@@ -1065,7 +1065,7 @@
       },
       'level' => 3,
       'line_nr' => {
-        'file_name' => 't/include_dir//section_file.texi',
+        'file_name' => 't/include_dir/section_file.texi',
         'line_nr' => 20,
         'macro' => ''
       },
@@ -1115,7 +1115,7 @@
         'spaces_after_command' => {}
       },
       'line_nr' => {
-        'file_name' => 't/include_dir//section_file.texi',
+        'file_name' => 't/include_dir/section_file.texi',
         'line_nr' => 26,
         'macro' => ''
       },
@@ -1211,7 +1211,7 @@
       },
       'level' => 4,
       'line_nr' => {
-        'file_name' => 't/include_dir//section_file.texi',
+        'file_name' => 't/include_dir/section_file.texi',
         'line_nr' => 27,
         'macro' => ''
       },



reply via email to

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