From 0838992dcd5a120d2b422ec734ebd52b0fdd3c7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Thu, 2 Dec 2010 04:05:35 +0000 Subject: [PATCH] ExternalSupport.cpp: fix #4398 (omit the newline in the LaTeX output behind the ExternalInset inset if the inset type is a date) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36654 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ExternalSupport.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/insets/ExternalSupport.cpp b/src/insets/ExternalSupport.cpp index aa6f51cbe9..d21c3d84ab 100644 --- a/src/insets/ExternalSupport.cpp +++ b/src/insets/ExternalSupport.cpp @@ -381,6 +381,17 @@ int writeExternal(InsetExternalParams const & params, str = substituteCommands(params, str, format); str = substituteOptions(params, str, format); + // If the template is a date, we must remove the newline at the end to + // avoid LaTeX errors like the one described in bug #4398 + if (params.templatename() == "Date") { + // depending on the OS we have either \r\n or only \n + size_t pos = str.rfind('\r'); + if (pos != string::npos) + str.erase(pos); + pos = str.rfind('\n'); + if (pos != string::npos) + str.erase(pos); + } // FIXME UNICODE os << from_utf8(str); return int(count(str.begin(), str.end(),'\n')); -- 2.39.2