From f754b97923a9dd82b14ff6076798680dd703b5ab Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 19 Aug 2016 11:36:13 +0800 Subject: Lex - Fix BOM handling after uncodefication --- src/parse/lex.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/parse') diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp index 6e274adc..c5b5c11f 100644 --- a/src/parse/lex.cpp +++ b/src/parse/lex.cpp @@ -35,17 +35,19 @@ Lexer::Lexer(const ::std::string& filename): throw ::std::runtime_error("Unable to open file"); } // Consume the BOM - if( this->getc() == '\xef' ) + if( this->getc_byte() == '\xef' ) { - if( this->getc() != '\xbb' ) { + if( this->getc_byte() != '\xbb' ) { + throw ::std::runtime_error("Incomplete BOM - missing \\xBB in second position"); } - if( this->getc() != '\xbf' ) { + if( this->getc_byte() != '\xbf' ) { + throw ::std::runtime_error("Incomplete BOM - missing \\xBF in second position"); } m_line_ofs = 0; } else { - this->ungetc(); + m_istream.unget(); } } -- cgit v1.2.3