Skip to content

Commit 30ad7f5

Browse files
author
Ahmed Shehab (Si-Vision)
committed
[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 : 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]>
1 parent 4e2fa5b commit 30ad7f5

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

newlib/libc/ctype/iswalnum.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,5 @@ No supporting OS subroutines are required.
7070
int
7171
iswalnum (wint_t c)
7272
{
73-
#ifdef _MB_CAPABLE
74-
return iswalnum_l (c, 0);
75-
#else
7673
return c < (wint_t)0x100 ? isalnum (c) : 0;
77-
#endif
7874
}

newlib/libc/ctype/iswdigit_l.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@ Copyright (c) 2016 Corinna Vinschen <[email protected]>
33
Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling
44
*/
55
#define _DEFAULT_SOURCE
6+
#include <ctype.h>
67
#include <wctype.h>
8+
#include "local.h"
9+
#include "categories.h"
710

811
int
912
iswdigit_l (wint_t c, struct __locale_t *locale)
1013
{
1114
(void) locale;
15+
#ifdef _MB_CAPABLE
16+
c = _jp2uc_l (c, locale);
17+
enum category cat = category (c);
18+
return cat == CAT_Nd; // Decimal_Number
19+
#else
1220
return c >= (wint_t)'0' && c <= (wint_t)'9';
21+
#endif /* _MB_CAPABLE */
1322
}

0 commit comments

Comments
 (0)