bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new module 'atoll'


From: Bruno Haible
Subject: new module 'atoll'
Date: Sun, 19 Oct 2008 19:12:02 +0200
User-agent: KMail/1.5.4

This adds a module for the POSIX function 'atoll'.

2008-10-19  Bruno Haible  <address@hidden>

        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.

========================== modules/atoll ===============================
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

========================== lib/atoll.c =================================
/* 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);
}
========================== m4/atoll.m4 =================================
# 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], [
  :
])
========================================================================
--- doc/posix-functions/atoll.texi.orig 2008-10-19 19:06:31.000000000 +0200
+++ doc/posix-functions/atoll.texi      2008-10-19 14:12:53.000000000 +0200
@@ -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
address@hidden
+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
address@hidden
-This function is missing on some platforms:
-AIX 5.1, HP-UX 11, OSF/1 5.1, Interix 3.5.
 @end itemize
--- lib/stdlib.in.h.orig        2008-10-19 19:06:31.000000000 +0200
+++ lib/stdlib.in.h     2008-10-19 18:56:11.000000000 +0200
@@ -108,6 +108,21 @@
 #endif
 
 
+#if @GNULIB_ATOLL@
+# if address@hidden@
+/* 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 address@hidden@
 /* Store max(NELEM,3) load average numbers in LOADAVG[].
--- m4/stdlib_h.m4.orig 2008-10-19 19:06:31.000000000 +0200
+++ m4/stdlib_h.m4      2008-10-19 18:57:33.000000000 +0200
@@ -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])
--- modules/stdlib.orig 2008-10-19 19:06:31.000000000 +0200
+++ modules/stdlib      2008-10-19 18:58:38.000000000 +0200
@@ -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_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 @@
              -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' \





reply via email to

[Prev in Thread] Current Thread [Next in Thread]