Hello,

On Thu, Sep 01, 2005 at 03:58:16PM -0700, Paul Eggert wrote:
> > Can I commit it, as soon as the mentioned bug is fixed?
> 
> Yes, please.  Thanks.

Regarding the bug reported in
http://lists.gnu.org/archive/html/bug-autoconf/2005-08/msg00034.html,
I followed the advice from Noah, that the arguments to AC_LINK_IFELSE
shouldn't use `break'.

I also added the check for that bug.

Moreover, I converted the code to use AS_VAR_* macros, so that it
allows more general application.

The final patch, which I committed, is attached to this mail.

Have a nice day,
        Stepan Kasal
2005-09-06  Stepan Kasal  <[EMAIL PROTECTED]>

        * lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Merge the two AC_LINK_IFELSE
          calls, so that the final expansion of this macro is shorter.
          Create the conftest.$ac_ext outside the `for' loop, to speed the run.
          Do not use `break' in the argument to AC_LINK_IFELSE, it would skip
          the cleanup there.  Use AS_VAR_* macros, to be more general.
        * tests/semantics.at (AC_SEARCH_LIBS): Check for the cleanup.

Index: lib/autoconf/libs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/libs.m4,v
retrieving revision 1.12
diff -u -r1.12 libs.m4
--- lib/autoconf/libs.m4        26 Aug 2005 19:42:25 -0000      1.12
+++ lib/autoconf/libs.m4        6 Sep 2005 15:19:52 -0000
@@ -67,24 +67,29 @@
 # --------------------------------------------------------
 # Search for a library defining FUNC, if it's not already available.
 AC_DEFUN([AC_SEARCH_LIBS],
-[AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
+[AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$1])dnl
+AC_CACHE_CHECK([for library containing $1], ac_Search,
 [ac_func_search_save_LIBS=$LIBS
-ac_cv_search_$1=no
-AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
-              [ac_cv_search_$1="none required"])
-if test "$ac_cv_search_$1" = no; then
-  for ac_lib in $2; do
+AC_LANG_CONFTEST([AC_LANG_CALL([], [$1])])
+for ac_lib in '' $2; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
     LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
-    AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
-                  [ac_cv_search_$1="-l$ac_lib"
-break])
-  done
-fi
+  fi
+  AC_LINK_IFELSE([], [AS_VAR_SET(ac_Search, [$ac_res])])
+  AS_VAR_SET_IF(ac_Search, [break])dnl
+done
+AS_VAR_SET_IF(ac_Search, , [AS_VAR_SET(ac_Search, [no])])dnl
+rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS])
-AS_IF([test "$ac_cv_search_$1" != no],
-  [test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
+ac_res=AS_VAR_GET(ac_Search)
+AS_IF([test "$ac_res" != no],
+  [test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
   $3],
       [$4])dnl
+AS_VAR_POPDEF([ac_Search])dnl
 ])
 
 
Index: tests/semantics.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/semantics.at,v
retrieving revision 1.50
diff -u -r1.50 semantics.at
--- tests/semantics.at  14 May 2005 07:00:40 -0000      1.50
+++ tests/semantics.at  6 Sep 2005 15:19:52 -0000
@@ -83,7 +83,13 @@
 case "$ac_cv_search_cos" in
   -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_cos must be a cool 
library!]) ;;
 esac
+])
 
+
+# AC_SEARCH_LIBS (none needed)
+# ----------------------------
+AT_CHECK_MACRO([AC_SEARCH_LIBS (none needed)],
+[
 AC_SEARCH_LIBS(printf, oser c ust,,
             [AC_MSG_ERROR([cannot find `printf'])])
 
@@ -91,7 +97,6 @@
   -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_printf must be a cool 
library!]) ;;
   -lc) AC_MSG_ERROR([huh, you need to give -lc?])
 esac
-
 ])
 
 

Reply via email to