From d476144565c29a041b48fa21c734fd71d4508fe8 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 13 Jun 2021 09:15:00 +0200 Subject: 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). --- Userland/Libraries/LibJS/Lexer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Userland/Libraries/LibJS/Lexer.h') diff --git a/Userland/Libraries/LibJS/Lexer.h b/Userland/Libraries/LibJS/Lexer.h index 7541ff7fce..616014499a 100644 --- a/Userland/Libraries/LibJS/Lexer.h +++ b/Userland/Libraries/LibJS/Lexer.h @@ -46,6 +46,7 @@ private: size_t m_position { 0 }; Token m_current_token; char m_current_char { 0 }; + bool m_eof { false }; StringView m_filename; size_t m_line_number { 1 }; -- cgit v1.2.3