This commit is contained in:
Jean-Francois Dockes 2021-11-11 18:43:47 +01:00
parent 728129e5ce
commit a1e98c1bdc
3 changed files with 6 additions and 4 deletions

View File

@ -720,7 +720,9 @@ bool ConfSimple::commentsAsXML(ostream& out)
{ {
string::size_type pos = line.m_data.find_first_not_of("# "); string::size_type pos = line.m_data.find_first_not_of("# ");
if (pos != string::npos) { if (pos != string::npos) {
out << line.m_data.substr(pos) << endl; out << line.m_data.substr(pos) << "\n";
} else {
out << "\n";
} }
break; break;
} }

View File

@ -347,7 +347,7 @@ template void stringsToCSV<vector<string> >(const vector<string>&, string&,
#endif #endif
void stringToTokens(const string& str, vector<string>& tokens, void stringToTokens(const string& str, vector<string>& tokens,
const string& delims, bool skipinit) const string& delims, bool skipinit, bool allowempty)
{ {
string::size_type startPos = 0, pos; string::size_type startPos = 0, pos;
@ -367,7 +367,7 @@ void stringToTokens(const string& str, vector<string>& tokens,
} }
if (pos == startPos) { if (pos == startPos) {
// Dont' push empty tokens after first // Dont' push empty tokens after first
if (tokens.empty()) { if (allowempty || tokens.empty()) {
tokens.emplace_back(); tokens.emplace_back();
} }
startPos = ++pos; startPos = ++pos;

View File

@ -142,7 +142,7 @@ template <class T> void stringsToCSV(const T& tokens, std::string& s,
extern void stringToTokens(const std::string& s, extern void stringToTokens(const std::string& s,
std::vector<std::string>& tokens, std::vector<std::string>& tokens,
const std::string& delims = " \t", const std::string& delims = " \t",
bool skipinit = true); bool skipinit = true, bool allowempty = false);
/** Like toTokens but with multichar separator */ /** Like toTokens but with multichar separator */
extern void stringSplitString(const std::string& str, extern void stringSplitString(const std::string& str,