$OpenBSD: patch-stepmake_aclocal_m4,v 1.2 2007/06/06 20:36:23 kili Exp $

# Make the version check more robust against multiple line output
# for $whatever --version, and use awk(1) instead of sh(1) for
# comparing version numbers (it fails for fontforge, since our sh(1)
# doesn't yet have 64-bit arithmetic).

--- stepmake/aclocal.m4.orig	Tue May  1 17:28:45 2007
+++ stepmake/aclocal.m4	Sun May  6 17:57:23 2007
@@ -32,9 +32,14 @@ AC_DEFUN(STEPMAKE_GET_VERSION, [
     ## for compatibility reasons.
     
     ## grab the first version number in  --version output.
-    eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 | grep '\(^\| \)[0-9][0-9]*\.[0-9]' \
-        | head -n 1 \
-	| tr ' ' '\n' | sed 's/\([0-9][0-9]*\.[0-9][0-9.]*\).*/\1/g' | grep '\(^\| \)[0-9][0-9]*\.[0-9]' | head -n 1\`\"
+    eval '_ver=\`'"$1"' --version 2>&1\` || _ver=\`'"$1"' -V 2>&1\` &&
+	 _ver=\`echo $_ver |
+	 	grep '\''[0-9]\.[0-9]'\'' |
+        	head -n 1 |
+		tr '\'' '\'' '\''\n'\'' |
+		grep '\''[0-9]\.[0-9]'\'' |
+		head -n 1 |
+		sed '\''s/\([0-9.]*\).*/\1/g'\''\`'
 
     if test -z "$_ver"; then
         ## If empty, try date [fontforge]
@@ -49,12 +54,9 @@ AC_DEFUN(STEPMAKE_GET_VERSION, [
 # Calculate simplistic numeric version from version string ($1)
 # As yet, we have no need for something more elaborate.
 AC_DEFUN(STEPMAKE_NUMERIC_VERSION, [
-    echo "$1" | awk -F. '
-    {
-      if ([$]3) {three = [$]3}
-      else {three = 0}
-    }
-    {printf "%.0f\n", [$]1*1000000 + [$]2*1000 + three}'
+	echo "$1" | awk -F. '
+	  NF==1 {print; next}
+	  {printf "%.0f\n", [$]1*1000000 + [$]2*1000 + [$]3}'
 ])
 
 
