cmLex.c : The quoted string matcher now correctly handles escaped double quotes.
This commit is contained in:
parent
cbd1b74586
commit
a8c3a33591
31
cmLex.c
31
cmLex.c
@ -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] != '"' )
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
if((i = _cmLexScanTo(cp+n, cn-n, qStr)) == cmInvalidIdx )
|
|
||||||
{
|
|
||||||
_cmLexError( p, kMissingEndQuoteLexRC, "Missing string end quote.");
|
|
||||||
return 0;
|
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 )
|
unsigned _cmLexQCharMatcher( cmLex* p, const cmChar_t* cp, unsigned cn, const cmChar_t* keyStr )
|
||||||
|
Loading…
Reference in New Issue
Block a user