-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
The following code is located immediately after searching for gethostbyname
in configure.ac
:
dnl resolve lib?
AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
AC_CHECK_LIB(resolve, strcasecmp,
[LIBS="-lresolve $LIBS"],
,
-lnsl)
fi
ac_cv_func_strcasecmp="no"
There are several issues with this code:
- I do not know of any library named
libresolve
, onlylibresolv
- I have never seen
strcasecmp
being searched for in a networking library - If the first
AC_CHECK_LIB
succeeds,-lresolve
is never added toLIBS
which makes no sense - Blindly setting the cache variable to "no" in the end is likely to wreak havoc in projects relying on the cache
I have the feeling this is some really old, untested code that was never executed, simply because (I originally confused the location of AC_CHECK_FUNC
re-used the cached variable ac_cv_func_strcasecmp
which is set earlier, in a call to CURL_CHECK_FUNC_STRCASECMP
, and which is highly likely to be "yes".CURL_CHECK_FUNC_STRCASECMP
relative to this piece of code)
When this variable is "no" AC_CHECK_FUNC
fails, assuming the library name is a typo, AC_CHECK_LIB
will never succeed and nothing will happen. When AC_CHECK_FUNC
succeeds, the rest is never executed and nothing will happen.
The code seems to be from 1999/2000, which fits with the existence of the library libresolv
.
I have the feeling, the author meant to look for gethostbyname
in libresolv
, as this function is searched in multiple libraries right before this piece of code.
If I'm wrong about any of this, I beg for a reference to libresolve
and for an explanation about looking for strcasecmp
there.
If I'm right about this, I would gladly rewrite the code to look for gethostbyname
(seems to have been in libresolv
in 1997)