summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/ChangeLog6
-rw-r--r--lib/inttypes.h48
-rw-r--r--lib/strtoimax.c8
-rw-r--r--m4/ChangeLog6
-rw-r--r--m4/_inttypes_h.m413
-rw-r--r--m4/full-header-path.m447
-rw-r--r--m4/include_next.m419
-rw-r--r--modules/inttypes28
-rw-r--r--modules/strtoimax1
-rw-r--r--modules/strtoumax1
11 files changed, 177 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 687d5d2959..17e6696b8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-18 Derek Price <derek@ximbiot.com>
+ Paul Eggert <eggert@cs.ucla.edu>
+
+ * modules/inttypes: New file.
+ * modules/strtoimax, modules/strtoumax: Depend on inttypes.
+
2006-04-12 Eric Blake <ebb9@byu.net>
* modules/time_r (Makefile.am): Remove lib_SOURCES line, as this
diff --git a/lib/ChangeLog b/lib/ChangeLog
index e243ab210c..8597056335 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-18 Derek Price <derek@ximbiot.com>
+ Paul Eggert <eggert@cs.ucla.edu>
+
+ * lib/inttypes.h: New file.
+ * lib/strtoimax.c: Assume <inttypes.h>.
+
2006-04-15 Paul Eggert <eggert@cs.ucla.edu>
* utimens.c (futimens): glibc futimesat messes up if /proc
diff --git a/lib/inttypes.h b/lib/inttypes.h
new file mode 100644
index 0000000000..924a66ac2d
--- /dev/null
+++ b/lib/inttypes.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+ Written by Derek Price & Paul Eggert.
+ This file is part of gnulib.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef INTTYPES_H
+#define INTTYPES_H
+
+/*
+ * A wrapper for the ISO C 99 <inttypes.h>.
+ * <http://www.opengroup.org/onlinepubs/007904975/basedefs/inttypes.h.html>
+ *
+ * Currently, if the system <inttypes.h> is missing or not C99 compliant, then
+ * this header may only to provide the required <stdint.h> (which may be the
+ * *almost* C99 compliant one from GNULIB) and prototypes for the strtoimax and
+ * strtoumax functions.
+ */
+
+#if HAVE_INTTYPES_H
+# if HAVE_INCLUDE_NEXT
+# include_next <inttypes.h>
+# else
+# include FULL_PATH_INTTYPES_H
+# endif
+#endif
+#include <stdint.h>
+
+#if !HAVE_DECL_STRTOIMAX
+intmax_t strtoimax (const char *, char **, int);
+#endif
+#if !HAVE_DECL_STRTOUMAX
+uintmax_t strtoumax (const char *, char **, int);
+#endif
+
+#endif /* INTTYPES_H */
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index a15b84af3a..098cfa966e 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -23,12 +23,8 @@
# include <config.h>
#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
+/* Verify interface. */
+#include <inttypes.h>
#include <stdlib.h>
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 198ba9c9ce..c443a4773d 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-18 Derek Price <derek@ximbiot.com>
+ Paul Eggert <eggert@cs.ucla.edu>
+
+ * m4/_inttypes_h.m4, m4/full-header-path.m4, m4/include_next: New
+ files.
+
2006-04-11 Paul Eggert <eggert@cs.ucla.edu>
* time_r.m4 (gl_TIME_R): Add AC_LIBSOURCES for time_r.c and time_r.h.
diff --git a/m4/_inttypes_h.m4 b/m4/_inttypes_h.m4
new file mode 100644
index 0000000000..8cf2a9c558
--- /dev/null
+++ b/m4/_inttypes_h.m4
@@ -0,0 +1,13 @@
+# _inttypes_h.m4 serial 1
+dnl Copyright (C) 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Derek Price.
+
+AC_DEFUN([gl_INTTYPES_H],
+[AC_LIBSOURCES([inttypes.h])
+gl_FULL_HEADER_PATH([inttypes.h])
+AC_CHECK_DECLS_ONCE([strtoimax strtoumax])dnl
+])
diff --git a/m4/full-header-path.m4 b/m4/full-header-path.m4
new file mode 100644
index 0000000000..3a1e2f08f1
--- /dev/null
+++ b/m4/full-header-path.m4
@@ -0,0 +1,47 @@
+# full-header-path.m4 serial 1
+dnl Copyright (C) 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Derek Price.
+
+# gl_FULL_HEADER_PATH(HEADER1 HEADER2 ...)
+# ----------------------------------------
+# Find the full path to a header file, when the #include_next directive
+# doesn't work and the header exists in the first place. If the header were
+# sys/inttypes.h (and it existed and #include_next didn't work), this macro
+# would define FULL_PATH_SYS_INTTYPES_H to the quoted full path to
+# sys/inttypes.h in config.h
+# (e.g. `#define FULL_PATH_SYS_INTTYPES_H "/usr/include/sys/inttypes.h"').
+AC_DEFUN([gl_FULL_HEADER_PATH],
+[AC_LANG_PREPROC_REQUIRE()dnl
+AC_REQUIRE([gl_INCLUDE_NEXT])dnl
+if test $gl_cv_have_include_next = no; then
+AC_FOREACH([gl_HEADER_NAME], [$1],
+ [AS_VAR_PUSHDEF([gl_full_header_path],
+ [gl_cv_full_path_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
+ AC_CACHE_CHECK([full path to <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
+ m4_quote(m4_defn([gl_full_header_path])),
+ [AS_VAR_PUSHDEF([ac_header_exists],
+ [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
+ AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl
+ if test AS_VAR_GET(ac_header_exists) = yes; then
+ AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
+dnl eval is necessary to expand ac_cpp.
+dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
+ AS_VAR_SET(gl_full_header_path,
+[`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
+sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#;p;q;}'`])
+ fi
+ AS_VAR_POPDEF([ac_header_exists])dnl
+ ])dnl
+ AC_DEFINE_UNQUOTED([FULL_PATH_]m4_quote(translit(m4_defn([gl_HEADER_NAME]),
+ [-./abcdefghijklmnopqrstuvwxyz],
+ [___ABCDEFGHIJKLMNOPQRSTUVWXYZ])),
+ ["AS_VAR_GET(gl_full_header_path)"],
+ [Define this to the full path to <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.])
+ AS_VAR_POPDEF([gl_full_header_path])dnl
+])dnl
+fi
+])# gl_FULL_HEADER_PATH
diff --git a/m4/include_next.m4 b/m4/include_next.m4
new file mode 100644
index 0000000000..62c5f3b3b5
--- /dev/null
+++ b/m4/include_next.m4
@@ -0,0 +1,19 @@
+# include_next.m4 serial 1
+dnl Copyright (C) 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Derek Price.
+
+AC_DEFUN([gl_INCLUDE_NEXT],
+[AC_CACHE_CHECK([whether the preprocessor supports include_next],
+[gl_cv_have_include_next],
+[AC_PREPROC_IFELSE([#include_next <stddef.h>],
+ [gl_cv_have_include_next=yes],
+ [gl_cv_have_include_next=no])])
+if test $gl_cv_have_include_next = yes; then
+ AC_DEFINE([HAVE_INCLUDE_NEXT], 1,
+ [Define if your compiler supports the #include_next directive.])
+fi
+])
diff --git a/modules/inttypes b/modules/inttypes
new file mode 100644
index 0000000000..fa542ab690
--- /dev/null
+++ b/modules/inttypes
@@ -0,0 +1,28 @@
+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.
+
+Files:
+lib/inttypes.h
+m4/include_next.m4
+m4/full-header-path.m4
+m4/_inttypes_h.m4
+
+Depends-on:
+stdint
+
+configure.ac:
+gl_INTTYPES_H
+
+Makefile.am:
+
+Include:
+#include <inttypes.h>
+
+License:
+LGPL
+
+Maintainer:
+Derek Price
+
diff --git a/modules/strtoimax b/modules/strtoimax
index dc48d2d72e..2f5fe593b1 100644
--- a/modules/strtoimax
+++ b/modules/strtoimax
@@ -12,6 +12,7 @@ m4/strtoimax.m4
Depends-on:
strtoll
verify
+inttypes
configure.ac:
gl_FUNC_STRTOIMAX
diff --git a/modules/strtoumax b/modules/strtoumax
index 8cfc8096b8..b8eadb4f0f 100644
--- a/modules/strtoumax
+++ b/modules/strtoumax
@@ -12,6 +12,7 @@ m4/strtoumax.m4
Depends-on:
strtoimax
strtoull
+inttypes
configure.ac:
gl_FUNC_STRTOUMAX