cmLex.c : The quoted string matcher now correctly handles escaped double quotes.

This commit is contained in:
kevin 2014-01-21 22:35:24 -05:00
parent cbd1b74586
commit a8c3a33591

31
cmLex.c
View File

@ -323,19 +323,30 @@ unsigned _cmLexIdentMatcher( cmLex* p, const cmChar_t* cp, unsigned cn, const cm
unsigned _cmLexQStrMatcher( cmLex* p, const cmChar_t* cp, unsigned cn, const cmChar_t* keyStr )
{
cmChar_t qStr[]="\"";
unsigned n = strlen(qStr);
if( strncmp(qStr,cp,n) == 0 )
{
unsigned i;
if((i = _cmLexScanTo(cp+n, cn-n, qStr)) == cmInvalidIdx )
{
_cmLexError( p, kMissingEndQuoteLexRC, "Missing string end quote.");
bool escFl = false;
unsigned i = 0;
if( cp[i] != '"' )
return 0;
for(i=1; i<cn; ++i)
{
if( escFl )
{
escFl = false;
continue;
}
return n+i;
if( cp[i] == '\\' )
{
escFl = true;
continue;
}
return 0;
if( cp[i] == '"' )
return i+1;
}
return _cmLexError(p, kMissingEndQuoteLexRC, "Missing string literal end quote.");
}
unsigned _cmLexQCharMatcher( cmLex* p, const cmChar_t* cp, unsigned cn, const cmChar_t* keyStr )