]> git.pld-linux.org Git - packages/rpm.git/commitdiff
- handle include(dirname(__FILE__) . "foo/bar.php")
authorMichal Moskal <michal@moskal.me>
Fri, 18 Oct 2002 23:01:07 +0000 (23:01 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    rpm-php-requires -> 1.13

rpm-php-requires

index 5a0fd12a60852ed60efdaa6124300281b8b655db..c92786c8485db53923308d7694c1173f52a21ef2 100644 (file)
@@ -13,6 +13,8 @@
 
 die "You have to specify input files" if (@ARGV < 1);
 
+$pear = "/usr/share/pear";
+
 @files = ();
 %req = ();
 
@@ -23,6 +25,14 @@ while (@ARGV > 0) {
        next unless ($f =~ /\.php$/);
        open(F, "< $f") or die;
 
+       if ($f =~ /$pear/) {
+               $file_dir = $f;
+               $file_dir =~ s|.*$pear/||;
+               $file_dir =~ s|/[^/]*$||;
+       } else {
+               $file_dir = undef;
+       }
+
        while (<F>) {
                # skip comments
                next if (/^\s*(#|\/\/|\*|\/\*)/);
@@ -41,6 +51,27 @@ while (@ARGV > 0) {
                        next if ($x =~ m|^\./| or $x =~ /\$/);
                        $req{$x} = 1;
                }
+
+               next unless (defined $file_dir);
+
+               while (/(\W|^)(require|include)(_once)?
+                         \s* \(? \s* dirname \s* \( \s* __FILE__ \s* \) \s* \. \s*
+                         ("([^"]*)"|'([^']*)') 
+                         \s* \)? \s* ;/xg) {
+                       if ($5 ne "") {
+                               $x = $5;
+                       } elsif ($6 ne "") {
+                               $x = $6;
+                       } else {
+                               next;
+                       }
+
+                       next if ($x =~ /\$/);
+
+                       $x = "$file_dir/$x";
+                       $x =~ s|/+|/|g;
+                       $req{$x} = 1;
+               }
        }
 }
 
This page took 0.049499 seconds and 4 git commands to generate.