From f74f53b7c8429f687acf34c7ed554fb2d76cb524 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 23 Jan 2004 08:21:51 +0000 Subject: [PATCH] * lib/autoconf/programs.m4 (AC_PROG_SED): New macro to test for a non-truncating sed or gsed program in PATH. * tests/acprograms.at: Add it. * doc/autoconf.texi (Particular Programs): Document it. * NEWS: Updated. --- ChangeLog | 8 +++++++ NEWS | 4 ++++ doc/autoconf.texi | 8 +++++++ lib/autoconf/programs.m4 | 59 +++++++++++++++++++++++++++++++++++++++++++++++- tests/acprograms.at | 3 ++- 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5cfbff3..4b025c06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-01-23 Gary V. Vaugan + + * lib/autoconf/programs.m4 (AC_PROG_SED): New macro to test for a + non-truncating sed or gsed program in PATH. + * tests/acprograms.at: Add it. + * doc/autoconf.texi (Particular Programs): Document it. + * NEWS: Updated. + 2004-01-15 Paul Eggert * lib/autoconf/c.m4 (_AC_PROG_CC_STDC): Try -std, not -std1, since diff --git a/NEWS b/NEWS index a9df1eb4..8a5d61f9 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ * Major changes in Autoconf 2.59a +** AC_PROG_SED + New macro that tests for a sed program that truncates as few characters + as possible. + * Major changes in Autoconf 2.59 Released 2003-11-04, by Akim Demaille diff --git a/doc/autoconf.texi b/doc/autoconf.texi index dc4b23a9..b567a576 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -3366,6 +3366,14 @@ Set output variable @code{RANLIB} to @samp{ranlib} if @code{ranlib} is found, and otherwise to @samp{:} (do nothing). @end defmac +@defmac AC_PROG_SED +@acindex {PROG_SED} +@ovindex SED +Set output variable @code{SED} to a @code{sed} on @samp{PATH} that +truncates as few characters as possible. If @sc{GNU} Sed is found, +use that instead. +@end defmac + @defmac AC_PROG_YACC @acindex{PROG_YACC} @ovindex YACC diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4 index 121fdb28..6b82890d 100644 --- a/lib/autoconf/programs.m4 +++ b/lib/autoconf/programs.m4 @@ -1,6 +1,6 @@ # This file is part of Autoconf. -*- Autoconf -*- # Checking for programs. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2004 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -501,6 +501,63 @@ AU_DEFUN([AC_RSH], 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, +[AS_TMPDIR([sed]) +ac_max=0 +# Loop through the user's path and test for sed and gsed. +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with a /bin/sed that truncates output. +_AS_PATH_WALK([$PATH:/usr/xpg4/bin], +[ac_fini=false +for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_sed="$as_dir/$ac_prog$ac_exec_ext" + if test -f "$ac_sed" && AS_EXECUTABLE_P(["$ac_sed"]); then + # Check for GNU sed and select it if it is found. + if "$ac_sed" --version 2>&1 < /dev/null | grep 'GNU' >/dev/null; then + ac_cv_path_sed="$ac_sed" + ac_fini=: + break + fi + + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo '' >> conftest.nl + "$ac_sed" -e 's/a$//' < conftest.nl >conftest.out || break + cmp conftest.out conftest.nl >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt $ac_max; then + ac_max=$ac_count + ac_cv_path_sed="$ac_sed" + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + fi + done + $ac_fini && break +done]) +rm -rf "$tmp" +]) +fi +SED="$ac_cv_path_sed" +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +]) + + # AC_PROG_YACC # ------------ AN_MAKEVAR([BISON], [AC_PROG_YACC]) diff --git a/tests/acprograms.at b/tests/acprograms.at index d21a4759..9ca5480e 100644 --- a/tests/acprograms.at +++ b/tests/acprograms.at @@ -4,7 +4,7 @@ ## Do not edit by hand. ## ## --------------------- ## -# Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. +# Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc. AT_BANNER([Testing autoconf/programs macros.]) @@ -16,6 +16,7 @@ AT_CHECK_MACRO([AC_PROG_LEX]) 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. -- 2.11.4.GIT