From: Bruno Haible Date: Fri, 5 Jan 2001 13:47:56 +0000 (+0000) Subject: New autoconf macros for detecting long integer types. X-Git-Tag: v0.10.36~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b401e094dc64e9054af2f09ec2741c8c835929b;p=thirdparty%2Fgettext.git New autoconf macros for detecting long integer types. --- diff --git a/ChangeLog b/ChangeLog index 32fc31423..b126b5848 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-12-30 Bruno Haible + + * configure.in: Call jm_AC_TYPE_UNSIGNED_LONG_LONG and + jm_AC_TYPE_UINTMAX_T. + 2000-11-09 Bruno Haible * configure.in (ALL_LINGUAS): Add tr. diff --git a/configure.in b/configure.in index 64118c3ee..0ee90f114 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.12) -AC_REVISION($Revision: 1.4 $) +AC_REVISION($Revision: 1.5 $) AC_INIT(src/msgfmt.c) AM_INIT_AUTOMAKE(gettext, 0.10.36) AM_CONFIG_HEADER(config.h) @@ -28,9 +28,11 @@ dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_C_BACKSLASH_A +jm_AC_TYPE_UNSIGNED_LONG_LONG AC_TYPE_OFF_T AC_TYPE_SIZE_T AM_TYPE_PTRDIFF_T +jm_AC_TYPE_UINTMAX_T dnl Checks for library functions. AC_FUNC_ALLOCA diff --git a/lib/ChangeLog b/lib/ChangeLog index 4bee6c6fd..52add8b9e 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,12 @@ +2000-12-30 Bruno Haible + + * printf.h (printf_info): New fields is_char, is_longlong. + (PA_FLAG_CHAR): New macro. + * printf-parse.h: Include inttypes.h. + (long_long_int): Define depending on HAVE_UNSIGNED_LONG_LONG. + (ptrdiff_t): Define depending on HAVE_PTRDIFF_T. + (parse_one_spec): Handle new ISO C99 length modifiers 'j', 't', 'z'. + 2000-12-30 Bruno Haible * basename.c: Update from current fileutils version, keeping the diff --git a/lib/printf-parse.h b/lib/printf-parse.h index 122582442..899323a56 100644 --- a/lib/printf-parse.h +++ b/lib/printf-parse.h @@ -1,5 +1,5 @@ /* Internal header for parsing printf format strings. - Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,9 @@ #if HAVE_STDDEF_H # include #endif +#if HAVE_INTTYPES_H +# include +#endif #if HAVE_STRING_H # include @@ -31,13 +34,21 @@ #endif #if __GNUC__ >= 2 -# define long_long_int long long int # define long_double long double #else -# define long_long_int long # define long_double double #endif +#if HAVE_UNSIGNED_LONG_LONG +# define long_long_int long long int +#else +# define long_long_int long int +#endif + +#if !HAVE_PTRDIFF_T +# define ptrdiff_t long int +#endif + #define NDEBUG 1 #include @@ -294,31 +305,49 @@ parse_one_spec (format, posn, spec, max_ref_arg) } /* Check for type modifiers. */ -#define is_longlong is_long_double spec->info.is_long_double = 0; spec->info.is_short = 0; + spec->info.is_char = 0; spec->info.is_long = 0; + spec->info.is_longlong = 0; while (*format == 'h' || *format == 'l' || *format == 'L' || *format == 'Z' || *format == 'q') switch (*format++) { case 'h': - /* int's are short int's. */ - spec->info.is_short = 1; + if (spec->info.is_short) + /* int's are char's. */ + spec->info.is_char = 1; + else + /* int's are short int's. */ + spec->info.is_short = 1; break; case 'l': if (spec->info.is_long) /* A double `l' is equivalent to an `L'. */ - spec->info.is_longlong = 1; + spec->info.is_longlong = spec->info.is_long_double = 1; else /* int's are long int's. */ spec->info.is_long = 1; break; case 'L': /* double's are long double's, and int's are long long int's. */ - spec->info.is_long_double = 1; + spec->info.is_long_double = spec->info.is_longlong = 1; + break; + case 'j': + /* int's are intmax_t's. */ + assert (sizeof(uintmax_t) <= sizeof(unsigned long_long_int)); + spec->info.is_longlong = sizeof(uintmax_t) > sizeof(unsigned long int); + spec->info.is_long = sizeof(uintmax_t) > sizeof(unsigned int); + break; + case 't': + /* int's are ptrdiff_t's. */ + assert (sizeof(ptrdiff_t) <= sizeof(unsigned long_long_int)); + spec->info.is_longlong = sizeof(ptrdiff_t) > sizeof(unsigned long int); + spec->info.is_long = sizeof(ptrdiff_t) > sizeof(unsigned int); break; + case 'z': case 'Z': /* int's are size_t's. */ assert (sizeof(size_t) <= sizeof(unsigned long_long_int)); @@ -348,6 +377,8 @@ parse_one_spec (format, posn, spec, max_ref_arg) spec->data_arg_type = PA_INT|PA_FLAG_LONG_LONG; else if (spec->info.is_long) spec->data_arg_type = PA_INT|PA_FLAG_LONG; + else if (spec->info.is_char) + spec->data_arg_type = PA_INT|PA_FLAG_CHAR; else if (spec->info.is_short) spec->data_arg_type = PA_INT|PA_FLAG_SHORT; else diff --git a/lib/printf.h b/lib/printf.h index 22b9623fc..9398cb1be 100644 --- a/lib/printf.h +++ b/lib/printf.h @@ -40,7 +40,9 @@ struct printf_info char spec; /* Format letter. */ unsigned is_long_double:1; /* L flag. */ unsigned is_short:1; /* h flag. */ + unsigned is_char:1; /* hh flag. */ unsigned is_long:1; /* l flag. */ + unsigned is_longlong:1; /* ll flag. */ unsigned alt:1; /* # flag. */ unsigned space:1; /* Space flag. */ unsigned left:1; /* - flag. */ @@ -103,6 +105,7 @@ enum #define PA_FLAG_LONG (1 << 9) #define PA_FLAG_SHORT (1 << 10) #define PA_FLAG_PTR (1 << 11) +#define PA_FLAG_CHAR (1 << 12) #endif /* printf.h */ diff --git a/m4/ChangeLog b/m4/ChangeLog index 8c46d58e1..3e0ec4636 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,10 @@ +2000-12-30 Bruno Haible + + * ulonglong.m4: New file, from fileutils-4.0.32. + * inttypes_h.m4: Likewise. + * uintmax_t.m4: Likewise. + * Makefile.am (EXTRA_DIST): Add them. + 2000-09-14 Bruno Haible * gettext.m4 (AM_WITH_NLS): Make the tests for gettext in libc and diff --git a/m4/Makefile.am b/m4/Makefile.am index 88175e8f2..eb744a4bd 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -7,5 +7,5 @@ aclocal_DATA = gettext.m4 isc-posix.m4 lcmessage.m4 progtest.m4 # find . -type f -name '*.m4' -printf '%f\n'|sort |fmt |tr '\012' @ \ # |sed 's/@$/%/;s/@/ \\@/g' |tr @% '\012\012' EXTRA_DIST = README \ -c-bs-a.m4 codeset.m4 gettext.m4 iconv.m4 isc-posix.m4 lcmessage.m4 \ -progtest.m4 +c-bs-a.m4 codeset.m4 gettext.m4 iconv.m4 inttypes_h.m4 isc-posix.m4 \ +lcmessage.m4 progtest.m4 uintmax_t.m4 ulonglong.m4 diff --git a/m4/inttypes_h.m4 b/m4/inttypes_h.m4 new file mode 100644 index 000000000..750639d6f --- /dev/null +++ b/m4/inttypes_h.m4 @@ -0,0 +1,22 @@ +#serial 3 + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN(jm_AC_HEADER_INTTYPES_H, +[ + AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1;], + jm_ac_cv_header_inttypes_h=yes, + jm_ac_cv_header_inttypes_h=no)]) + if test $jm_ac_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, +[Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) diff --git a/m4/uintmax_t.m4 b/m4/uintmax_t.m4 new file mode 100644 index 000000000..27045387d --- /dev/null +++ b/m4/uintmax_t.m4 @@ -0,0 +1,22 @@ +#serial 5 + +dnl From Paul Eggert. + +AC_PREREQ(2.13) + +# Define uintmax_t to `unsigned long' or `unsigned long long' +# if does not exist. + +AC_DEFUN(jm_AC_TYPE_UINTMAX_T, +[ + AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) + if test $jm_ac_cv_header_inttypes_h = no; then + AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG]) + test $ac_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, + [Define to unsigned long or unsigned long long + if doesn't define.]) + fi +]) diff --git a/m4/ulonglong.m4 b/m4/ulonglong.m4 new file mode 100644 index 000000000..e2fbb5526 --- /dev/null +++ b/m4/ulonglong.m4 @@ -0,0 +1,17 @@ +#serial 2 + +dnl From Paul Eggert. + +AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG, +[ + AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long, + [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;], + [unsigned long long ullmax = (unsigned long long) -1; + return ull << i | ull >> i | ullmax / ull | ullmax % ull;], + ac_cv_type_unsigned_long_long=yes, + ac_cv_type_unsigned_long_long=no)]) + if test $ac_cv_type_unsigned_long_long = yes; then + AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1, + [Define if you have the unsigned long long type.]) + fi +])