autoconf
[Top][All Lists]
Advanced

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

Re: strncasecmp dcl


From: Akim Demaille
Subject: Re: strncasecmp dcl
Date: 28 Jun 2001 19:08:23 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Academic Rigor)

>>>>> "Paul" == Paul Eggert <address@hidden> writes:

Paul> The change I proposed should render unnecessary the inttypes.h
Paul> patch that Akim proposed Saturday to bug-autoconf.  This is
Paul> because it would cause AC_CHECK_HEADER to do the right thing
Paul> with sys/types.h versus inttypes.h, and we thus wouldn't need to
Paul> have Akim's special-purpose code to second-guess
Paul> AC_CHECK_HEADER.

In fact we have the very same intentions.  And I had already changed
AC_CHECK_HEADERS to do this, when I was handling inttypes vs
sys/types.  Hence CVS has:


   # AC_CHECK_HEADER(HEADER-FILE,
   #                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
   #                 [INCLUDES])
   # ---------------------------------------------------------
   AC_DEFUN([AC_CHECK_HEADER],
   [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
   AC_CACHE_CHECK([for $1], ac_Header,
                  [AC_PREPROC_IFELSE([AC_LANG_SOURCE([m4_n([$4])dnl
   @%:@include <$1>])],
                                     [AS_VAR_SET(ac_Header, yes)],
                                     [AS_VAR_SET(ac_Header, no)])])
   AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
   AS_VAR_POPDEF([ac_Header])dnl
   ])# AC_CHECK_HEADER


with the INCLUDES (that's the novelty wrt 2.50).  That was my goal,
and I was happy as I had fixed the bug.


Until I realized we are using CPP here, which just does not care with
such name clashes.


So I'd like to move AC_CHECK_HEADERS to compile instead of
preprocessing.  But it can be extremely dangerous as people are not
use to it and are most probably checking for the existence of some
headers without first including required headers (Pavel helped me
realize that, thanks Pavel).

In the urgency I applied an ugly patch to fix the inttype vs sys/types
issue:

   # _AC_INCLUDES_DEFAULT_REQUIREMENTS
   # ---------------------------------
   # Required when AC_INCLUDES_DEFAULT uses its default branch.
   AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
   [m4_divert_text([DEFAULTS],
   [# Factoring default headers for most tests.
   dnl If ever you change this variable, please keep autoconf.texi in sync.
   ac_includes_default="\
   #include <stdio.h>
   #if HAVE_SYS_TYPES_H
   # include <sys/types.h>
   #endif
   #if HAVE_SYS_STAT_H
   # include <sys/stat.h>
   #endif
   #if STDC_HEADERS
   # include <stdlib.h>
   # include <stddef.h>
   #else
   # if HAVE_STDLIB_H
   #  include <stdlib.h>
   # endif
   #endif
   #if HAVE_STRING_H
   # if !STDC_HEADERS && HAVE_MEMORY_H
   #  include <memory.h>
   # endif
   # include <string.h>
   #else
   # if HAVE_STRINGS_H
   #  include <strings.h>
   # endif
   #endif
   #if HAVE_INTTYPES_H
   # include <inttypes.h>
   #else
   # if HAVE_STDINT_H
   #  include <stdint.h>
   # endif
   #endif
   #if HAVE_UNISTD_H
   # include <unistd.h>
   #endif"
   ])dnl
   AC_REQUIRE([AC_HEADER_STDC])dnl
   # On IRIX 5.3, sys/types and inttypes.h are conflicting.
   AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h 
strings.h \
                     stdint.h unistd.h],
                    [], [], $ac_includes_default)
>   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define HAVE_INTTYPES_H 1
>   $ac_includes_default])],
>                     [ac_cv_header_inttypes_h=yes,
>   AC_DEFINE([HAVE_INTTYPES_H], 1,
>             [Define if you have the <inttypes.h> header file.])],
>                     [ac_cv_header_inttypes_h=no])
   ])




Now, I took some more time to think about it, and here is my proposal:
when $4 is not given (was introduced in 2.50a, did not exist before,
so we are free to do whatever we want with it), just do what Autoconf
always did: merely check it can be preprocessed --- yuck, how sad CPP
was chosen here :-( ---, but when $4 is given, test with the compiler.


Then I agree many dedicated code can be removed, and the world is more
beautiful than before.



reply via email to

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