From d739e485743a7c864bac5748f9475466172106de Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 12 Dec 2016 17:00:20 +0100 Subject: [PATCH] Fix command termination before line breaks. --- src/texstream.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/texstream.cpp b/src/texstream.cpp index 10033a9255..9f46a87db2 100644 --- a/src/texstream.cpp +++ b/src/texstream.cpp @@ -68,8 +68,8 @@ void otexstream::put(char_type const & c) protectspace_ = false; } if (terminate_command_) { - if ((c == ' ' || c == '\0') && !isprotected) - // A space follows. Terminate with brackets. + if ((c == ' ' || c == '\0' || c == '\n') && !isprotected) + // A space or line break follows. Terminate with brackets. os() << "{}"; else if (c != '\\' && c != '{' && c != '}') // Non-terminating character follows. Terminate with space. @@ -107,6 +107,8 @@ TerminateCommand termcmd; otexstream & operator<<(otexstream & ots, BreakLine) { if (ots.canBreakLine()) { + if (ots.terminateCommand()) + ots << "{}"; ots.otexrowstream::put('\n'); ots.lastChar('\n'); } @@ -120,6 +122,8 @@ otexstream & operator<<(otexstream & ots, SafeBreakLine) { otexrowstream & otrs = ots; if (ots.canBreakLine()) { + if (ots.terminateCommand()) + otrs << "{}"; otrs << "%\n"; ots.lastChar('\n'); } @@ -184,8 +188,8 @@ otexstream & operator<<(otexstream & ots, TexString ts) ots.protectSpace(false); } if (ots.terminateCommand()) { - if ((c == ' ' || c == '\0') && !isprotected) - // A space follows. Terminate with brackets. + if ((c == ' ' || c == '\0' || c == '\n') && !isprotected) + // A space or line break follows. Terminate with brackets. otrs << "{}"; else if (c != '\\' && c != '{' && c != '}') // Non-terminating character follows. Terminate with space. @@ -228,8 +232,8 @@ otexstream & operator<<(otexstream & ots, docstring const & s) ots.protectSpace(false); } if (ots.terminateCommand()) { - if ((c == ' ' || c == '\0') && !isprotected) - // A space follows. Terminate with brackets. + if ((c == ' ' || c == '\0' || c == '\n') && !isprotected) + // A space or line break follows. Terminate with brackets. otrs << "{}"; else if (c != '\\' && c != '{' && c != '}') // Non-terminating character follows. Terminate with space. -- 2.39.2