[Top][All Lists]

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

_AC_FEATURE_CHECK_LENGTH bug (Was: Re: 4-gary-AC_PROG_GREP.patch)

From: Alexandre Duret-Lutz
Subject: _AC_FEATURE_CHECK_LENGTH bug (Was: Re: 4-gary-AC_PROG_GREP.patch)
Date: Tue, 20 Apr 2004 00:13:31 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

>>> "Gary" == Gary V Vaughan <address@hidden> writes:


 Gary> from  Gary V. Vaugan  <address@hidden>
 Gary> Albert Chin-A-Young <address@hidden>

 Gary> * lib/autoconf/programs.m4 (AC_PROG_GREP): New macro to test for a
 Gary> grep or ggrep program in PATH that accepts as long lines as
 Gary> possible.
 Gary> * lib/autoconf/programs.m4 (_AC_PROG_GREP): Factor out the core of
 Gary> (AC_PROG_EGREP, AC_PROG_FGREP): Use it to find best available
 Gary> egrep and fgrep respectively if $GREP -E/-F don't work.
 Gary> (_AC_PATH_PROG_FEATURE_CHECK): Factor out the common core of
 Gary> (_AC_FEATURE_CHECK_LENGTH): New helper macro for finding the
 Gary> longest input length accepted by a command.
 Gary> (AC_PROG_SED): Use it.
 Gary> * doc/autoconf.texi (Particular Programs): Document the changes.
 Gary> * NEWS: Updated.

I have a problem apparently caused by this patch.

Will configuring CVS Automake on Solaris8:

checking build system type... sparc-sun-solaris2.8
checking for a BSD-compatible install... /home/adl/usr/sun4/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking for perl... /home/adl/usr/sun4/bin/perl
checking for tex... no
checking whether autoconf is installed... yes
checking whether autoconf works... yes
checking whether autoconf is recent enough... yes
checking whether ln works... yes
checking for grep that handles long lines... 
checking for egrep... configure: error: no acceptable egrep could be found in 

The empty result for `checking for grep that handles long lines'
is the typo Maciej just reported.  

The egrep failure is a more subtle issue.  

The _AC_FEATURE_CHECK_LENGTH macro (quoted below) uses the
`$ac_max' variable to record the last size that worked so far.
Apparently `$ac_max' is not initialized because
_AC_FEATURE_CHECK_LENGTH is meant to be called several times
while checking for a tool.

However the problem is that _AC_FEATURE_CHECK_LENGTH is used
while checking different tools like grep, egrep, fgrep, sed, and
I'm not sure it makes sense to share the same `$ac_max' between
all these checks.

Tracing the above configure reveals that `ac_max' is first set
to 11 while checking for grep.  Then the egrep checking code
never manage to do better (because there is only ten iterations),
so it never sets ac_cv_path_EGREP and fails.

The whole thing works when GNU tools are used because the ac_max
computation is skipped.

I'm not familiar enough with all this to know the appropriate
fix.  Maybe $2 could be changed to be the suffix of the cache
variable, and then use ac_cv_$2 when talking about the
cache variable, and ac_max_$2 instead of the ac_max variable?

 Gary> +# 
 Gary> +# For use as the FEATURE-TEST argument to _AC_PATH_PROG_FEATURE_TEST.
 Gary> +# On each iteration run CHECK-CMD on an input file, storing the value
 Gary> +# of PROGPATH in CACHE-VAR if the CHECK-CMD succeeds.  The input file
 Gary> +# is always one line, starting with only 10 characters, and doubling
 Gary> +# in length at each iteration until approx 10000 characters or the
 Gary> +# feature check succeeds.  The feature check is called at each
 Gary> +# iteration by appending (optionally, MATCH-STRING and) a newline
 Gary> +# to the file, and using the result as input to CHECK-CMD.
 Gary> +m4_define([_AC_FEATURE_CHECK_LENGTH],
 Gary> +[if AS_EXECUTABLE_P(["$$1"]); then
 Gary> +  # Check for GNU $1 and select it if it is found.
 Gary> +  _AC_PATH_PROG_FLAVOR_GNU([$$1],
 Gary> +    [$2="$$1"
 Gary> +    break 2
 Gary> +  ])
 Gary> +
 Gary> +  ac_count=0
 Gary> +  echo $ECHO_N "0123456789$ECHO_C" >"$tmp/"
 Gary> +  while :
 Gary> +  do
 Gary> +    cat "$tmp/" "$tmp/" >"$tmp/conftest.tmp"
 Gary> +    mv "$tmp/conftest.tmp" "$tmp/"
 Gary> +    cp "$tmp/" "$tmp/"
 Gary> +    echo '$4' >> "$tmp/"
 Gary> +    $3 < "$tmp/" >"$tmp/conftest.out" || break
 Gary> +   diff "$tmp/conftest.out" "$tmp/" >/dev/null 2>&1 || break
 Gary> +    ac_count=`expr $ac_count + 1`
 Gary> +    if test $ac_count -gt ${ac_max-0}; then
 Gary> +      # Best one so far, save it but keep looking for a better one
 Gary> +      $2="$$1"
 Gary> +      ac_max=$ac_count
 Gary> +    fi
 Gary> +    # 10*(2^10) chars as input seems more than enough
 Gary> +    test $ac_count -gt 10 && break
 Gary> +  done
 Gary> +fi
 Gary> +])
Alexandre Duret-Lutz

reply via email to

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