changeset 7207:a1deb716fd26

Rewritten inttypes module. New modules imaxabs, imaxdiv.
author Bruno Haible <bruno@clisp.org>
date Mon, 28 Aug 2006 12:54:47 +0000
parents 4e6b2be7a129
children 783f359a4ea2
files ChangeLog lib/ChangeLog lib/stdint_.h m4/ChangeLog m4/inttypes-pri.m4 m4/stdint.m4 modules/inttypes modules/stdint
diffstat 8 files changed, 68 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-08-26  Bruno Haible  <bruno@clisp.org>
+
+	* modules/inttypes (Files): Add lib/inttypes_.h, remove lib/inttypes.h.
+	Add m4/inttypes.m4, remove m4/_inttypes_h.m4 and m4/include_next.m4.
+	(Makefile.am): Create inttypes.h from inttypes_.h.
+	* modules/stdint (Makefile.am): Substitute also ABSOLUTE_INTTYPES_H.
+
+	* modules/imaxabs: New file.
+
+	* modules/imaxdiv: New file.
+
 2006-08-25  Paul Eggert  <eggert@cs.ucla.edu>
 
 	New config-h module, so that "make" output needn't be cluttered
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,13 @@
+2006-08-26  Bruno Haible  <bruno@clisp.org>
+
+	* inttypes_.h: New file.
+	* inttypes.h: Remove file.
+	* stdint_.h: Include <inttypes.h> through its absolute filename.
+
+	* imaxabs.c: New file.
+
+	* imaxdiv.c: New file.
+
 2006-08-22  Bruno Haible  <bruno@clisp.org>
 
 	* readutmp.h: Skip most definitions if neither <utmp.h> nor
--- a/lib/stdint_.h
+++ b/lib/stdint_.h
@@ -62,7 +62,7 @@
   /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
      int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
      <inttypes.h> also defines intptr_t and uintptr_t.  */
-# include <inttypes.h>
+# include @ABSOLUTE_INTTYPES_H@
 #elif @HAVE_SYS_INTTYPES_H@
   /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
      the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.  */
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,14 @@
+2006-08-26  Bruno Haible  <bruno@clisp.org>
+
+	* inttypes.m4: New file.
+	* _inttypes_h.m4: Remove file.
+	* inttypes-pri.m4 (gt_INTTYPES_PRI): Also AC_SUBST PRI_MACROS_BROKEN.
+	* stdint.m4 (gl_STDINT_H): Define also ABSOLUTE_INTTYPES_H.
+
+	* imaxabs.m4: New file.
+
+	* imaxdiv.m4: New file.
+
 2006-08-25  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* config-h.m4: New file.
--- a/m4/inttypes-pri.m4
+++ b/m4/inttypes-pri.m4
@@ -1,4 +1,4 @@
-# inttypes-pri.m4 serial 2 (gettext-0.15)
+# inttypes-pri.m4 serial 3 (gettext-0.15.1)
 dnl Copyright (C) 1997-2002, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -26,5 +26,9 @@
   if test "$gt_cv_inttypes_pri_broken" = yes; then
     AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1,
       [Define if <inttypes.h> exists and defines unusable PRI* macros.])
+    PRI_MACROS_BROKEN=1
+  else
+    PRI_MACROS_BROKEN=0
   fi
+  AC_SUBST([PRI_MACROS_BROKEN])
 ])
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 18
+# stdint.m4 serial 19
 dnl Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -32,10 +32,14 @@
   dnl Check for <inttypes.h>.
   dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
   if test $ac_cv_header_inttypes_h = yes; then
+    gl_ABSOLUTE_HEADER([inttypes.h])
+    ABSOLUTE_INTTYPES_H=\"$gl_cv_absolute_inttypes_h\"
     HAVE_INTTYPES_H=1
   else
+    ABSOLUTE_INTTYPES_H=\"no/such/file/inttypes.h\"
     HAVE_INTTYPES_H=0
   fi
+  AC_SUBST([ABSOLUTE_INTTYPES_H])
   AC_SUBST([HAVE_INTTYPES_H])
 
   dnl Check for <sys/types.h>.
--- a/modules/inttypes
+++ b/modules/inttypes
@@ -1,21 +1,37 @@
 Description:
-A wrapper C99 <inttypes.h> header which will always include <stdint.h>
-(possibly the *almost* C99 compliant GNULIB <stdint.h>) and prototypes for the
-strtoimax & strtoumax functions.
+An <inttypes.h> that nearly conforms to C99.
 
 Files:
-lib/inttypes.h
-m4/include_next.m4
+lib/inttypes_.h
 m4/absolute-header.m4
-m4/_inttypes_h.m4
+m4/inttypes-pri.m4
+m4/inttypes.m4
 
 Depends-on:
+stdint
 
 configure.ac:
 gl_INTTYPES_H
 
 Makefile.am:
-EXTRA_DIST += inttypes.h
+BUILT_SOURCES += $(INTTYPES_H)
+EXTRA_DIST += inttypes_.h
+
+# We need the following in order to create <inttypes.h> when the system
+# doesn't have one that works with the given compiler.
+inttypes.h: inttypes_.h
+	sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+	    -e 's/@''ABSOLUTE_INTTYPES_H''@/$(ABSOLUTE_INTTYPES_H)/g' \
+	    -e 's/@''PRI_MACROS_BROKEN''@/$(PRI_MACROS_BROKEN)/g' \
+	    -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
+	    -e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \
+	    -e 's/@''HAVE_DECL_IMAXABS''@/$(HAVE_DECL_IMAXABS)/g' \
+	    -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
+	    -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
+	    -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
+	    < $(srcdir)/inttypes_.h > $@-t
+	mv $@-t $@
+MOSTLYCLEANFILES += inttypes.h inttypes.h-t
 
 Include:
 #include <inttypes.h>
--- a/modules/stdint
+++ b/modules/stdint
@@ -26,9 +26,10 @@
 stdint.h: stdint_.h
 	sed -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
 	    -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
+	    -e 's|@''ABSOLUTE_STDINT_H''@|$(ABSOLUTE_STDINT_H)|g' \
 	    -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
-	    -e 's|@''ABSOLUTE_STDINT_H''@|$(ABSOLUTE_STDINT_H)|g' \
 	    -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+	    -e 's|@''ABSOLUTE_INTTYPES_H''@|$(ABSOLUTE_INTTYPES_H)|g' \
 	    -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
 	    -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
 	    -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \