]> git.pld-linux.org Git - packages/rpm.git/blobdiff - rpm-php-requires.php
- print out rpm requires/provides from eclipse feature.xml
[packages/rpm.git] / rpm-php-requires.php
index 7b3c536c564af5fc45787d43a7e71870acd3499b..619ebecc33826cee5387d52d0319234a3c1517d0 100644 (file)
@@ -38,25 +38,25 @@ function peardeps($files) {
                }
 
                foreach (file($f) as $line) {
-                       // skip comments
+                       // skip comments -- not perfect, matches "*" at start of line (very rare altho)
                        if (preg_match('/^\s*(#|\/\/|\*|\/\*)/', $line)) {
                                continue;
                        }
 
-                       while (preg_match("/(\W|^)(require|include)(_once)?
+                       if (preg_match("/(\W|^)(require|include)(_once)?
                                        \s* \(? \s*
                                        (\"([^\"]*)\"|'([^']*)')
                                        \s* \)? \s* ;/x", $line, $m)) {
 
-                               if ($m[5] != "") {
+                               if ($m[5]) {
                                        $x = $m[5];
-                               } else if ($m[6] != "") {
+                               } else if ($m[6]) {
                                        $x = $m[6];
                                } else {
                                        continue 2;
                                }
 
-                               if (substr($x, 0, 2) == './' || substr($x, -1) == '$') {
+                               if (substr($x, 0, 2) == './' || substr($x, -1) == '$') {  # XXX must be: CONTAINS DOLLAR
                                        continue 2;
                                }
 
@@ -71,20 +71,20 @@ function peardeps($files) {
                                continue;
                        }
 
-                       while (preg_match("/(\W|^)(require|include)(_once)?
+                       if (preg_match("/(\W|^)(require|include)(_once)?
                                        \s* \(? \s* dirname \s* \( \s* __FILE__ \s* \) \s* \. \s*
                                        (\"([^\"]*)\"|'([^']*)')
                                        \s* \)? \s* ;/x", $line, $m)) {
 
-                               if ($m[5] != "") {
+                               if ($m[5]) {
                                        $x = $m[5];
-                               } else if ($m[6] != "") {
+                               } else if ($m[6]) {
                                        $x = $m[6];
                                } else {
                                        continue 2;
                                }
 
-                               if (substr($x, -1) == '$') {
+                               if (substr($x, -1) == '$') { # XXX must be: CONTAINS DOLLAR
                                        continue 2;
                                }
                                if (substr($x, -4) != '.php') {
@@ -92,6 +92,9 @@ function peardeps($files) {
                                }
 
                                $x = "$file_dir/$x";
+                               // remove double slashes
+                               // TODO: resolve simpletest/test/../socket.php -> simpletest/socket.php
+                               $x = str_replace("//", "/", $x);
                                $req[$x] = 1;
                                continue;
                        }
@@ -137,15 +140,16 @@ function extdeps($files) {
                if ($ext == 'bz2') {
                        $ext = 'bzip2';
                }
-               // SPL ext is in php-spl package
-               if ($ext == 'SPL') {
-                       $ext = 'spl';
+               // libxml ext is in php-xml package
+               if ($ext == 'libxml') {
+                       $ext = 'xml';
                }
-               // ereg
-               if ($ext == 'ereg') {
-                       // not yet
-                       continue;
+
+               // these need to be lowercased
+               if (in_array($ext, array('SPL', 'PDO', 'SQLite', 'Reflection', 'SimpleXML'))) {
+                       $ext = strtolower($ext);
                }
+
                printf("$fmt\n", $ext);
        }
 }
This page took 0.036828 seconds and 4 git commands to generate.