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

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