Skip to content

Commit 803a8bf

Browse files
committed
chore: move errno assignment
1 parent b5b8f3b commit 803a8bf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/_libs/src/parser/tokenizer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,6 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19381938
return 0;
19391939
}
19401940

1941-
errno = 0;
19421941
char buffer[PROCESSED_WORD_CAPACITY];
19431942
size_t str_len = strlen(p_item);
19441943
if (tsep != '\0' && memchr(p_item, tsep, str_len) != NULL) {
@@ -1959,6 +1958,9 @@ int64_t str_to_int64(const char *p_item, int64_t int_min, int64_t int_max,
19591958
}
19601959

19611960
char *endptr = NULL;
1961+
// strtoll sets errno if it finds an overflow.
1962+
// It's value is reset to don't pollute the verification below.
1963+
errno = 0;
19621964
int64_t result = strtoll(p_item, &endptr, 10);
19631965

19641966
if (!has_only_spaces(endptr)) {
@@ -2001,7 +2003,6 @@ uint64_t str_to_uint64(uint_state *state, const char *p_item, int64_t int_max,
20012003
return 0;
20022004
}
20032005

2004-
errno = 0;
20052006
char buffer[PROCESSED_WORD_CAPACITY];
20062007
size_t str_len = strlen(p_item);
20072008
if (tsep != '\0' && memchr(p_item, tsep, str_len) != NULL) {
@@ -2016,6 +2017,9 @@ uint64_t str_to_uint64(uint_state *state, const char *p_item, int64_t int_max,
20162017
}
20172018

20182019
char *endptr = NULL;
2020+
// strtoull sets errno if it finds an overflow.
2021+
// It's value is reset to don't pollute the verification below.
2022+
errno = 0;
20192023
uint64_t result = strtoull(p_item, &endptr, 10);
20202024

20212025
if (!has_only_spaces(endptr)) {

0 commit comments

Comments
 (0)