[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_PROG_SED
From: |
Akim Demaille |
Subject: |
Re: AC_PROG_SED |
Date: |
28 Feb 2002 11:02:36 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp) |
| 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
We also need a documentation, a NEWS entry, and a lib/autoscan/program
entry.
| ? 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)
This is not the way Autoconf works: I don't understand why you want a
tmp dir. I recommend using conftest.in and conftest.out or whatever.
| + _max=0
| + _count=0
Please, don't. The private space for Autoconf shell variables is
ac_*. The test suite should have failed for your macro. I don't know
why it didn't (did you run it? cd tests/; ./testsuite -k sed).
| + # 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
Idem.
| + test ! -f ${_sed} && break
We don't ${} in Autoconf. In addition, your use of "" is inconsistent
for $ac_sed (see the `if' below).
| + 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;
Why 2>&1, why egrep, why RE-parens?
| +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])
| +])
Incidentally, your patch led me to think about something about the
structure of M4sh vs Autoconf: here, the core of the test (no MSG, no
CACHE, no SUBST), should probably find its place into M4sh. And many
more macros should probably be redesigned this way.
But don't consider this as a suggestion. Just a thought.
- Re: AC_PROG_SED,
Akim Demaille <=