This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Don't do redundant test
[perl5.git] / x2p / find2perl.PL
index b99bb49..d68c036 100644 (file)
@@ -42,20 +42,6 @@ use vars qw/$statdone/;
 use File::Spec::Functions 'curdir';
 my $startperl = "#! $perlpath -w";
 
-#
-# Modified September 26, 1993 to provide proper handling of years after 1999
-#   Tom Link <tml+@pitt.edu>
-#   University of Pittsburgh
-#
-# Modified April 7, 1998 with nasty hacks to implement the troublesome -follow
-#  Billy Constantine <wdconsta@cs.adelaide.edu.au> <billy@smug.adelaide.edu.au>
-#  University of Adelaide, Adelaide, South Australia
-#
-# Modified 1999-06-10, 1999-07-07 to migrate to cleaner perl5 usage
-#   Ken Pizzini <ken@halcyon.com>
-#
-# Modified 2000-01-28 to use the 'follow' option of File::Find
-
 sub tab ();
 sub n ($$);
 sub fileglob_to_re ($);
@@ -99,8 +85,10 @@ while (@ARGV) {
     } elsif ($_ eq '!') {
         $out .= tab . "!";
         next;
-    } elsif ($_ eq 'name') {
-        $out .= tab . '/' . fileglob_to_re(shift) . "/s";
+    } elsif (/^(i)?name$/) {
+        $out .= tab . '/' . fileglob_to_re(shift) . "/s$1";
+    } elsif (/^(i)?path$/) {
+        $out .= tab . '$File::Find::name =~ /' . fileglob_to_re(shift) . "/s$1";
     } elsif ($_ eq 'perm') {
         my $onum = shift;
         $onum =~ /^-?[0-7]+$/
@@ -266,7 +254,9 @@ while (@ARGV) {
 }
 
 if ($print_needed) {
-    $out .= "\n" . tab . '&& print("$name\n")';
+    my $t = tab;
+    if ($t !~ /&&\s*$/) { $t .= '&& ' }
+    $out .= "\n" . $t . 'print("$name\n")';
 }
 
 
@@ -691,7 +681,8 @@ sub tab () {
 sub fileglob_to_re ($) {
     my $x = shift;
     $x =~ s#([./^\$()+])#\\$1#g;
-    $x =~ s#([?*])#.$1#g;
+    $x =~ s#\*#.*#g;
+    $x =~ s#\?#.#g;
     "^$x\\z";
 }
 
@@ -781,6 +772,18 @@ File name matches specified GLOB wildcard pattern.  GLOB may need to be
 quoted to avoid interpretation by the shell (just as with using
 C<find(1)>).
 
+=item C<-iname GLOB>
+
+Like C<-name>, but the match is case insensitive.
+
+=item C<-path GLOB>
+
+Path name matches specified GLOB wildcard pattern.
+
+=item C<-ipath GLOB>
+
+Like C<-path>, but the match is case insensitive.
+
 =item C<-perm PERM>
 
 Low-order 9 bits of permission match octal value PERM.
@@ -826,7 +829,7 @@ True if (hard) link count of file matches N (see below).
 
 True if file's size matches N (see below) N is normally counted in
 512-byte blocks, but a suffix of "c" specifies that size should be
-counted in characters (bytes) and a suffix of "k" specifes that
+counted in characters (bytes) and a suffix of "k" specifies that
 size should be counted in 1024-byte blocks.
 
 =item C<-atime N>
@@ -905,7 +908,7 @@ Predicates which take a numeric argument N can come in three forms:
 
 =head1 SEE ALSO
 
-find
+find, File::Find.
 
 =cut
 !NO!SUBS!