sniper          Tue Oct 15 15:37:16 2002 EDT

  Modified files:              
    /php4       acinclude.m4 
  Log:
  - Added PHP_PROG_SED which checks whether the sed in system works with
    very long strings.
  
  #
  # Sascha, is this okay? I added this here since any libtool/autoconf
  # release out there doesn't have this yet..we can remove this when
  # we can really start requiring such versions which have it?
  #
  # This sets $SED to the correct binary, so that should be used in 
  # places were the lines might be very long.
  #
  
  
Index: php4/acinclude.m4
diff -u php4/acinclude.m4:1.210 php4/acinclude.m4:1.211
--- php4/acinclude.m4:1.210     Wed Oct  2 08:52:53 2002
+++ php4/acinclude.m4   Tue Oct 15 15:37:16 2002
@@ -1,4 +1,4 @@
-dnl $Id: acinclude.m4,v 1.210 2002/10/02 12:52:53 helly Exp $
+dnl $Id: acinclude.m4,v 1.211 2002/10/15 19:37:16 sniper Exp $
 dnl
 dnl This file contains local autoconf functions.
 
@@ -1729,4 +1729,88 @@
   IFS=$ac_IFS
 
   APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
+])
+
+dnl PHP_PROG_SED
+dnl ------------
+dnl Check for a fully-functional sed program, that truncates
+dnl as few characters as possible.  Prefer GNU sed if found.
+dnl
+dnl Based on LT_AC_PROG_SED (libtool CVS)
+dnl 
+AC_DEFUN([PHP_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(ac_cv_path_sed,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH; do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in sed gsed; do
+    if test -x "$as_dir/$ac_prog"; then
+      _sed_list="$_sed_list $as_dir/$ac_prog"
+    fi
+  done
+done
+
+  # Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+: ${TMPDIR=/tmp}
+{
+  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/sedXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=$TMPDIR/sed$$-$RANDOM
+  (umask 077 && mkdir $tmp)
+} ||
+{
+   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
+   { (exit 1); exit 1; }
+}
+  _max=0
+  _count=0
+  # Add /usr/xpg4/bin/sed as it is typically found on Solaris
+  # along with /bin/sed that truncates output.
+  for _sed in $_sed_list /usr/xpg4/bin/sed; do
+    test ! -f ${_sed} && break
+    cat /dev/null > "$tmp/sed.in"
+    _count=0
+    echo -n "0123456789" >"$tmp/sed.in"
+    # Check for GNU sed and select it if it is found.
+    if "${_sed}" --version 2>&1 < /dev/null | egrep '(GNU)' > /dev/null; then
+      ac_cv_path_sed=${_sed}
+      break;
+    fi
+    while true; do
+      cat "$tmp/sed.in" "$tmp/sed.in" >"$tmp/sed.tmp"
+      mv "$tmp/sed.tmp" "$tmp/sed.in"
+      cp "$tmp/sed.in" "$tmp/sed.nl"
+      echo >>"$tmp/sed.nl"
+      ${_sed} -e 's/a$//' < "$tmp/sed.nl" >"$tmp/sed.out" || break
+      cmp -s "$tmp/sed.out" "$tmp/sed.nl" || break
+      # 10000 chars as input seems more than enough
+      test $_count -gt 10 && break
+      _count=`expr $_count + 1`
+      if test $_count -gt $_max; then
+        _max=$_count
+        ac_cv_path_sed=$_sed
+      fi
+    done
+  done
+  rm -rf "$tmp"
+])
+if test -z "$SED"; then
+  AC_MSG_ERROR([Could not find working sed on this system. Please install GNU sed.])
+else
+  SED=$ac_cv_path_sed
+  AC_MSG_RESULT([$SED])
+fi
 ])



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to