From f5d0fe9681b8f9759beaf1c56fbc3734b9de4be1 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 13 Nov 2015 08:14:05 +0100 Subject: [PATCH] conf parsing: do not truncate lines. Fixes GUI not displaying results with paths longer than around 1000 characters --- src/utils/conftree.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/utils/conftree.cpp b/src/utils/conftree.cpp index 71f336ec..982dfe34 100644 --- a/src/utils/conftree.cpp +++ b/src/utils/conftree.cpp @@ -41,19 +41,19 @@ using namespace std; #define LOGDEB(X) #endif -#define LL 1024 void ConfSimple::parseinput(istream &input) { string submapkey; - char cline[LL]; + string cline; bool appending = false; string line; bool eof = false; for (;;) { - cline[0] = 0; - input.getline(cline, LL-1); - LOGDEB((stderr, "Parse:line: [%s] status %d\n", cline, int(status))); + cline.clear(); + std::getline(input, cline); + LOGDEB((stderr, "Parse:line: [%s] status %d\n", + cline.c_str(), int(status))); if (!input.good()) { if (input.bad()) { LOGDEB((stderr, "Parse: input.bad()\n")); @@ -68,10 +68,11 @@ void ConfSimple::parseinput(istream &input) } { - size_t ll = strlen(cline); - while (ll > 0 && (cline[ll-1] == '\n' || cline[ll-1] == '\r')) { - cline[ll-1] = 0; - ll--; + string::size_type pos = cline.find_last_not_of("\n\r"); + if (pos == string::npos) { + cline.clear(); + } else if (pos != cline.length()-1) { + cline.erase(pos+1); } }