From e8755e448558202feb64092ef8b1d91569ecc7db Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 29 May 2014 23:15:19 +0300 Subject: [PATCH 1/1] Fixed processing of coma-separated lists. --- projects/sgconf/tariffs.cpp | 2 +- projects/sgconf/users.cpp | 3 +-- stglibs/srvconf.lib/parsers/chg_user.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/projects/sgconf/tariffs.cpp b/projects/sgconf/tariffs.cpp index cf9f49c9..0c9f9751 100644 --- a/projects/sgconf/tariffs.cpp +++ b/projects/sgconf/tariffs.cpp @@ -112,7 +112,7 @@ return res; void Splice(std::vector & lhs, const std::vector & rhs) { -for (size_t i = 0; i < lhs.size(); ++i) +for (size_t i = 0; i < lhs.size() && i < rhs.size(); ++i) lhs[i].Splice(rhs[i]); } diff --git a/projects/sgconf/users.cpp b/projects/sgconf/users.cpp index e9be65a6..fe74e677 100644 --- a/projects/sgconf/users.cpp +++ b/projects/sgconf/users.cpp @@ -131,7 +131,7 @@ res = !value.empty() && value[0] == 'y'; void Splice(std::vector > & lhs, const std::vector > & rhs) { -for (size_t i = 0; i < lhs.size(); ++i) +for (size_t i = 0; i < lhs.size() && i < rhs.size(); ++i) lhs[i].splice(rhs[i]); } @@ -142,7 +142,6 @@ return value; void ConvStringList(std::string value, std::vector > & res) { -value.erase(std::remove(value.begin(), value.end(), ' '), value.end()); Splice(res, Split > >(value, ',', ConvString)); } diff --git a/stglibs/srvconf.lib/parsers/chg_user.cpp b/stglibs/srvconf.lib/parsers/chg_user.cpp index 74247c31..01361d08 100644 --- a/stglibs/srvconf.lib/parsers/chg_user.cpp +++ b/stglibs/srvconf.lib/parsers/chg_user.cpp @@ -102,7 +102,7 @@ appendResetable(stream, "ip", conf.ips); // TODO: ip -> ips if (!conf.nextTariff.empty()) stream << ""; else if (!conf.tariffName.empty()) - stream << ""; + stream << ""; appendResetable(stream, "note", MaybeEncode(conf.note)); appendResetable(stream, "name", MaybeEncode(conf.realName)); // TODO: name -> realName -- 2.44.2