fixed: when reading a non-escaped space token we should check whether a delimiter was escaped or not

also a '#' was not tested
pull/4/head
Tomasz Sowa 2 years ago
parent db5e516564
commit 4119461f8e

@ -674,7 +674,7 @@ protected:
if( !is_main_object )
{
str << '{';
print_if(pretty_print, str, '\n');
print_if(pretty_print && (!value.value_object.empty() || (child_spaces && !child_spaces->empty())), str, '\n');
}
bool is_first = true;

@ -739,7 +739,7 @@ void SpaceParser::SkipWhite()
{
if( parsing_space )
{
while( IsWhite(lastc) || lastc == '#' )
while( IsWhite(lastc) || (!char_was_escaped && lastc == '#') )
{
if( lastc == '#' )
SkipLine();
@ -808,7 +808,7 @@ void SpaceParser::ReadTokenUntilDelimiter(std::wstring & token, int delimiter1,
{
token.clear();
while( lastc != -1 && lastc != '\n' && lastc != '#' && lastc != delimiter1 && lastc != delimiter2 )
while( lastc != -1 && (char_was_escaped || (lastc != '\n' && lastc != '#' && lastc != delimiter1 && lastc != delimiter2)) )
{
token += static_cast<wchar_t>(lastc);
ReadChar();
@ -860,7 +860,7 @@ void SpaceParser::ReadSpaceFieldToken(std::wstring & token)
{
token.clear();
while( lastc != -1 && (char_was_escaped || (lastc != separator && lastc != 10 && lastc != space_start)) )
while( lastc != -1 && (char_was_escaped || (lastc != separator && lastc != 10 && lastc != space_start && lastc != '#' )) )
{
token += static_cast<wchar_t>(lastc);
ReadChar();
@ -915,7 +915,10 @@ void SpaceParser::ReadMultilineTokenQuoted(std::wstring & token)
}
/*
* this method is used to read the field name (key) in an object
* or to read the space child name (used in Space format)
*/
void SpaceParser::ReadKey()
{
SkipWhite();
@ -1128,7 +1131,7 @@ int SpaceParser::ReadChar()
case 'b': lastc = 0x08; break;
case 'f': lastc = 0x0c; break;
case 'u': ReadUnicodeCodePoint(); break;
// in other cases we return the last character
// "in other cases we return the last character, so two \\ returns one \ "
}
}

Loading…
Cancel
Save