From c8784faf3c7e74336554b873f502443cc6b04075 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Mon, 4 Jan 2021 15:23:27 +0800 Subject: [PATCH] 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 --- include/ctype.h | 2 +- libs/libc/ctype/lib_iscntrl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ctype.h b/include/ctype.h index b76ea42ca1..3beff884c6 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -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); diff --git a/libs/libc/ctype/lib_iscntrl.c b/libs/libc/ctype/lib_iscntrl.c index 410377b193..697b3d4829 100644 --- a/libs/libc/ctype/lib_iscntrl.c +++ b/libs/libc/ctype/lib_iscntrl.c @@ -30,5 +30,5 @@ int iscntrl(int c) { - return !isprint(c); + return c < 0x20 || c == 0x7f; }