From: Akim Demaille Date: Mon, 24 Jul 2000 06:54:53 +0000 (+0000) Subject: * acgeneral.m4 (_AC_CHECK_TYPE_BUILTIN_P): Add `off_t' and X-Git-Tag: autoconf-2.50~698 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cd06f3117f0391d24df564654197237e1ad459a;p=thirdparty%2Fautoconf.git * acgeneral.m4 (_AC_CHECK_TYPE_BUILTIN_P): Add `off_t' and `size_t' which are often used too. Fix a bug which prevents recognition of `bool' and `char'. (_AC_CHECK_TYPE_MAYBE_TYPE_P): New macro. (AC_CHECK_TYPE): Use it. --- diff --git a/ChangeLog b/ChangeLog index 82f7a525f..85da98ee6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-07-24 Akim Demaille + + * acgeneral.m4 (_AC_CHECK_TYPE_BUILTIN_P): Add `off_t' and + `size_t' which are often used too. + Fix a bug which prevents recognition of `bool' and `char'. + (_AC_CHECK_TYPE_MAYBE_TYPE_P): New macro. + (AC_CHECK_TYPE): Use it. + 2000-07-19 Peter Eisentraut * Makefile.am: Remove INSTALL.txt by maintainer-clean target. diff --git a/acgeneral.m4 b/acgeneral.m4 index 5b26dd772..cbc4766a7 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -3744,16 +3744,28 @@ define([_AC_CHECK_TYPE_OLD], ])# _AC_CHECK_TYPE_OLD -# _AC_CHECK_TYPE_BUILTIN_P(STRING) -# -------------------------------- +# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P(STRING) +# ----------------------------------------- # Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it # starts with `_Bool', `bool', `char', `double', `float', `int', # `long', `short', `signed', or `unsigned' followed by characters # that are defining types. -define([_AC_CHECK_TYPE_BUILTIN_P], -[ifelse(regexp([$1], [^\(_Bool\|bool|\char\|double\|float\|int\|long\|short\|\(un\)?signed\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), +# Because many people have used `off_t' and `size_t' too, they are added +# for better common-useward backward compatibility. +define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P], +[ifelse(regexp([$1], + [^\(_Bool\|bool\|char\|double\|float\|int\|long\|short\|\(un\)?signed\|size_t\|off_t\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), + 0, 1, 0)dnl +])# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P + + +# _AC_CHECK_TYPE_MAYBE_TYPE_P(STRING) +# ----------------------------------- +# Return `1' if STRING looks like a C/C++ type. +define([_AC_CHECK_TYPE_MAYBE_TYPE_P], +[ifelse(regexp([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), 0, 1, 0)dnl -])# _AC_CHECK_TYPE_BUILTIN_P +])# _AC_CHECK_TYPE_MAYBE_TYPE_P # AC_CHECK_TYPE(TYPE, DEFAULT) @@ -3764,15 +3776,20 @@ define([_AC_CHECK_TYPE_BUILTIN_P], # ------------------------------------------------------- # # Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW. -# 1. More than two arguments => NEW -# 2. $2 seems to be builtin type => OLD -# 3. $2 seems to be a type => NEW plus a warning -# 4. default => NEW +# 1. More than two arguments => NEW +# 2. $2 seems to be replacement type => OLD +# See _AC_CHECK_TYPE_REPLACEMENT_TYPE_P for `replacement type'. +# 3. $2 seems to be a type => NEW plus a warning +# 4. default => NEW AC_DEFUN([AC_CHECK_TYPE], -[ifelse($#, 3, [_AC_CHECK_TYPE_NEW($@)], - $#, 4, [_AC_CHECK_TYPE_NEW($@)], - _AC_CHECK_TYPE_BUILTIN_P([$2]), 1, [_AC_CHECK_TYPE_OLD($@)], - regexp([$2], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), 0, [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)], +[ifelse($#, 3, + [_AC_CHECK_TYPE_NEW($@)], + $#, 4, + [_AC_CHECK_TYPE_NEW($@)], + _AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2]), 1, + [_AC_CHECK_TYPE_OLD($@)], + _AC_CHECK_TYPE_MAYBE_TYPE_P([$2]), 1, + [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)], [_AC_CHECK_TYPE_NEW($@)])[]dnl ])# AC_CHECK_TYPE diff --git a/doc/autoconf.texi b/doc/autoconf.texi index fd6dece32..5d931746c 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -3778,9 +3778,8 @@ AC_CHECK_TYPES([unsigned long long, uintmax_t]) Autoconf, up to 2.13, used to provide to another version of @code{AC_CHECK_TYPE}, broken by design. In order to keep backward compatibility, a simple heuristics, quite safe but not totally, is -implemented. In case of doubt, the reader is strongly encouraged to -read the documentation of the former @code{AC_CHECK_TYPE}, see -@ref{Obsolete Macros}. +implemented. In case of doubt, read the documentation of the former +@code{AC_CHECK_TYPE}, see @ref{Obsolete Macros}. @node Compilers and Preprocessors, C Compiler Characteristics, Types, Existing Tests @@ -7863,11 +7862,12 @@ The user is encouraged to explicitly use either @defmac AC_CHECK_TYPE (@var{type}, @var{default}) @maindex CHECK_TYPE -Autoconf, up to 2.13, used to provide to this version of -@code{AC_CHECK_TYPE}, broken by design. First, although it is a member -of the @code{CHECK} clan, singular sub-family, it does more than just -checking. Second, missing types are not typedef'd, they are defined, -which can lead to incompatible code in the case of pointer types. +Autoconf, up to 2.13, used to provide this version of +@code{AC_CHECK_TYPE} deprecated because of it flaws. Firstly, although +it is a member of the @code{CHECK} clan, singular sub-family, it does +more than just checking. Second, missing types are not +@code{typedef}'d, they are @code{#define}'d, which can lead to +incompatible code in the case of pointer types. This use of @code{AC_CHECK_TYPE} is obsolete and discouraged, see @ref{Generic Types}, for the description of the current macro. @@ -7875,43 +7875,39 @@ This use of @code{AC_CHECK_TYPE} is obsolete and discouraged, see If the type @var{type} is not defined, define it to be the C (or C++) builtin type @var{default}; e.g., @samp{short} or @samp{unsigned}. -This macro is equivalent to +This macro is equivalent to: + @example AC_CHECK_TYPE([@var{type}], [AC_DEFINE([@var{type}], [@var{default}], [Define to `@var{default}' if does not define.])]) @end example + In order to keep backward compatibility, the two versions of @code{AC_CHECK_TYPE} are implemented, selected by a simple heuristics: -@itemize @bullet -@item -if there are three or four arguments, the modern version is used; +@enumerate @item -if the second argument is a C or C++ @strong{builtin} type, then the -obsolete version is used; +If there are three or four arguments, the modern version is used. @item -if the second argument is spelled with the alphabet of valid C and C++ -types, the user is warned and the modern version is used; +If the second argument is a C or C++ @emph{builtin} type, then the +obsolete version is used. Because many people have used @samp{off_t} +and @samp{size_t} as replacement types, they are recognized too. @item -otherwise, the modern version is used. -@end itemize +If the second argument is spelled with the alphabet of valid C and C++ +types, the user is warned and the modern version is used. -@noindent -In particular, the following code, which was invalid but functional: - -@example -AC_CHECK_TYPE(loff_t, off_t) -@end example +@item +Otherwise, the modern version is used. +@end enumerate @noindent -will be improperly branched to the modern implementation. You are -encouraged either to use a valid builtin type, or to use the equivalent -modern code (see above), or better yet, to use @code{AC_CHECK_TYPES} -together with +You are encouraged either to use a valid builtin type, or to use the +equivalent modern code (see above), or better yet, to use +@code{AC_CHECK_TYPES} together with @example #if !HAVE_LOFF_T diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 5b26dd772..cbc4766a7 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -3744,16 +3744,28 @@ define([_AC_CHECK_TYPE_OLD], ])# _AC_CHECK_TYPE_OLD -# _AC_CHECK_TYPE_BUILTIN_P(STRING) -# -------------------------------- +# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P(STRING) +# ----------------------------------------- # Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it # starts with `_Bool', `bool', `char', `double', `float', `int', # `long', `short', `signed', or `unsigned' followed by characters # that are defining types. -define([_AC_CHECK_TYPE_BUILTIN_P], -[ifelse(regexp([$1], [^\(_Bool\|bool|\char\|double\|float\|int\|long\|short\|\(un\)?signed\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), +# Because many people have used `off_t' and `size_t' too, they are added +# for better common-useward backward compatibility. +define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P], +[ifelse(regexp([$1], + [^\(_Bool\|bool\|char\|double\|float\|int\|long\|short\|\(un\)?signed\|size_t\|off_t\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), + 0, 1, 0)dnl +])# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P + + +# _AC_CHECK_TYPE_MAYBE_TYPE_P(STRING) +# ----------------------------------- +# Return `1' if STRING looks like a C/C++ type. +define([_AC_CHECK_TYPE_MAYBE_TYPE_P], +[ifelse(regexp([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), 0, 1, 0)dnl -])# _AC_CHECK_TYPE_BUILTIN_P +])# _AC_CHECK_TYPE_MAYBE_TYPE_P # AC_CHECK_TYPE(TYPE, DEFAULT) @@ -3764,15 +3776,20 @@ define([_AC_CHECK_TYPE_BUILTIN_P], # ------------------------------------------------------- # # Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW. -# 1. More than two arguments => NEW -# 2. $2 seems to be builtin type => OLD -# 3. $2 seems to be a type => NEW plus a warning -# 4. default => NEW +# 1. More than two arguments => NEW +# 2. $2 seems to be replacement type => OLD +# See _AC_CHECK_TYPE_REPLACEMENT_TYPE_P for `replacement type'. +# 3. $2 seems to be a type => NEW plus a warning +# 4. default => NEW AC_DEFUN([AC_CHECK_TYPE], -[ifelse($#, 3, [_AC_CHECK_TYPE_NEW($@)], - $#, 4, [_AC_CHECK_TYPE_NEW($@)], - _AC_CHECK_TYPE_BUILTIN_P([$2]), 1, [_AC_CHECK_TYPE_OLD($@)], - regexp([$2], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), 0, [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)], +[ifelse($#, 3, + [_AC_CHECK_TYPE_NEW($@)], + $#, 4, + [_AC_CHECK_TYPE_NEW($@)], + _AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2]), 1, + [_AC_CHECK_TYPE_OLD($@)], + _AC_CHECK_TYPE_MAYBE_TYPE_P([$2]), 1, + [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)], [_AC_CHECK_TYPE_NEW($@)])[]dnl ])# AC_CHECK_TYPE