From eba0bbe503d247c988a943cd4102b8d3249aad55 Mon Sep 17 00:00:00 2001 From: Jean-Marc Date: Sat, 12 Sep 2015 18:05:08 +0200 Subject: [PATCH] Fix unreachable code Coverity issues 23292 and 23297. --- src/support/lstrings.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp index 3a081a7701..5e68b755d0 100644 --- a/src/support/lstrings.cpp +++ b/src/support/lstrings.cpp @@ -1074,18 +1074,20 @@ String const doSplit(String const & a, String & piece, Char delim) size_t i = a.find(delim); if (i == a.length() - 1) { piece = a.substr(0, i); - } else if (i != String::npos) { - piece = a.substr(0, i); - tmp = a.substr(i + 1); } else if (i == 0) { piece.erase(); tmp = a.substr(i + 1); + } else if (i != String::npos) { + piece = a.substr(0, i); + tmp = a.substr(i + 1); } else { piece = a; } return tmp; } + +// FIXME: why is this specialization needed? template inline docstring const doSplit(docstring const & a, docstring & piece, Char delim) { @@ -1093,12 +1095,12 @@ docstring const doSplit(docstring const & a, docstring & piece, Char delim) size_t i = a.find(delim); if (i == a.length() - 1) { piece = a.substr(0, i); - } else if (i != docstring::npos) { - piece = a.substr(0, i); - tmp = a.substr(i + 1); } else if (i == 0) { piece.erase(); tmp = a.substr(i + 1); + } else if (i != docstring::npos) { + piece = a.substr(0, i); + tmp = a.substr(i + 1); } else { piece = a; }