From: Thomas Debesse Date: Sat, 5 May 2018 18:05:41 +0000 (+0200) Subject: do not write useless empty line at beginning of map file X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bfc92ddecf9b85030ef6bb30e45935c25802a5a7;p=xonotic%2Fnetradiant.git do not write useless empty line at beginning of map file --- diff --git a/libs/script/scripttokenwriter.h b/libs/script/scripttokenwriter.h index 49ee57af..f1c5fc31 100644 --- a/libs/script/scripttokenwriter.h +++ b/libs/script/scripttokenwriter.h @@ -28,7 +28,8 @@ class SimpleTokenWriter : public TokenWriter { public: SimpleTokenWriter( TextOutputStream& ostream ) - : m_ostream( ostream ), m_separator( '\n' ){ + // HACK: \0 separator is used to tell we are at beginning of file + : m_ostream( ostream ), m_separator( '\0' ){ } ~SimpleTokenWriter(){ writeSeparator(); @@ -63,7 +64,10 @@ void writeFloat( double f ){ private: void writeSeparator(){ - m_ostream << m_separator; + // HACK: do not write separator at beginning of file + if (m_separator != '\0') { + m_ostream << m_separator; + } m_separator = ' '; } TextOutputStream& m_ostream;