From: Bruno Haible Date: Sun, 19 Oct 2008 17:11:37 +0000 (+0200) Subject: New module 'atoll'. X-Git-Tag: v0.1~6812 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=2fbd31539f6349ef22c716a574a1a2547a4688b3;p=gnulib.git New module 'atoll'. --- diff --git a/ChangeLog b/ChangeLog index f448b43f9..f44d87422 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2008-10-19 Bruno Haible + 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 + Add strtoull() declaration to . * 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 55907152c..75b2ce88b 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 000000000..89ef25bed --- /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 +#endif + +/* Specification. */ +#include + +#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 5e04b1e30..c5615b039 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 000000000..aa8a0d97d --- /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 46078fe73..838c5b668 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 000000000..5f0571293 --- /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: + + +License: +LGPL + +Maintainer: +all, glibc + diff --git a/modules/stdlib b/modules/stdlib index 169d883bf..78b64d0d7 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' \