]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - stdlib/strtol_l.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / stdlib / strtol_l.c
index 325c01cac8c907ee3b5c4a65416eb95733bf6495..5dd0091b20fef9d1497eee2f69c6f91144da7fb6 100644 (file)
@@ -1,6 +1,5 @@
 /* Convert string representing a number to integer value, using given locale.
-   Copyright (C) 1997, 2002, 2004, 2006, 2007, 2010, 2012
-   Free Software Foundation, Inc.
+   Copyright (C) 1997-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -15,9 +14,8 @@
    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.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 
 #if HAVE_CONFIG_H
@@ -26,7 +24,6 @@
 
 #ifdef _LIBC
 # define USE_NUMBER_GROUPING
-# define STDC_HEADERS
 # define HAVE_LIMITS_H
 #endif
 
@@ -44,7 +41,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <locale.h>
-#include <xlocale.h>
+#include <stdint.h>
 #include <bits/wordsize.h>
 
 #ifdef USE_NUMBER_GROUPING
 # define UCHAR_TYPE wint_t
 # define STRING_TYPE wchar_t
 # define ISSPACE(Ch) __iswspace_l ((Ch), loc)
-# define ISALPHA(Ch) __iswalpha_l ((Ch), loc)
-# define TOUPPER(Ch) __towupper_l ((Ch), loc)
+# define ISALPHA(Ch) __iswalpha_l ((Ch), _nl_C_locobj_ptr)
+# define TOUPPER(Ch) __towupper_l ((Ch), _nl_C_locobj_ptr)
 #else
 # if defined _LIBC \
    || defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
 # define UCHAR_TYPE unsigned char
 # define STRING_TYPE char
 # define ISSPACE(Ch) __isspace_l ((Ch), loc)
-# define ISALPHA(Ch) __isalpha_l ((Ch), loc)
-# define TOUPPER(Ch) __toupper_l ((Ch), loc)
+# define ISALPHA(Ch) __isalpha_l ((Ch), _nl_C_locobj_ptr)
+# define TOUPPER(Ch) __toupper_l ((Ch), _nl_C_locobj_ptr)
 #endif
 
 #define INTERNAL(X) INTERNAL1(X)
@@ -224,19 +221,15 @@ extern const unsigned char __strtol_ull_rem_tab[] attribute_hidden;
    one converted is stored in *ENDPTR.  */
 
 INT
-INTERNAL (__strtol_l) (nptr, endptr, base, group, loc)
-     const STRING_TYPE *nptr;
-     STRING_TYPE **endptr;
-     int base;
-     int group;
-     __locale_t loc;
+INTERNAL (__strtol_l) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
+                      int base, int group, locale_t loc)
 {
   int negative;
-  register unsigned LONG int cutoff;
-  register unsigned int cutlim;
-  register unsigned LONG int i;
-  register const STRING_TYPE *s;
-  register UCHAR_TYPE c;
+  unsigned LONG int cutoff;
+  unsigned int cutlim;
+  unsigned LONG int i;
+  const STRING_TYPE *s;
+  UCHAR_TYPE c;
   const STRING_TYPE *save, *end;
   int overflow;
 #ifndef USE_WIDE_CHAR
@@ -256,7 +249,7 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc)
      in the format described in <locale.h>.  */
   const char *grouping;
 
-  if (__builtin_expect (group, 0))
+  if (__glibc_unlikely (group))
     {
       grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
       if (*grouping <= 0 || *grouping == CHAR_MAX)
@@ -298,7 +291,7 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc)
   /* Skip white space.  */
   while (ISSPACE (*s))
     ++s;
-  if (__builtin_expect (*s == L_('\0'), 0))
+  if (__glibc_unlikely (*s == L_('\0')))
     goto noconv;
 
   /* Check for a sign.  */
@@ -332,7 +325,7 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc)
   if (base != 10)
     grouping = NULL;
 
-  if (__builtin_expect (grouping != NULL, 0))
+  if (__glibc_unlikely (grouping != NULL))
     {
 # ifndef USE_WIDE_CHAR
       thousands_len = strlen (thousands);
@@ -357,8 +350,8 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc)
                && (wchar_t) c != thousands
 # else
                && ({ for (cnt = 0; cnt < thousands_len; ++cnt)
-                     if (thousands[cnt] != end[cnt])
-                       break;
+                       if (thousands[cnt] != end[cnt])
+                         break;
                      cnt < thousands_len; })
 # endif
                && (!ISALPHA (c)
@@ -500,7 +493,7 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc)
     overflow = 1;
 #endif
 
-  if (__builtin_expect (overflow, 0))
+  if (__glibc_unlikely (overflow))
     {
       __set_errno (ERANGE);
 #if UNSIGNED
@@ -548,11 +541,8 @@ INT
 #ifdef weak_function
 weak_function
 #endif
-__strtol_l (nptr, endptr, base, loc)
-     const STRING_TYPE *nptr;
-     STRING_TYPE **endptr;
-     int base;
-     __locale_t loc;
+__strtol_l (const STRING_TYPE *nptr, STRING_TYPE **endptr,
+           int base, locale_t loc)
 {
   return INTERNAL (__strtol_l) (nptr, endptr, base, 0, loc);
 }