summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--doc/posix-functions/atoll.texi8
-rw-r--r--lib/atoll.c36
-rw-r--r--lib/stdlib.in.h15
-rw-r--r--m4/atoll.m426
-rw-r--r--m4/stdlib_h.m42
-rw-r--r--modules/atoll26
-rw-r--r--modules/stdlib4
8 files changed, 124 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index f448b43f9a..f44d874225 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2008-10-19 Bruno Haible <bruno@clisp.org>
+ New module 'atoll'.
+ * modules/atoll: New file.
+ * lib/stdlib.in.h (atoll): New declaration.
+ * lib/atoll.c: New file, from glibc with modifications.
+ * m4/atoll.m4: New file.
+ * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_ATOLL,
+ HAVE_ATOLL.
+ * modules/stdlib (Makefile.am): Substitute GNULIB_ATOLL, HAVE_ATOLL.
+ * doc/posix-functions/atoll.texi: Mention the new module.
+
+2008-10-19 Bruno Haible <bruno@clisp.org>
+
Add strtoull() declaration to <stdlib.h>.
* lib/stdlib.in.h (strtoull): New declaration.
* m4/strtoull.m4 (gl_FUNC_STRTOLL): Require gl_STDLIB_H_DEFAULTS.
diff --git a/doc/posix-functions/atoll.texi b/doc/posix-functions/atoll.texi
index 55907152c9..75b2ce88b5 100644
--- a/doc/posix-functions/atoll.texi
+++ b/doc/posix-functions/atoll.texi
@@ -4,15 +4,15 @@
POSIX specification: @url{http://www.opengroup.org/susv3xsh/atoll.html}
-Gnulib module: ---
+Gnulib module: atoll
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on some platforms:
+AIX 5.1, HP-UX 11, OSF/1 5.1, Interix 3.5.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on some platforms:
-AIX 5.1, HP-UX 11, OSF/1 5.1, Interix 3.5.
@end itemize
diff --git a/lib/atoll.c b/lib/atoll.c
new file mode 100644
index 0000000000..89ef25bedc
--- /dev/null
+++ b/lib/atoll.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1997, 1998, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library 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 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !_LIBC
+# include <config.h>
+#endif
+
+/* Specification. */
+#include <stdlib.h>
+
+#if _LIBC
+# undef atoll
+#endif
+
+
+/* Convert a string to a long long int. */
+long long int
+atoll (const char *nptr)
+{
+ return strtoll (nptr, (char **) NULL, 10);
+}
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 5e04b1e304..c5615b0390 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -108,6 +108,21 @@ extern void * calloc (size_t nmemb, size_t size);
#endif
+#if @GNULIB_ATOLL@
+# if !@HAVE_ATOLL@
+/* Parse a signed decimal integer.
+ Returns the value of the integer. Errors are not detected. */
+extern long long atoll (const char *string);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef atoll
+# define atoll(s) \
+ (GL_LINK_WARNING ("atoll is unportable - " \
+ "use gnulib module atoll for portability"), \
+ atoll (s))
+#endif
+
+
#if @GNULIB_GETLOADAVG@
# if !@HAVE_DECL_GETLOADAVG@
/* Store max(NELEM,3) load average numbers in LOADAVG[].
diff --git a/m4/atoll.m4 b/m4/atoll.m4
new file mode 100644
index 0000000000..aa8a0d97d5
--- /dev/null
+++ b/m4/atoll.m4
@@ -0,0 +1,26 @@
+# atoll.m4 serial 1
+dnl Copyright (C) 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_ATOLL],
+[
+ 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_CHECK_FUNCS([atoll])
+ if test $ac_cv_func_atoll = no; then
+ HAVE_ATOLL=0
+ AC_LIBOBJ([atoll])
+ gl_PREREQ_ATOLL
+ fi
+ fi
+])
+
+# Prerequisites of lib/atoll.c.
+AC_DEFUN([gl_PREREQ_ATOLL], [
+ :
+])
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 46078fe730..838c5b6683 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -22,6 +22,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
+ GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
@@ -34,6 +35,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX])
HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX])
diff --git a/modules/atoll b/modules/atoll
new file mode 100644
index 0000000000..5f0571293e
--- /dev/null
+++ b/modules/atoll
@@ -0,0 +1,26 @@
+Description:
+atoll() function: convert decimal string string to 'long long'.
+
+Files:
+lib/atoll.c
+m4/atoll.m4
+m4/longlong.m4
+
+Depends-on:
+strtoll
+
+configure.ac:
+gl_FUNC_ATOLL
+gl_STDLIB_MODULE_INDICATOR([atoll])
+
+Makefile.am:
+
+Include:
+<stdlib.h>
+
+License:
+LGPL
+
+Maintainer:
+all, glibc
+
diff --git a/modules/stdlib b/modules/stdlib
index 169d883bff..78b64d0d74 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -27,8 +27,9 @@ stdlib.h: stdlib.in.h
-e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
-e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
-e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
- -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
+ -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
-e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
+ -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
-e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
-e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
-e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
@@ -38,6 +39,7 @@ stdlib.h: stdlib.in.h
-e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
-e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
-e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
+ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
-e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
-e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
-e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \