This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
eval: handle taint of overloaded/tied arg
[perl5.git] / lib / getcwd.pl
index a3214ba..77b2442 100644 (file)
@@ -1,5 +1,17 @@
+warn "Legacy library @{[(caller(0))[6]]} will be removed from the Perl core distribution in the next major release. Please install it from the CPAN distribution Perl4::CoreLibs. It is being used at @{[(caller)[1]]}, line @{[(caller)[2]]}.\n";
+
 # By Brandon S. Allbery
 #
+# This library is no longer being maintained, and is included for backward
+# compatibility with Perl 4 programs which may require it.
+# This legacy library is deprecated and will be removed in a future
+# release of perl.
+# In particular, this should not be used as an example of modern Perl
+# programming techniques.
+#
+# Suggested alternative: Cwd
+
+#
 # Usage: $cwd = &getcwd;
 
 sub getcwd
@@ -28,7 +40,7 @@ sub getcwd
            closedir(getcwd'PARENT);                                    #');
            return '';
        }
-       if ($pst[$[] == $cst[$[] && $pst[$[ + 1] == $cst[$[ + 1])
+       if ($pst[0] == $cst[0] && $pst[1] == $cst[1])
        {
            $dir = '';
        }
@@ -36,7 +48,7 @@ sub getcwd
        {
            do
            {
-               unless ($dir = readdir(getcwd'PARENT))                  #'))
+               unless (defined ($dir = readdir(getcwd'PARENT)))        #'))
                {
                    warn "readdir($dotdots): $!";
                    closedir(getcwd'PARENT);                            #');
@@ -44,17 +56,17 @@ sub getcwd
                }
                unless (@tst = lstat("$dotdots/$dir"))
                {
-                   warn "lstat($dotdots/$dir): $!";
-                   closedir(getcwd'PARENT);                            #');
-                   return '';
+                   warn "lstat($dotdots/$dir): $!";
+                   # closedir(getcwd'PARENT);                          #');
+                   return '';
                }
            }
-           while ($dir eq '.' || $dir eq '..' || $tst[$[] != $pst[$[] ||
-                  $tst[$[ + 1] != $pst[$[ + 1]);
+           while ($dir eq '.' || $dir eq '..' || $tst[0] != $pst[0] ||
+                  $tst[1] != $pst[1]);
        }
        $cwd = "$dir/$cwd";
        closedir(getcwd'PARENT);                                        #');
-    } while ($dir);
+    } while ($dir ne '');
     chop($cwd);
     $cwd;
 }