Skip to content

fix cctype usage - #19379

Open
Megamouse wants to merge 2 commits into
RPCS3:masterfrom
Megamouse:isdigit
Open

fix cctype usage#19379
Megamouse wants to merge 2 commits into
RPCS3:masterfrom
Megamouse:isdigit

Conversation

@Megamouse

Copy link
Copy Markdown
Contributor

According to the documentation, we should cast to unsigned char. Anything negative is undefined behavior.

@kd-11 kd-11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The longer I use this language the more I realize why most people hate it so much. They define std::string as std::basic_string<char> then decide that string functions require cast to unsigned char instead of providing a sensible override.

@AniLeo
AniLeo requested a review from elad335 September 2, 2026 14:52
Comment thread rpcs3/Emu/Cell/Modules/cellGame.cpp Outdated
std::strlen(systemVersion.get_ptr()) == 7 &&
std::isdigit(systemVersion[0]) &&
std::isdigit(systemVersion[1]) &&
std::isdigit(static_cast<uchar>(systemVersion[0])) &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add an alternative function it to util/types.hpp
This was already "fixed" multiple times in the past, need a pernament solution.

@Megamouse Megamouse Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added cctype.hpp + unit test.

I hope none of the places actually depended on the std (<locale>) versions

@Megamouse
Megamouse force-pushed the isdigit branch 4 times, most recently from 34e0b40 to a3600c6 Compare September 2, 2026 21:18
According to the documentation, we should cast to unsigned char.
Anything negative is undefined behavior.
@RPCS3 RPCS3 deleted a comment from hhrtgr Sep 5, 2026
@RPCS3 RPCS3 deleted a comment from hhrtgr Sep 5, 2026
@RPCS3 RPCS3 deleted a comment from hhrtgr Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants