BUG: verbatim token output strips type (#1497)

- use os::write(token) for verbatim string to preserve its type
This commit is contained in:
Mark Olesen
2020-01-20 10:09:58 +01:00
parent 5d33586864
commit 21456b8cdc
2 changed files with 10 additions and 5 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -194,12 +194,13 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& tok)
break;
case token::tokenType::STRING:
case token::tokenType::VERBATIMSTRING:
os << *tok.data_.stringPtr;
break;
case token::tokenType::VARIABLE:
// Behaviour differs according to stream type
case token::tokenType::VERBATIMSTRING:
// Different behaviour for (serial/parallel) stream type
// - preserve its type
os.write(tok);
break;

View File

@ -62,8 +62,12 @@ static inline void writeEntryIfPresent
if (eptr)
{
const token& tok = eptr->stream()[0];
os.writeKeyword(key) << tok << token::END_STATEMENT << nl;
const tokenList& toks = eptr->stream();
if (!toks.empty())
{
os.writeEntry(key, toks[0]);
}
}
}
//! \endcond