[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C99 strto* protos
From: |
Derek R. Price |
Subject: |
Re: C99 strto* protos |
Date: |
Tue, 11 Apr 2006 10:48:41 -0400 |
User-agent: |
Thunderbird 1.5 (Windows/20051201) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Paul Eggert wrote:
> How about if gnulib creates an <inttypes.h> that has the declarations
> that the standard requires? The gnulib <inttypes.h> can look like this:
So, you were suggesting something like the attached mess? The new
<inttypes.h> file looks mostly like what you were suggesting, except
that it includes <stdint.h> unconditionally by depending on GNULIB's
stdint module. The new m4/_inttypes_h.m4 file name is a bit ugly, but
there appear to be a lot of inttype.h related macros currently.
Merging the new _inttypes_h.m4 with intypes.m4 and inttypes_h.m4
should be trivial, but it looks like some of this might need to take
place in gettext and I thought this patch was big enough as things
stand. I tested pretty thoroughly that all the full-path and
include_next stuff works under Linux, but have yet to try this on any
other systems.
2006-04-11 Derek Price <derek@ximbiot.com>
Paul Eggert <eggert@cs.ucla.edu>
* lib/inttypes.h: New file.
* lib/strtoimax.c: Assume <inttypes.h>.
* m4/_inttypes_h.m4, m4/full-header-path.m4, m4/include_next: New
files.
* modules/inttypes: New file.
* modules/strtoimax, modules/strtoumax: Depend on inttypes.
Regards,
Derek
- --
Derek R. Price
CVS Solutions Architect
Get CVS support at Ximbiot <http://ximbiot.com>!
v: +1 248.835.1260
f: +1 248.835.1263
<mailto:derek@ximbiot.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEO8HGLD1OTBfyMaQRAhUmAJ49emGwWL3cAwVhTTmKFdJLtaRX5ACg22iO
ZQoENDQz5gxnMBjEvbLnIro=
=/vjZ
-----END PGP SIGNATURE-----
Index: lib/inttypes.h
===================================================================
RCS file: lib/inttypes.h
diff -N lib/inttypes.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/inttypes.h 11 Apr 2006 14:27:29 -0000
@@ -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 */
Index: lib/strtoimax.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strtoimax.c,v
retrieving revision 1.13
diff -u -p -r1.13 strtoimax.c
--- lib/strtoimax.c 2 Oct 2005 22:44:15 -0000 1.13
+++ lib/strtoimax.c 11 Apr 2006 14:27:29 -0000
@@ -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>
Index: m4/_inttypes_h.m4
===================================================================
RCS file: m4/_inttypes_h.m4
diff -N m4/_inttypes_h.m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ m4/_inttypes_h.m4 11 Apr 2006 14:27:29 -0000
@@ -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
+])
Index: m4/full-header-path.m4
===================================================================
RCS file: m4/full-header-path.m4
diff -N m4/full-header-path.m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ m4/full-header-path.m4 11 Apr 2006 14:27:29 -0000
@@ -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_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
Index: m4/include_next.m4
===================================================================
RCS file: m4/include_next.m4
diff -N m4/include_next.m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ m4/include_next.m4 11 Apr 2006 14:27:29 -0000
@@ -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
+])
Index: modules/inttypes
===================================================================
RCS file: modules/inttypes
diff -N modules/inttypes
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/inttypes 11 Apr 2006 14:27:29 -0000
@@ -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
+
Index: modules/strtoimax
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/strtoimax,v
retrieving revision 1.5
diff -u -p -r1.5 strtoimax
--- modules/strtoimax 2 Oct 2005 22:44:15 -0000 1.5
+++ modules/strtoimax 11 Apr 2006 14:27:29 -0000
@@ -12,6 +12,7 @@ m4/strtoimax.m4
Depends-on:
strtoll
verify
+inttypes
configure.ac:
gl_FUNC_STRTOIMAX
Index: modules/strtoumax
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/strtoumax,v
retrieving revision 1.4
diff -u -p -r1.4 strtoumax
--- modules/strtoumax 22 Sep 2004 15:11:04 -0000 1.4
+++ modules/strtoumax 11 Apr 2006 14:27:29 -0000
@@ -12,6 +12,7 @@ m4/strtoumax.m4
Depends-on:
strtoimax
strtoull
+inttypes
configure.ac:
gl_FUNC_STRTOUMAX
- C99 strto* protos, Derek R. Price, 2006/04/10
- Re: C99 strto* protos, Paul Eggert, 2006/04/10
- Re: C99 strto* protos,
Derek R. Price <=
- Re: C99 strto* protos, Derek R. Price, 2006/04/18
- Re: C99 strto* protos, Paul Eggert, 2006/04/19
- Re: C99 strto* protos, Derek R. Price, 2006/04/19
- Re: C99 strto* protos, Paul Eggert, 2006/04/19
- Re: C99 strto* protos, Derek R. Price, 2006/04/19
- Re: C99 strto* protos, Derek R. Price, 2006/04/19
- Re: C99 strto* protos, Derek R. Price, 2006/04/21
- Re: C99 strto* protos, Eric Blake, 2006/04/19
- Re: C99 strto* protos, Derek R. Price, 2006/04/19