From f5ea941f32a4ba2b09d4726f531b18f28f87cf61 Mon Sep 17 00:00:00 2001 From: icanhasmath Date: Wed, 3 Apr 2024 18:52:40 -0500 Subject: [PATCH] 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 https://github.com/pandas-dev/pandas/commit/1f7ef05ef4e2e5b72763d8f32d79e3495c364d35 --- pandas/_libs/src/headers/portable.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/src/headers/portable.h b/pandas/_libs/src/headers/portable.h index 9ac4ebc306baa..1976addace3f3 100644 --- a/pandas/_libs/src/headers/portable.h +++ b/pandas/_libs/src/headers/portable.h @@ -7,8 +7,9 @@ // GH-23516 - works around locale perf issues // from MUSL libc, MIT Licensed - see LICENSES -#define isdigit_ascii(c) ((unsigned)c - '0' < 10) -#define isspace_ascii(c) (c == ' ' || (unsigned)c-'\t' < 5) -#define toupper_ascii(c) (((unsigned)c-'a' < 26) ? (c & 0x5f) : c) +#define isdigit_ascii(c) (((unsigned)(c) - '0') < 10u) +#define isspace_ascii(c) (((c) == ' ') || (((unsigned)(c) - '\t') < 5)) +#define toupper_ascii(c) ((((unsigned)(c) - 'a') < 26) ? ((c) & 0x5f) : (c)) +#define tolower_ascii(c) ((((unsigned)(c) - 'A') < 26) ? ((c) | 0x20) : (c)) #endif