Skip to content

iscntrl() broken? #56

@th-otto

Description

@th-otto

I ever wondered about the strange extra code for iscntrl() in ctype.h. I explicitly returns 0 for EOF(-1), and 1 for 255.

But i think that is wrong. In all environments where i tested it, only characters 0-31 and 127 return != for iscntrl, and in all cases both -1 and 255 return 0.

And there is also room for optimizations. Even if we want to keep the current behaviour, we do not need to explicitly check the 255 case. The same effect can be achieved by setting myctype[255] to zero. It would also by possible to get rid of the extra access through the _ctype pointer, and to make the array(s) unsigned char instead of int in order to save some space, essentially implementing it similar to libcmini.

Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions