>From 022521230ffa940a5428ee2a50120dc882920b16 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 2 Apr 2021 19:50:19 +0200 Subject: [PATCH 2/7] strtol, strtoul, strtoll, strtoull: Optimize. * lib/strtol.c (GROUP_PARAM_PROTO): New macro. (INTERNAL): Define differently if !USE_NUMBER_GROUPING. (INTERNAL (strtol)): Define without 'int group' parameter if !USE_NUMBER_GROUPING. (strtol): Don't define if !USE_NUMBER_GROUPING. --- ChangeLog | 9 +++++++++ lib/strtol.c | 25 ++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bf4c58..d5b833a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2021-04-02 Bruno Haible + strtol, strtoul, strtoll, strtoull: Optimize. + * lib/strtol.c (GROUP_PARAM_PROTO): New macro. + (INTERNAL): Define differently if !USE_NUMBER_GROUPING. + (INTERNAL (strtol)): Define without 'int group' parameter if + !USE_NUMBER_GROUPING. + (strtol): Don't define if !USE_NUMBER_GROUPING. + +2021-04-02 Bruno Haible + strto*l: Don't pass invalid arguments to isspace, isalnum, toupper. * lib/strtol.c (ISSPACE, ISALPHA, TOUPPER): Cast argument to 'unsigned char' before passing it to the functions isspace(), isalpha(), diff --git a/lib/strtol.c b/lib/strtol.c index 14836d0..c30e5b4 100644 --- a/lib/strtol.c +++ b/lib/strtol.c @@ -131,6 +131,12 @@ #endif +#ifdef USE_NUMBER_GROUPING +# define GROUP_PARAM_PROTO , int group +#else +# define GROUP_PARAM_PROTO +#endif + /* We use this code also for the extended locale handling where the function gets as an additional argument the locale which has to be used. To access the values we have to redefine the _NL_CURRENT @@ -176,9 +182,13 @@ # endif #endif -#define INTERNAL(X) INTERNAL1(X) -#define INTERNAL1(X) __##X##_internal -#define WEAKNAME(X) WEAKNAME1(X) +#ifdef USE_NUMBER_GROUPING +# define INTERNAL(X) INTERNAL1(X) +# define INTERNAL1(X) __##X##_internal +# define WEAKNAME(X) WEAKNAME1(X) +#else +# define INTERNAL(X) X +#endif #ifdef USE_NUMBER_GROUPING /* This file defines a function to check for correct grouping. */ @@ -196,7 +206,7 @@ INT INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, - int base, int group LOCALE_PARAM_PROTO) + int base GROUP_PARAM_PROTO LOCALE_PARAM_PROTO) { int negative; register unsigned LONG int cutoff; @@ -379,15 +389,16 @@ noconv: return 0L; } +#ifdef USE_NUMBER_GROUPING /* External user entry point. */ - INT -#ifdef weak_function +# ifdef weak_function weak_function -#endif +# endif strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base LOCALE_PARAM_PROTO) { return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM); } +#endif -- 2.7.4