From cf988ebad3b2a43466794d7d52789e3a366f6c6b 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. Change-Id: Id187b39ce50b80e9ebee85a7242716eb017575d7 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 b76ea42ca1e..75e7a77dbfb 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 410377b193e..7f8c44ae06b 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; }