]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New autoconf macros for detecting long integer types.
authorBruno Haible <bruno@clisp.org>
Fri, 5 Jan 2001 13:47:56 +0000 (13:47 +0000)
committerBruno Haible <bruno@clisp.org>
Fri, 5 Jan 2001 13:47:56 +0000 (13:47 +0000)
ChangeLog
configure.in
lib/ChangeLog
lib/printf-parse.h
lib/printf.h
m4/ChangeLog
m4/Makefile.am
m4/inttypes_h.m4 [new file with mode: 0644]
m4/uintmax_t.m4 [new file with mode: 0644]
m4/ulonglong.m4 [new file with mode: 0644]

index 32fc31423deb6b8bc4c14d5b3a6c7b031ca06b79..b126b58488ba3006fbabd2c384dc2db587fd9d5c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-12-30  Bruno Haible  <haible@clisp.cons.org>
+
+       * configure.in: Call jm_AC_TYPE_UNSIGNED_LONG_LONG and
+       jm_AC_TYPE_UINTMAX_T.
+
 2000-11-09  Bruno Haible  <haible@clisp.cons.org>
 
        * configure.in (ALL_LINGUAS): Add tr.
index 64118c3eee03353a240f03a6c2ec5a1ad61b5051..0ee90f1145ccc535032f5047be12637863642a6e 100644 (file)
@@ -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
index 4bee6c6fdd39ea3fe79fc81a0d3984643ccaf98c..52add8b9ec4be16632adb3edc6a8937598493eff 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-30  Bruno Haible  <haible@clisp.cons.org>
+
+       * 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  <haible@clisp.cons.org>
 
        * basename.c: Update from current fileutils version, keeping the
index 1225824423a011bcc01b04e9ca6f0387e6ee07ff..899323a56ac3d0522f1e791f5e177bf5c3d3da0f 100644 (file)
@@ -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 <stddef.h>
 #endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
 
 #if HAVE_STRING_H
 # include <string.h>
 #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 <assert.h>
 
@@ -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
index 22b9623fc8ee9f669d149c878529dbcc2f27c77a..9398cb1be0a7e1b49f9804d676c7a32ba3830ef1 100644 (file)
@@ -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  */
index 8c46d58e1a6fab9a6c3814d928f24f081d1402e6..3e0ec46368fd3c35079f27fbc8daac949b314d66 100644 (file)
@@ -1,3 +1,10 @@
+2000-12-30  Bruno Haible  <haible@clisp.cons.org>
+
+       * 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  <haible@clisp.cons.org>
 
        * gettext.m4 (AM_WITH_NLS): Make the tests for gettext in libc and
index 88175e8f29b0bce260dbf781595116c8276568c2..eb744a4bd9f3a1fd83a5becf7db3fdb84eec88dc 100644 (file)
@@ -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 (file)
index 0000000..750639d
--- /dev/null
@@ -0,0 +1,22 @@
+#serial 3
+
+dnl From Paul Eggert.
+
+# Define HAVE_INTTYPES_H if <inttypes.h> exists,
+# doesn't clash with <sys/types.h>, 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 <sys/types.h>
+#include <inttypes.h>],
+    [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 <inttypes.h> exists, doesn't clash with <sys/types.h>,
+   and declares uintmax_t. ])
+  fi
+])
diff --git a/m4/uintmax_t.m4 b/m4/uintmax_t.m4
new file mode 100644 (file)
index 0000000..2704538
--- /dev/null
@@ -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 <inttypes.h> 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 <inttypes.h> doesn't define.])
+  fi
+])
diff --git a/m4/ulonglong.m4 b/m4/ulonglong.m4
new file mode 100644 (file)
index 0000000..e2fbb55
--- /dev/null
@@ -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
+])