Add strtoll() declaration to <stdlib.h>.
authorBruno Haible <bruno@clisp.org>
Sun, 19 Oct 2008 16:42:31 +0000 (18:42 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 19 Oct 2008 16:42:31 +0000 (18:42 +0200)
ChangeLog
lib/stdlib.in.h
m4/stdlib_h.m4
m4/strtoll.m4
modules/stdlib
modules/strtoll

index 1b9512b..742c0c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2008-10-19  Bruno Haible  <bruno@clisp.org>
 
+       Add strtoll() declaration to <stdlib.h>.
+       * lib/stdlib.in.h (strtoll): New declaration.
+       * m4/strtoll.m4 (gl_FUNC_STRTOLL): Require gl_STDLIB_H_DEFAULTS.
+       Set HAVE_STRTOLL.
+       * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_STRTOLL,
+       HAVE_STRTOLL.
+       * modules/strtoll (Depends-on): Add stdlib.
+       (configure.ac): Invoke gl_STDLIB_MODULE_INDICATOR.
+       * modules/stdlib (Makefile.am): Substitute GNULIB_STRTOLL, HAVE_STRTOLL.
+
+2008-10-19  Bruno Haible  <bruno@clisp.org>
+
        * modules/bcopy (Depends-on): Add strings.
        (Include): Specify <strings.h>.
 
index b721ac1..cf8cf77 100644 (file)
@@ -257,6 +257,27 @@ extern double strtod (const char *str, char **endp);
 #endif
 
 
+#if @GNULIB_STRTOLL@
+# if !@HAVE_STRTOLL@
+/* Parse a signed integer whose textual representation starts at STRING.
+   The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
+   it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
+   "0x").
+   If ENDPTR is not NULL, the address of the first byte after the integer is
+   stored in *ENDPTR.
+   Upon overflow or underflow, the return value is LLONG_MAX or LLONG_MIN,
+   respectively, and errno is set to ERANGE.  */
+extern long long strtoll (const char *string, char **endptr, int base);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtoll
+# define strtoll(s,e,b) \
+    (GL_LINK_WARNING ("strtoll is unportable - " \
+                      "use gnulib module strtoll for portability"), \
+     strtoll (s, e, b))
+#endif
+
+
 #ifdef __cplusplus
 }
 #endif
index 6f83221..b1f2c0e 100644 (file)
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 8
+# stdlib_h.m4 serial 9
 dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -30,6 +30,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   GNULIB_RPMATCH=0;       AC_SUBST([GNULIB_RPMATCH])
   GNULIB_SETENV=0;        AC_SUBST([GNULIB_SETENV])
   GNULIB_STRTOD=0;        AC_SUBST([GNULIB_STRTOD])
+  GNULIB_STRTOLL=0;       AC_SUBST([GNULIB_STRTOLL])
   GNULIB_UNSETENV=0;      AC_SUBST([GNULIB_UNSETENV])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_CALLOC_POSIX=1;    AC_SUBST([HAVE_CALLOC_POSIX])
@@ -40,6 +41,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_RPMATCH=1;         AC_SUBST([HAVE_RPMATCH])
   HAVE_SETENV=1;          AC_SUBST([HAVE_SETENV])
   HAVE_STRTOD=1;          AC_SUBST([HAVE_STRTOD])
+  HAVE_STRTOLL=1;         AC_SUBST([HAVE_STRTOLL])
   HAVE_SYS_LOADAVG_H=0;   AC_SUBST([HAVE_SYS_LOADAVG_H])
   HAVE_UNSETENV=1;        AC_SUBST([HAVE_UNSETENV])
   HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
index 53cbed2..c9b8951 100644 (file)
@@ -1,17 +1,19 @@
-# strtoll.m4 serial 4
-dnl Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+# strtoll.m4 serial 5
+dnl Copyright (C) 2002, 2004, 2006, 2008 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.
 
 AC_DEFUN([gl_FUNC_STRTOLL],
 [
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   dnl We don't need (and can't compile) the replacement strtoll
   dnl unless the type 'long long int' exists.
   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
   if test "$ac_cv_type_long_long_int" = yes; then
     AC_REPLACE_FUNCS(strtoll)
     if test $ac_cv_func_strtoll = no; then
+      HAVE_STRTOLL=0
       gl_PREREQ_STRTOLL
     fi
   fi
index f7133ac..157af21 100644 (file)
@@ -35,6 +35,7 @@ stdlib.h: stdlib.in.h
              -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
              -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
              -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
+             -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
              -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
              -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
              -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
@@ -44,6 +45,7 @@ stdlib.h: stdlib.in.h
              -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
              -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
              -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
+             -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
              -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
              -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
              -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
index a25ebfa..738c9ef 100644 (file)
@@ -7,10 +7,12 @@ m4/longlong.m4
 m4/strtoll.m4
 
 Depends-on:
+stdlib
 strtol
 
 configure.ac:
 gl_FUNC_STRTOLL
+gl_STDLIB_MODULE_INDICATOR([strtoll])
 
 Makefile.am: