autoconf-patches
[Top][All Lists]
Advanced

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

36-fyi-backname.patch


From: Akim Demaille
Subject: 36-fyi-backname.patch
Date: Wed, 24 Oct 2001 16:31:53 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        * lib/Autom4te/General.pm (backname): New.
        
Index: lib/Autom4te/General.pm
--- lib/Autom4te/General.pm Sun, 14 Oct 2001 15:25:15 +0200 akim
+++ lib/Autom4te/General.pm Sun, 21 Oct 2001 15:37:20 +0200 akim
@@ -29,7 +29,8 @@
 use vars qw (@ISA @EXPORT);
 
 @ISA = qw (Exporter);
address@hidden = qw (&debug &find_configure_ac &find_file &getopt &mktmpdir 
&mtime
address@hidden = qw (&backname &debug &find_configure_ac &find_file
+              &getopt &mktmpdir &mtime
               &uniq &update_file &up_to_date_p &verbose &xsystem
              $debug $force $help $me $tmp $verbose $version);
 
@@ -66,6 +67,12 @@
 
 sub verbose (@);
 
+
+## ----- ##
+## END.  ##
+## ----- ##
+
+
 # END
 # ---
 # Exit nonzero whenever closing STDOUT fails.
@@ -99,8 +106,45 @@ sub END
 }
 
 
-# debug(@MESSAGE)
-# ---------------
+## ----------- ##
+## Functions.  ##
+## ----------- ##
+
+
+# $BACKPATH
+# &backname ($REL-DIR)
+# --------------------
+# If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
+# For instance `src/foo' => `../..'.
+# Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
+sub backname ($)
+{
+  use File::Spec;
+
+  my ($file) = @_;
+  my $underscore = $_;
+  my @res;
+
+  foreach (split (/\//, $file))
+    {
+      next if $_ eq '.' || $_ eq '';
+      if ($_ eq '..')
+       {
+         pop @res;
+       }
+      else
+       {
+         push (@res, '..');
+       }
+    }
+
+  $_ = $underscore;
+  return File::Spec->canonpath (File::Spec->catfile (@res))
+}
+
+
+# &debug(@MESSAGE)
+# ----------------
 # Messages displayed only if $DEBUG and $VERBOSE.
 sub debug (@)
 {



reply via email to

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