This resource has not currently been approved, and is not currently linked to from our directory of resources. It is being displayed here for preview by the author and moderators only.
6. Correction of string literal processing function.
We offer you to modify Lex::ReadStrConst() function as it is shown further. This will allow to correct two errors related to processing of separated string literals. The first error occurs while processing strings of the following kind:
const char *name = "Viva\
Core";
|
The second:
const wchar_t *str = L"begin" L"end".
|
The corrected function variant:
bool Lex::ReadStrConst(size_t top, bool isWcharStr)
{
char c;
for(;;){
c = file->Get();
if(c == '\\'){
c = file->Get();
// Support: "\"
if (c == '\r') {
c = file->Get();
if (c != '\n')
return false;
} else if(c == '\0')
return false;
}
else if(c == '"</str>'){
size_t pos = file->GetCurPos() + 1;
ptrdiff_t nline = 0;
do{
c = file->Get();
if(c == '\n')
++nline;
} while(is_blank(c) || c == '\n');
if (isWcharStr && c == 'L') {
//Support: L"123" L"456" L "789".
c = file->Get();
if(c == '"')
/* line_number += nline; */ ;
else{
file->Unget();
return false;
}
} else {
if(c == '"')
/* line_number += nline; */ ;
else{
token_len = ptrdiff_t(pos - top);
file->Rewind(pos);
return true;
}
}
}
else if(c == '\n' || c == '\0')
return false;
}
}
|