New module 'atoll'.
authorBruno Haible <bruno@clisp.org>
Sun, 19 Oct 2008 17:11:37 +0000 (19:11 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 19 Oct 2008 17:11:37 +0000 (19:11 +0200)
ChangeLog
doc/posix-functions/atoll.texi
lib/atoll.c [new file with mode: 0644]
lib/stdlib.in.h
m4/atoll.m4 [new file with mode: 0644]
m4/stdlib_h.m4
modules/atoll [new file with mode: 0644]
modules/stdlib

index f448b43..f44d874 100644 (file)
--- 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.
index 5590715..75b2ce8 100644 (file)
@@ -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 (file)
index 0000000..89ef25b
--- /dev/null
@@ -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);
+}
index 5e04b1e..c5615b0 100644 (file)
@@ -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 (file)
index 0000000..aa8a0d9
--- /dev/null
@@ -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], [
+  :
+])
index 46078fe..838c5b6 100644 (file)
@@ -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 (file)
index 0000000..5f05712
--- /dev/null
@@ -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
+
index 169d883..78b64d0 100644 (file)
@@ -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' \