ctype/iscntrl: correct the control character function

all the characters placed before the space on the ASCII table
and the 0x7F character (DEL) are control characters.

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-01-04 15:23:27 +08:00 committed by Xiang Xiao
parent 89406462cc
commit c8784faf3c
2 changed files with 2 additions and 2 deletions

View File

@ -143,7 +143,7 @@ int isgraph(int c);
#ifdef __cplusplus
static inline int iscntrl(int c)
{
return !isprint(c);
return c < 0x20 || c == 0x7f;
}
#else
int iscntrl(int c);

View File

@ -30,5 +30,5 @@
int iscntrl(int c)
{
return !isprint(c);
return c < 0x20 || c == 0x7f;
}