autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_PROG_SED


From: Robert Boehne
Subject: Re: AC_PROG_SED
Date: Wed, 09 Jan 2002 14:34:38 -0600

Hello,

Here is the latest incarnation of AC_PROG_SED, sanitized
for Autoconf.
    Now I'd like to add it's use to Libtool ASAP,
but there is the problem of AC_PROG_SED not being
available until this code is released, or requiring
a CVS version of autoconf (which I'd prefer to not do).
I was thinking that I would tack on LT_ to the macro name
(after expanding post-2.50 Autoconf macros in it), add it to Libtool,
and then when AC_PROG_SED is available in a released version
of Autoconf, remove my private copy.  Does that sound sane?

- Robert

ChangeLog entry:

2002-01-06  Robert Boehne  <address@hidden>
        Based on a post by Albert Chin <address@hidden>:

        * lib/autoconf/programs.m4 (AC_PROG_SED): Find a sed
        program that will not truncate its output.
        * tests/acprograms.at : Add AC_PROG_SED to tests.
? ac_prog_sed.patch
? tests/atlocal
? tests/atconfig
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvs/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.8
diff -u -r1.8 programs.m4
--- lib/autoconf/programs.m4    12 Nov 2001 16:08:53 -0000      1.8
+++ lib/autoconf/programs.m4    9 Jan 2002 20:13:16 -0000
@@ -459,6 +459,65 @@
 Remove this warning when you adjust the code.])])
 
 
+# AC_PROG_SED
+# --------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+AC_DEFUN([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+if test -z "$SED"; then
+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_PATH_WALK([$PATH],
+  [for ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if AS_EXECUTABLE_P(["$as_dir/$ac_prog$ac_exec_ext"]); then
+        _sed_list="$_sed_list $as_dir/$ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+  ])
+  AS_TMPDIR(sed)
+  _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 $ECHO_N "0123456789$ECHO_C" >"$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"
+])
+fi
+AC_SUBST([SED], $ac_cv_path_sed)
+AC_MSG_RESULT([$SED])
+])
+
+
 # AC_PROG_YACC
 # ------------
 AC_DEFUN([AC_PROG_YACC],
Index: tests/acprograms.at
===================================================================
RCS file: /cvs/autoconf/tests/acprograms.at,v
retrieving revision 1.1
diff -u -r1.1 acprograms.at
--- tests/acprograms.at 22 Aug 2001 06:44:57 -0000      1.1
+++ tests/acprograms.at 9 Jan 2002 20:13:17 -0000
@@ -10,6 +10,7 @@
 AT_CHECK_MACRO([AC_PROG_LN_S])
 AT_CHECK_MACRO([AC_PROG_MAKE_SET])
 AT_CHECK_MACRO([AC_PROG_RANLIB])
+AT_CHECK_MACRO([AC_PROG_SED])
 AT_CHECK_MACRO([AC_PROG_YACC])
 
 # Obsolete macros.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]