From 4a3ccab3e9ce31e18e312fa7063eadec015c2993 Mon Sep 17 00:00:00 2001 From: "Bastian M. Wojek" Date: Sat, 5 Feb 2011 18:32:12 +0000 Subject: [PATCH] Fix of the auto-header generation in msr2data for DOS-formatted output files --- src/classes/PMsr2Data.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/classes/PMsr2Data.cpp b/src/classes/PMsr2Data.cpp index 3b2cc3f8..9679114c 100644 --- a/src/classes/PMsr2Data.cpp +++ b/src/classes/PMsr2Data.cpp @@ -51,12 +51,6 @@ using namespace boost::algorithm; #include "PMsr2Data.h" -// determine the length of the linebreak string for different systems ('\r' (old) Macintosh, '\n' Unix, "\r\n" DOS) -#if defined(__MSDOS__) || defined(_MSC_VER) -#define INCR 2 -#else -#define INCR 1 -#endif /* __MSDOS__ || _MSC_VER */ //------------------------------------------------------------- /** @@ -1961,11 +1955,11 @@ int PMsr2Data::WriteOutput(const string &outfile, bool db, unsigned int withHead int size(outFile.tellg()); string s; - for (int i(INCR); i<=size; i+=INCR) { // find the last non-empty line + for (int i(1); i<=size; ++i) { // find the last non-empty line outFile.seekg(-i, ios::end); getline(outFile, s); trim(s); // remove whitespace - if (s.empty()) { + if (s.empty() || (s == "\n")) { // (s == "\n") check is for M$-systems using "\r\n" linebreaks if (i == size) { outFile.seekp(0); fHeaderWritten = false; // if the file contained only empty lines, default to writing the header