From 30ad7f502b436c85c89bcfa2ce951b6497803297 Mon Sep 17 00:00:00 2001 From: "Ahmed Shehab (Si-Vision)" Date: Tue, 5 Nov 2024 15:31:53 +0200 Subject: [PATCH] [picolib/ctype] Fix for conflict between C/POSIX for iswdigit() This commit is a trial fix to avoid the conflict between C & POSIX standard regarding the iswdigit() and iswdigit_l() functions as mentioned in the discussion : https://github.com/picolibc/picolibc/discussions/872 to define iswalnum to be how C defines it (iswalpha(c) || iswdigit(c)), and then define iswalnum_l to be iswalpha_l(c,l) || iswdigit_l(c, l) Signed-off-by: Ahmed Shehab (Si-Vision) --- newlib/libc/ctype/iswalnum.c | 4 ---- newlib/libc/ctype/iswdigit_l.c | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/newlib/libc/ctype/iswalnum.c b/newlib/libc/ctype/iswalnum.c index 999e8828c0..61dee823c1 100644 --- a/newlib/libc/ctype/iswalnum.c +++ b/newlib/libc/ctype/iswalnum.c @@ -70,9 +70,5 @@ No supporting OS subroutines are required. int iswalnum (wint_t c) { -#ifdef _MB_CAPABLE - return iswalnum_l (c, 0); -#else return c < (wint_t)0x100 ? isalnum (c) : 0; -#endif } diff --git a/newlib/libc/ctype/iswdigit_l.c b/newlib/libc/ctype/iswdigit_l.c index 025b5c0d68..0654d44533 100644 --- a/newlib/libc/ctype/iswdigit_l.c +++ b/newlib/libc/ctype/iswdigit_l.c @@ -3,11 +3,20 @@ Copyright (c) 2016 Corinna Vinschen Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE +#include #include +#include "local.h" +#include "categories.h" int iswdigit_l (wint_t c, struct __locale_t *locale) { (void) locale; +#ifdef _MB_CAPABLE + c = _jp2uc_l (c, locale); + enum category cat = category (c); + return cat == CAT_Nd; // Decimal_Number +#else return c >= (wint_t)'0' && c <= (wint_t)'9'; +#endif /* _MB_CAPABLE */ }