From ff94f771db6d0e5eb9990e32e42e6c149c1eac41 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 30 Jul 2015 13:47:03 +0000 Subject: [PATCH] cpp: Now supports BOM #1208 git-svn-id: svn://ultimatepp.org/upp/trunk@8772 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CppBase/Body.cpp | 5 ++--- uppsrc/CppBase/cpp.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/uppsrc/CppBase/Body.cpp b/uppsrc/CppBase/Body.cpp index 579198e6a..cca64a5ef 100644 --- a/uppsrc/CppBase/Body.cpp +++ b/uppsrc/CppBase/Body.cpp @@ -20,9 +20,8 @@ void Parser::Locals(const String& type) bool Parser::TryDecl() { // attempt to interpret code as local variable declaration for(;;) { - if(lex[0] == tk_static || lex[0] == tk_const || - lex[0] == tk_register || lex[0] == tk_volatile) - ++lex; + if(findarg(lex[0], tk_static, tk_const, tk_register, tk_volatile) >= 0) + ++lex; else if(!VCAttribute()) break; diff --git a/uppsrc/CppBase/cpp.cpp b/uppsrc/CppBase/cpp.cpp index 533cbe877..fca8c4147 100644 --- a/uppsrc/CppBase/cpp.cpp +++ b/uppsrc/CppBase/cpp.cpp @@ -234,6 +234,13 @@ void Cpp::Do(const String& sourcefile, Stream& in, const String& currentfile, bo if(get_macros) return; + if(in.Peek() == 0xef) { // Skip UTF-8 BOM + int64 pos = in.GetPos(); + in.Get(); + if(in.Get() != 0xbb || in.Get() != 0xbf) + in.Seek(pos); // Was not UTF-8 BOM after all + } + LTIMING("Expand"); incomment = false; prefix_macro.Clear();