From ea8e68ab680ff3f6d7fe933d63c6ab5b327c5eb4 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 12 May 2015 15:07:55 +0000 Subject: [PATCH] .cpp git-svn-id: svn://ultimatepp.org/upp/trunk@8436 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CppBase/CppBase.h | 3 ++- uppsrc/CppBase/cpp.cpp | 13 ------------- uppsrc/CppBase/ppfile.cpp | 22 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/uppsrc/CppBase/CppBase.h b/uppsrc/CppBase/CppBase.h index aba90ddf8..b14572b61 100644 --- a/uppsrc/CppBase/CppBase.h +++ b/uppsrc/CppBase/CppBase.h @@ -8,6 +8,8 @@ NAMESPACE_UPP bool IsCPPFile(const String& file); bool IsHFile(const String& path); +const char *SkipString(const char *s); + void RemoveComments(String& l, bool& incomment); void LoadPPConfig(const String& json); @@ -122,7 +124,6 @@ struct Cpp { void Define(const char *s); - static const char *SkipString(const char *s); void ParamAdd(Vector& param, const char *b, const char *e); String Expand(const char *s); void DoFlatInclude(const String& header_path); diff --git a/uppsrc/CppBase/cpp.cpp b/uppsrc/CppBase/cpp.cpp index 65786bd38..49c28edca 100644 --- a/uppsrc/CppBase/cpp.cpp +++ b/uppsrc/CppBase/cpp.cpp @@ -5,19 +5,6 @@ NAMESPACE_UPP #define LTIMING(x) RTIMING(x) #define LLOG(x) // DLOG(x) -const char *Cpp::SkipString(const char *s) -{ - CParser p(s); - try { - p.ReadOneString(*s); - } - catch(CParser::Error) {} - s = p.GetPtr(); - while((byte)*(s - 1) <= ' ') - s--; - return s; -} - void Cpp::ParamAdd(Vector& param, const char *s, const char *e) { while(s < e && (byte)*s <= ' ') s++; diff --git a/uppsrc/CppBase/ppfile.cpp b/uppsrc/CppBase/ppfile.cpp index ff42d6c58..cab9f0c27 100644 --- a/uppsrc/CppBase/ppfile.cpp +++ b/uppsrc/CppBase/ppfile.cpp @@ -22,6 +22,19 @@ void SetSpaces(String& l, int pos, int count) l = s; } +const char *SkipString(const char *s) +{ + CParser p(s); + try { + p.ReadOneString(*s); + } + catch(CParser::Error) {} + s = p.GetPtr(); + while((byte)*(s - 1) <= ' ') + s--; + return s; +} + void RemoveComments(String& l, bool& incomment) { int q = -1; @@ -29,7 +42,14 @@ void RemoveComments(String& l, bool& incomment) if(incomment) q = w = 0; else { - q = l.Find("/*"); + const char *s = l; + while(*s) { + if(*s == '\"') + s = SkipString(s); + else + if(s[0] == '/' && s[1] == '*') + q = int(s - ~l); + } if(q >= 0) w = q + 2; }