Skip to content

Commit

Permalink
[picolib/ctype] Fix for conflict between C/POSIX for iswdigit()
Browse files Browse the repository at this point in the history
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 : picolibc#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) <[email protected]>
  • Loading branch information
Ahmed Shehab (Si-Vision) committed Nov 5, 2024
1 parent 4e2fa5b commit 30ad7f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 0 additions & 4 deletions newlib/libc/ctype/iswalnum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 9 additions & 0 deletions newlib/libc/ctype/iswdigit_l.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ Copyright (c) 2016 Corinna Vinschen <[email protected]>
Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling
*/
#define _DEFAULT_SOURCE
#include <ctype.h>
#include <wctype.h>
#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 */
}

0 comments on commit 30ad7f5

Please sign in to comment.