From 97e4dc3a417be85a69688f2e56616c0985db9c70 Mon Sep 17 00:00:00 2001 From: foobar Date: Tue, 15 Oct 2002 19:37:16 +0000 Subject: [PATCH] - 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. # --- acinclude.m4 | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index 01810775be..2f52a4085c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1730,3 +1730,87 @@ 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 +]) -- 2.40.0