parseSimplePart() returned bad return code in case of failure (RhBug:1123722)
[rpm.git] / scripts / find-requires.php
1 #!/bin/sh
2 #####################################################################
3 #                                                                   #
4 # Check system dependences between php-pear modules                 #
5 #                                                                   #
6 # Pawe¬≥ Go¬≥aszewski <blues@ds.pg.gda.pl>                            #
7 # ------------------------------------------------------------------#
8 # TODO:                                                             #
9 # - extension_loaded - dependencies.                                #
10 # - some clean-up...                                                #
11 #####################################################################
12 if [ $# -lt 1 ]; then
13         echo "You have to specify input file"
14         exit 1
15 fi
16
17 for files in `echo $@`; do
18         files=`echo $files | grep "\.php$"`
19         if [ -n "$files" ]; then
20                 # Requires trough  new call:
21                 j=`cat $files | grep -i new | grep -E "(=|return)" | grep -E -v "^[[:space:]*]*(\/\/|#|\*|/\*)" | tr -d "\r" | grep -E "[;|(|)|{|}|,][[:space:]*]*$" | awk -F "new " '{ print $2 }' | sed "s/[(|;|.]/ /g" | cut -f 1 -d " " | sed "s/^$.*//"`
22                 if [ -n "$j" ]; then
23                         for feature in $j; do
24                                 echo "pear($feature)"
25                         done
26                         j=""
27                 fi
28                 # requires trough class extension
29                 k=`cat $files | grep -E -i "(^Class.*extends)" | awk -F " extends " '{ print $2 }' | sed "s/{.*/ /" | cut -f 1 -d " " | tr -d "\r"`
30                 if [ -n "$k" ]; then
31                         for feature in $k; do
32                                 echo "pear($feature)"
33                         done
34                         k=""
35                 fi
36                 # requires trough class:: call
37                 l=`cat $files | grep "::" | grep -E -v "^[[:space:]*]*(\/\/|#|\*|/\*)" | sed "s/[(|'|!|\"|&|@|;]/ /g" | awk -F "::" '{ print $1 }' | sed "s/.*\ \([:alphanum:]*\)/\1/" | sed "s/^$.*//" | sed "s/[.]//g" | tr -d "\r"`
38                 if [ -n "$l" ]; then
39                         for feature in $l; do
40                                 echo "pear($feature)"
41                         done
42                         l=""
43                 fi
44         fi
45 done
46