]> granicus.if.org Git - php/commitdiff
this is faster than parsing the file line by line
authorSascha Schumann <sas@php.net>
Sat, 8 May 1999 21:44:12 +0000 (21:44 +0000)
committerSascha Schumann <sas@php.net>
Sat, 8 May 1999 21:44:12 +0000 (21:44 +0000)
genif.sh

index 571e2b9a885f310cf8213b61998007cd4ce5c7f0..c071743b069b6cfc02a5d108d637b58d7d7c6c29 100644 (file)
--- a/genif.sh
+++ b/genif.sh
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $Id: genif.sh,v 1.2 1999-05-08 18:16:29 andrey Exp $
+# $Id: genif.sh,v 1.3 1999-05-08 21:44:12 sas Exp $
 # replacement for genif.pl
 
 infile="$1"
@@ -13,24 +13,24 @@ if test "$infile" = "" -o "$srcdir" = ""; then
        exit 1
 fi
 
-cmd1='echo $data | grep @EXT_INCLUDE_CODE@ > /dev/null 2>&1'
-cmd2='echo $data | grep @EXT_MODULE_PTRS@ > /dev/null 2>&1'
-
-while read data; do
-       if eval $cmd1 ; then
-               for ext in $* ; do
-                       for pre in php3 php php4 zend; do
-                               hdrfile="ext/$ext/${pre}_${ext}.h"
-                               if test -f $hdrfile ; then
-                                       echo "#include \"$hdrfile\""
-                               fi
-                       done
-               done
-       elif eval $cmd2 ; then
-               for ext in $* ; do
-                       echo "  phpext_${ext}_ptr,"
-               done
-       else
-               echo "$data"
-       fi
-done < $infile
+module_ptrs=""
+includes=""
+
+# the 'ä' is used as a newline replacement
+# its later tr'd to '\n'
+
+for ext in $* ; do
+       module_ptrs="   phpext_${ext}_ptr,ä$module_ptrs"
+       for pre in php3 php php4 zend; do
+               hdrfile="ext/$ext/${pre}_${ext}.h"
+               if test -f $hdrfile ; then
+                       includes="#include \"$hdrfile\"ä$includes"
+               fi
+       done
+done
+
+cat $infile | \
+       sed "s'@EXT_INCLUDE_CODE@'$includes'" | \
+       sed "s'@EXT_MODULE_PTRS@'$module_ptrs'" | \
+       tr ä '\n'
+