Skip to content

Warning for ctype.h misuse #9882

@jsonn

Description

@jsonn
Bugzilla Link 9510
Version trunk
OS Linux

Extended Description

One of the most often misused APIs in C is ctype.h. A lot of programmers don't understand the value range of the functions and the following code fragments are seen over and over again:

char c;
isalpha(c);

isalpha((int)c); // Attempt to pacify the compiler warning on some systems

Correct usage is:
isalpha((unsigned char)c)
if EOF can be ruled out. Above is valid only if a check for ASCII was done before (e.g. with isascii).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions