summaryrefslogtreecommitdiff
path: root/x2p
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1991-06-06 23:28:02 +0000
committerLarry Wall <lwall@netlabs.com>1991-06-06 23:28:02 +0000
commit6e21c824d91ef0b4ae60b95b347e344e5bb4d38a (patch)
treecc298b664815eb149de874f4694ea9d4b3f08308 /x2p
parent2b317908ea5309ab202d1cdbadccfdf42d10e2b1 (diff)
downloadperl-6e21c824d91ef0b4ae60b95b347e344e5bb4d38a.tar.gz
perl 4.0 patch 6: patch #4, continued
See patch #4.
Diffstat (limited to 'x2p')
-rw-r--r--x2p/find2perl.SH134
-rw-r--r--x2p/handy.h11
2 files changed, 31 insertions, 114 deletions
diff --git a/x2p/find2perl.SH b/x2p/find2perl.SH
index f850247391..9161f7ba98 100644
--- a/x2p/find2perl.SH
+++ b/x2p/find2perl.SH
@@ -128,11 +128,25 @@ while (@ARGV) {
elsif ($_ eq 'exec') {
for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { }
shift;
- for (@cmd) { s/'/\\'/g; }
- $" = "','";
- $out .= &tab . "&exec(0, '@cmd')";
- $" = ' ';
- $initexec++;
+ $_ = "@cmd";
+ if (m#^(/bin/)?rm -f {}$#) {
+ if (!@ARGV) {
+ $out .= &tab . 'unlink($_)';
+ }
+ else {
+ $out .= &tab . '(unlink($_) || 1)';
+ }
+ }
+ elsif (m#^(/bin/)?rm {}$#) {
+ $out .= &tab . '(unlink($_) || warn "$name: $!\n")';
+ }
+ else {
+ for (@cmd) { s/'/\\'/g; }
+ $" = "','";
+ $out .= &tab . "&exec(0, '@cmd')";
+ $" = ' ';
+ $initexec++;
+ }
}
elsif ($_ eq 'ok') {
for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { }
@@ -202,9 +216,9 @@ while (@ARGV) {
}
if (@ARGV) {
if ($ARGV[0] eq '-o') {
+ { local($statdone) = 1; $out .= "\n" . &tab . "||\n"; }
$statdone = 0 if $indent == 1 && $delayedstat;
$saw_or++;
- $out .= "\n" . &tab . "||\n";
shift;
}
else {
@@ -246,10 +260,13 @@ print $initnewer, "\n" if $initnewer;
print $initfile, "\n" if $initfile;
+$find = $depth ? "finddepth" : "find";
print <<"END";
+require "$find.pl";
+
# Traverse desired filesystems
-&dodirs($roots);
+&$find($roots);
$flushall
exit;
@@ -259,109 +276,6 @@ $out;
END
-print <<'END';
-sub dodirs {
- chop($cwd = `pwd`);
- foreach $topdir (@_) {
- (($topdev,$topino,$topmode,$topnlink) = stat($topdir))
- || (warn("Can't stat $topdir: $!\n"), next);
- if (-d _) {
- if (chdir($topdir)) {
-END
-if ($depth) {
- print <<'END';
- $topdir = '' if $topdir eq '/';
- &dodir($topdir,$topnlink);
- ($dir,$_) = ($topdir,'.');
- $name = $topdir;
- &wanted;
-END
-}
-else {
- print <<'END';
- ($dir,$_) = ($topdir,'.');
- $name = $topdir;
- &wanted;
- $topdir = '' if $topdir eq '/';
- &dodir($topdir,$topnlink);
-END
-}
-print <<'END';
- }
- else {
- warn "Can't cd to $topdir: $!\n";
- }
- }
- else {
- unless (($dir,$_) = $topdir =~ m#^(.*/)(.*)$#) {
- ($dir,$_) = ('.', $topdir);
- }
- chdir $dir && &wanted;
- }
- chdir $cwd;
- }
-}
-
-sub dodir {
- local($dir,$nlink) = @_;
- local($dev,$ino,$mode,$subcount);
- local($name);
-
- # Get the list of files in the current directory.
-
- opendir(DIR,'.') || warn "Can't open $dir: $!\n";
- local(@filenames) = readdir(DIR);
- closedir(DIR);
-
- if ($nlink == 2) { # This dir has no subdirectories.
- for (@filenames) {
- next if $_ eq '.';
- next if $_ eq '..';
- $name = "$dir/$_";
- $nlink = 0;
- &wanted;
- }
- }
- else { # This dir has subdirectories.
- $subcount = $nlink - 2;
- for (@filenames) {
- next if $_ eq '.';
- next if $_ eq '..';
- $nlink = $prune = 0;
- $name = "$dir/$_";
-END
-print <<'END' unless $depth;
- &wanted;
-END
-print <<'END';
- if ($subcount > 0) { # Seen all the subdirs?
-
- # Get link count and check for directoriness.
-
- ($dev,$ino,$mode,$nlink) = lstat($_) unless $nlink;
-
- if (-d _) {
-
- # It really is a directory, so do it recursively.
-
- if (!$prune && chdir $_) {
- &dodir($name,$nlink);
- chdir '..';
- }
- --$subcount;
- }
- }
-END
-print <<'END' if $depth;
- &wanted;
-END
-print <<'END';
- }
- }
-}
-
-END
-
if ($initexec) {
print <<'END';
sub exec {
diff --git a/x2p/handy.h b/x2p/handy.h
index e50cbc3866..25a1bdac1e 100644
--- a/x2p/handy.h
+++ b/x2p/handy.h
@@ -1,11 +1,14 @@
-/* $RCSfile: handy.h,v $$Revision: 4.0.1.1 $$Date: 91/04/12 09:29:08 $
+/* $RCSfile: handy.h,v $$Revision: 4.0.1.2 $$Date: 91/06/07 12:15:43 $
*
- * Copyright (c) 1989, Larry Wall
+ * Copyright (c) 1991, Larry Wall
*
- * You may distribute under the terms of the GNU General Public License
- * as specified in the README file that comes with the perl 3.0 kit.
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Artistic License, as specified in the README file.
*
* $Log: handy.h,v $
+ * Revision 4.0.1.2 91/06/07 12:15:43 lwall
+ * patch4: new copyright notice
+ *
* Revision 4.0.1.1 91/04/12 09:29:08 lwall
* patch1: random cleanup in cpp namespace
*