Mercurial > hg > octave-lojdl > gnulib-hg
changeset 10673:8e54ec4dc691
New module 'atoll'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 19 Oct 2008 19:11:37 +0200 |
parents | 66414a3e577c |
children | fbb2ccfb180d |
files | ChangeLog doc/posix-functions/atoll.texi lib/atoll.c lib/stdlib.in.h m4/atoll.m4 m4/stdlib_h.m4 modules/atoll modules/stdlib |
diffstat | 8 files changed, 125 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +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>.
--- 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 -@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 + +Portability problems not fixed by Gnulib: +@itemize +@end itemize
new file mode 100644 --- /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); +}
--- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -108,6 +108,21 @@ #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[].
new file mode 100644 --- /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], [ + : +])
--- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -22,6 +22,7 @@ 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 @@ 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])
new file mode 100644 --- /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 +
--- a/modules/stdlib +++ b/modules/stdlib @@ -27,8 +27,9 @@ -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_ATOLL''@|$(GNULIB_ATOLL)|g' \ + -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \ -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ - -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|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 @@ -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' \