mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
Userland: Allow building SerenityOS with -funsigned-char
Some of the code assumed that chars were always signed while that is not the case on ARM hosts. Also, some of the code tried to use EOF (-1) in a way similar to what fgetc() does, however instead of storing the characters in an int variable a char was used. While this seemed to work it also meant that character 0xFF would be incorrectly seen as an end-of-file. Careful reading of fgetc() reveals that fgetc() stores character data in an int where valid characters are in the range of 0-255 and the EOF value is explicitly outside of that range (usually -1).
This commit is contained in:
parent
6ab48d612a
commit
d476144565
9 changed files with 20 additions and 13 deletions
|
@ -177,7 +177,8 @@ URL URLParser::parse(Badge<URL>, StringView const& raw_input, URL const* base_ur
|
|||
size_t start_index = 0;
|
||||
size_t end_index = raw_input.length();
|
||||
for (size_t i = 0; i < raw_input.length(); ++i) {
|
||||
if (0 <= raw_input[i] && raw_input[i] <= 0x20) {
|
||||
i8 ch = raw_input[i];
|
||||
if (0 <= ch && ch <= 0x20) {
|
||||
++start_index;
|
||||
has_validation_error = true;
|
||||
} else {
|
||||
|
@ -185,7 +186,8 @@ URL URLParser::parse(Badge<URL>, StringView const& raw_input, URL const* base_ur
|
|||
}
|
||||
}
|
||||
for (ssize_t i = raw_input.length() - 1; i >= 0; --i) {
|
||||
if (0 <= raw_input[i] && raw_input[i] <= 0x20) {
|
||||
i8 ch = raw_input[i];
|
||||
if (0 <= ch && ch <= 0x20) {
|
||||
--end_index;
|
||||
has_validation_error = true;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue