@@ -1839,13 +1839,6 @@ int uint64_conflict(uint_state *self) {
18391839 return self -> seen_uint && (self -> seen_sint || self -> seen_null );
18401840}
18411841
1842- static inline bool has_only_spaces (const char * str ) {
1843- while (* str != '\0' && isspace_ascii (* str )) {
1844- str ++ ;
1845- }
1846- return * str == '\0' ;
1847- }
1848-
18491842/* Copy a string without `char_to_remove` into `output`.
18501843 */
18511844static int copy_string_without_char (char output [PROCESSED_WORD_CAPACITY ],
@@ -1917,10 +1910,13 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19171910 char * endptr ;
19181911 int64_t result = strtoll (p , & endptr , 10 );
19191912
1913+ // Skip trailing spaces.
1914+ while (isspace_ascii (* endptr )) {
1915+ ++ endptr ;
1916+ }
1917+
19201918 // Did we use up all the characters?
1921- if (!has_only_spaces (endptr )) {
1922- // Check first for invalid characters because we may
1923- // want to skip integer parsing if we find one.
1919+ if (* endptr ) {
19241920 * error = ERROR_INVALID_CHARS ;
19251921 result = 0 ;
19261922 } else if (errno == ERANGE || result > int_max || result < int_min ) {
@@ -1974,8 +1970,13 @@ uint64_t str_to_uint64(uint_state *state, const char *p_item, int64_t int_max,
19741970 char * endptr ;
19751971 uint64_t result = strtoull (p , & endptr , 10 );
19761972
1973+ // Skip trailing spaces.
1974+ while (isspace_ascii (* endptr )) {
1975+ ++ endptr ;
1976+ }
1977+
19771978 // Did we use up all the characters?
1978- if (! has_only_spaces ( endptr ) ) {
1979+ if (* endptr ) {
19791980 * error = ERROR_INVALID_CHARS ;
19801981 result = 0 ;
19811982 } else if (errno == ERANGE || result > uint_max ) {
0 commit comments