1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 17:25:06 +00:00

Everywhere: Replace ctype.h to avoid narrowing conversions

This replaces ctype.h with CharacterType.h everywhere I could find
issues with narrowing conversions. While using it will probably make
sense almost everywhere in the future, the most critical places should
have been addressed.
This commit is contained in:
Max Wipfli 2021-06-01 21:18:08 +02:00 committed by Andreas Kling
parent 1c9d87c455
commit bc8d16ad28
16 changed files with 153 additions and 266 deletions

View file

@ -7,6 +7,7 @@
#include "Shell.h"
#include "Execution.h"
#include "Formatter.h"
#include <AK/CharacterTypes.h>
#include <AK/Debug.h>
#include <AK/Function.h>
#include <AK/LexicalPath.h>
@ -1188,10 +1189,8 @@ Shell::SpecialCharacterEscapeMode Shell::special_character_escape_mode(u32 code_
return SpecialCharacterEscapeMode::QuotedAsEscape;
default:
// FIXME: Should instead use unicode's "graphic" property (categories L, M, N, P, S, Zs)
if (code_point < NumericLimits<i32>::max()) {
if (isascii(static_cast<i32>(code_point)))
return isprint(static_cast<i32>(code_point)) ? SpecialCharacterEscapeMode::Untouched : SpecialCharacterEscapeMode::QuotedAsHex;
}
if (is_ascii(code_point))
return is_ascii_printable(code_point) ? SpecialCharacterEscapeMode::Untouched : SpecialCharacterEscapeMode::QuotedAsHex;
return SpecialCharacterEscapeMode::Untouched;
}
}