From d58cf1a8bfe32f0a726fd4e22d275bf6b6f760e1 Mon Sep 17 00:00:00 2001 From: "Derek R. Price" Date: Tue, 18 Apr 2006 17:20:47 +0000 Subject: [PATCH] * modules/inttypes: New file. * modules/strtoimax, modules/strtoumax: Depend on inttypes. * lib/inttypes.h: New file. * lib/strtoimax.c: Assume . * m4/_inttypes_h.m4, m4/full-header-path.m4, m4/include_next: New files. --- ChangeLog | 6 ++++++ lib/ChangeLog | 6 ++++++ lib/inttypes.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/strtoimax.c | 8 ++------ m4/ChangeLog | 6 ++++++ m4/_inttypes_h.m4 | 13 +++++++++++++ m4/full-header-path.m4 | 47 +++++++++++++++++++++++++++++++++++++++++++++++ m4/include_next.m4 | 19 +++++++++++++++++++ modules/inttypes | 28 ++++++++++++++++++++++++++++ modules/strtoimax | 1 + modules/strtoumax | 1 + 11 files changed, 177 insertions(+), 6 deletions(-) create mode 100644 lib/inttypes.h create mode 100644 m4/_inttypes_h.m4 create mode 100644 m4/full-header-path.m4 create mode 100644 m4/include_next.m4 create mode 100644 modules/inttypes diff --git a/ChangeLog b/ChangeLog index 687d5d295..17e6696b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-18 Derek Price + Paul Eggert + + * modules/inttypes: New file. + * modules/strtoimax, modules/strtoumax: Depend on inttypes. + 2006-04-12 Eric Blake * modules/time_r (Makefile.am): Remove lib_SOURCES line, as this diff --git a/lib/ChangeLog b/lib/ChangeLog index e243ab210..859705633 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2006-04-18 Derek Price + Paul Eggert + + * lib/inttypes.h: New file. + * lib/strtoimax.c: Assume . + 2006-04-15 Paul Eggert * utimens.c (futimens): glibc futimesat messes up if /proc diff --git a/lib/inttypes.h b/lib/inttypes.h new file mode 100644 index 000000000..924a66ac2 --- /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 . + * + * + * Currently, if the system is missing or not C99 compliant, then + * this header may only to provide the required (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 +# else +# include FULL_PATH_INTTYPES_H +# endif +#endif +#include + +#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 a15b84af3..098cfa966 100644 --- a/lib/strtoimax.c +++ b/lib/strtoimax.c @@ -23,12 +23,8 @@ # include #endif -#if HAVE_INTTYPES_H -# include -#endif -#if HAVE_STDINT_H -# include -#endif +/* Verify interface. */ +#include #include diff --git a/m4/ChangeLog b/m4/ChangeLog index 198ba9c9c..c443a4773 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,9 @@ +2006-04-18 Derek Price + Paul Eggert + + * m4/_inttypes_h.m4, m4/full-header-path.m4, m4/include_next: New + files. + 2006-04-11 Paul Eggert * 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 000000000..8cf2a9c55 --- /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 000000000..3a1e2f08f --- /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 000000000..62c5f3b3b --- /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 ], + [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 000000000..fa542ab69 --- /dev/null +++ b/modules/inttypes @@ -0,0 +1,28 @@ +Description: +A wrapper C99 header which will always include +(possibly the *almost* C99 compliant GNULIB ) 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 + +License: +LGPL + +Maintainer: +Derek Price + diff --git a/modules/strtoimax b/modules/strtoimax index dc48d2d72..2f5fe593b 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 8cfc8096b..b8eadb4f0 100644 --- a/modules/strtoumax +++ b/modules/strtoumax @@ -12,6 +12,7 @@ m4/strtoumax.m4 Depends-on: strtoimax strtoull +inttypes configure.ac: gl_FUNC_STRTOUMAX -- 2.11.0