git-svn-id: svn://ultimatepp.org/upp/trunk@8436 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-05-12 15:07:55 +00:00
parent 75304bcf39
commit 9ffdf5e847
3 changed files with 23 additions and 15 deletions

View file

@ -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<String>& param, const char *b, const char *e);
String Expand(const char *s);
void DoFlatInclude(const String& header_path);

View file

@ -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<String>& param, const char *s, const char *e)
{
while(s < e && (byte)*s <= ' ') s++;

View file

@ -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;
}