2005-03-15  Stepan Kasal  <kasal@ucw.cz>

	* macros2/gnome-autogen.sh (compare_versions): Cosmetic changes of
	  the IFS manipulations; use expr instead of sed to save a process.
	(version_check): Save one `head" process.
	(sed_ac_config_macro_dir): New variable, contains a sed script which
	  can replace a pipe of five processes.

Index: macros2/gnome-autogen.sh
===================================================================
RCS file: /cvs/gnome/gnome-common/macros2/gnome-autogen.sh,v
retrieving revision 1.14
diff -u -r1.14 gnome-autogen.sh
--- macros2/gnome-autogen.sh	11 Feb 2005 08:59:41 -0000	1.14
+++ macros2/gnome-autogen.sh	15 Mar 2005 11:34:47 -0000
@@ -47,16 +47,16 @@
     ch_min_version=$1
     ch_actual_version=$2
     ch_status=0
-    IFS="${IFS=         }"; ch_save_IFS="$IFS"; IFS="."
+    ch_save_IFS="${IFS=         }"; IFS="."
     set $ch_actual_version
     for ch_min in $ch_min_version; do
-        ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
+        IFS="$ch_save_IFS"
+        ch_cur=`expr "$1" : '\([0-9]*\)'`; shift # remove letter suffixes
         if [ -z "$ch_min" ]; then break; fi
         if [ -z "$ch_cur" ]; then ch_status=1; break; fi
         if [ $ch_cur -gt $ch_min ]; then break; fi
         if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
     done
-    IFS="$ch_save_IFS"
     return $ch_status
 }
 
@@ -86,8 +86,8 @@
     for vc_checkprog in $vc_checkprogs; do
 	echo $ECHO_N "  testing $vc_checkprog... "
 	if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
-	    vc_actual_version=`$vc_checkprog --version | head -n 1 | \
-                               sed 's/^.*[ 	]\([0-9.]*[a-z]*\).*$/\1/'`
+	    vc_actual_version=`$vc_checkprog --version | \
+                               sed 's/^.*[ 	]\([0-9.]*[a-z]*\).*$/\1/;q'`
 	    if compare_versions $vc_min_version $vc_actual_version; then
 		echo "found $vc_actual_version"
 		# set variable
@@ -309,6 +309,10 @@
   printerr
 fi
 
+# Sed command to extract the argument of AC_CONFIG_MACRO_DIR:
+sed_ac_config_macro_dir='/AC_CONFIG_MACRO_DIR(/!d
+s/^AC_CONFIG_MACRO_DIR([[]*/-I /;s/]*).*//;q'
+
 topdir=`pwd`
 for configure_ac in $configure_files; do 
     dirname=`dirname $configure_ac`
@@ -361,14 +365,10 @@
 
         # Now run aclocal to pull in any additional macros needed
 
-	# if the AC_CONFIG_MACRO_DIR() macro is used, pass that
+	# If the AC_CONFIG_MACRO_DIR() macro is used, pass that
 	# directory to aclocal.
-	m4dir=`cat "$basename" | grep '^AC_CONFIG_MACRO_DIR' | sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
-	if [ -n "$m4dir" ]; then
-	    m4dir="-I $m4dir"
-	fi
 	printbold "Running $ACLOCAL..."
-	$ACLOCAL $m4dir $ACLOCAL_FLAGS || exit 1
+	$ACLOCAL `sed "$sed_ac_config_macro_dir" "$basename"` $ACLOCAL_FLAGS || exit 1
 
 	if grep "GNOME_AUTOGEN_OBSOLETE" aclocal.m4 >/dev/null; then
 	    printerr "*** obsolete gnome macros were used in $configure_ac"
