From: Maxim Mamontov Date: Thu, 29 May 2014 20:15:19 +0000 (+0300) Subject: Fixed processing of coma-separated lists. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/e8755e448558202feb64092ef8b1d91569ecc7db?hp=d38cb3c850bd206ed40410c8cba241094ab90833 Fixed processing of coma-separated lists. --- 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