From b07a2a7ab375600d8c0f07bd89eb42838d3e2999 Mon Sep 17 00:00:00 2001 From: Olivier Couet <Olivier.Couet@cern.ch> Date: Fri, 2 Mar 2012 12:45:10 +0000 Subject: [PATCH] From M.Trocme: a fix to cope with DOS files (CR+LF) for non-standard ctors. git-svn-id: http://root.cern.ch/svn/root/trunk@43221 27541ba8-7e3a-0410-8455-c3a389f83636 --- hist/hist/src/TGraph.cxx | 3 +++ hist/hist/src/TGraph2D.cxx | 3 +++ hist/hist/src/TGraphErrors.cxx | 3 +++ 3 files changed, 9 insertions(+) diff --git a/hist/hist/src/TGraph.cxx b/hist/hist/src/TGraph.cxx index 13e1c75c29d..c3873e4f70d 100644 --- a/hist/hist/src/TGraph.cxx +++ b/hist/hist/src/TGraph.cxx @@ -442,6 +442,9 @@ TGraph::TGraph(const char *filename, const char *format, Option_t *option) // Looping while (std::getline(infile, line, '\n')) { + if (line[line.size() - 1] == char(13)) { // removing DOS CR character + line.erase(line.end() - 1, line.end()) ; + } if (line != "") { token = strtok(const_cast<char*>(line.c_str()), option) ; while (token != NULL && value_idx < 2) { diff --git a/hist/hist/src/TGraph2D.cxx b/hist/hist/src/TGraph2D.cxx index ebf8e74b12a..1aa59054fff 100644 --- a/hist/hist/src/TGraph2D.cxx +++ b/hist/hist/src/TGraph2D.cxx @@ -465,6 +465,9 @@ TGraph2D::TGraph2D(const char *filename, const char *format, Option_t *option) // Looping while (std::getline(infile, line, '\n')) { + if (line[line.size() - 1] == char(13)) { // removing DOS CR character + line.erase(line.end() - 1, line.end()) ; + } if (line != "") { token = strtok(const_cast<char*>(line.c_str()), option) ; while (token != NULL && value_idx < 3) { diff --git a/hist/hist/src/TGraphErrors.cxx b/hist/hist/src/TGraphErrors.cxx index 190b471ea91..631171beda4 100644 --- a/hist/hist/src/TGraphErrors.cxx +++ b/hist/hist/src/TGraphErrors.cxx @@ -319,6 +319,9 @@ TGraphErrors::TGraphErrors(const char *filename, const char *format, Option_t *o // Looping while (std::getline(infile, line, '\n')) { + if (line[line.size() - 1] == char(13)) { // removing DOS CR character + line.erase(line.end() - 1, line.end()) ; + } if (line != "") { token = strtok(const_cast<char*>(line.c_str()), option) ; while (token != NULL && value_idx < ntokensToBeSaved) { -- GitLab