Whether `char` has a sign is implementation dependent, and `c >= 0` may result in a compiler warning. We can use bitwise operator to check whether the character is a control character, regardless of the sign.
This commit is contained in:
1 parent
6d8e9f98ae
commit
70e72abea3
2 files changed
+15
-1
No files matched your search
+1
-1
@@ -493,7 +493,7 @@ static pfunc found_string(struct jv_parser* p) {
|
||||
return "Invalid escape";
|
||||
}
|
||||
} else {
|
||||
if (c >= 0 && c <= 0x001f)
|
||||
if (!(c & ~0x1F))
|
||||
return "Invalid string: control characters from U+0000 through U+001F must be escaped";
|
||||
*out++ = c;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user