Skip to content

Commit 1f7ef05

Browse files
vnlitvinovjreback
authored andcommitted
Safe version of ascii macros, add missing tolower_ascii (#25836)
* Safer version of ascii macros in portable.h * Add missing tolower_ascii macro needed by lowercase() in parse_helper.h
1 parent f2bcb9f commit 1f7ef05

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/_libs/src/headers/portable.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
// GH-23516 - works around locale perf issues
99
// from MUSL libc, MIT Licensed - see LICENSES
10-
#define isdigit_ascii(c) ((unsigned)c - '0' < 10)
11-
#define isspace_ascii(c) (c == ' ' || (unsigned)c-'\t' < 5)
12-
#define toupper_ascii(c) (((unsigned)c-'a' < 26) ? (c & 0x5f) : c)
10+
#define isdigit_ascii(c) (((unsigned)(c) - '0') < 10u)
11+
#define isspace_ascii(c) (((c) == ' ') || (((unsigned)(c) - '\t') < 5))
12+
#define toupper_ascii(c) ((((unsigned)(c) - 'a') < 26) ? ((c) & 0x5f) : (c))
13+
#define tolower_ascii(c) ((((unsigned)(c) - 'A') < 26) ? ((c) | 0x20) : (c))
1314

1415
#endif

0 commit comments

Comments
 (0)