From 21456b8cdcc92d152577e5497f062a4c1d27f835 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 20 Jan 2020 10:09:58 +0100 Subject: [PATCH] BUG: verbatim token output strips type (#1497) - use os::write(token) for verbatim string to preserve its type --- src/OpenFOAM/db/IOstreams/token/tokenIO.C | 7 ++++--- src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/token/tokenIO.C b/src/OpenFOAM/db/IOstreams/token/tokenIO.C index 024c03c0bf..4c527c5497 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenIO.C +++ b/src/OpenFOAM/db/IOstreams/token/tokenIO.C @@ -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; diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C index 246686afb9..c4429222cb 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C @@ -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