Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[picolib/ctype] Fix for conflict between C/POSIX for iswdigit() #22

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

A-Shehab
Copy link
Collaborator

@A-Shehab A-Shehab commented Nov 5, 2024

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)

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) <shehab@eudcodcvder0497.internal.synopsys.com>
@A-Shehab
Copy link
Collaborator Author

A-Shehab commented Nov 5, 2024

Hello @keith-packard,
Regarding this discussion here : picolibc#872

i wanted to make sure i understand this part correctly or not

So, we should 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).

If what i implemented in this draft PR is correct i encountered another issues because of it:
caused a problem with iswalpha because now in global locale some chars are not considered alpha-numerical but considered alphabetical because iswalnum doesnt call iswalnum_l in this case but iswalpha calls iswalpha_l

that drived me to change iswalpha function to not call iswalpha_l as well.

but that causes an error in iswalpha becuase in C99 7.25.2.1.2 The iswalpha function:

The iswalpha function tests for any wide character for which iswupper or
iswlower is true
, or any wide character that is one of a locale-specific set of alphabetic

and because iswupper returns true with some locale-specific characters calling iswalpha for such chars will return false because iswalpha doesnt call iswalpha_l which is not the correct behavior according to the C-standard

so i will keep getting into cascading failures like that because they mostly depend on eachother.
but that depends mainly if my implementation here is what you suggested in the first place or not.

Thank you,

@keith-packard
Copy link
Collaborator

Yeah, the whole wctype database used by picolibc appears to have significant issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants