]> git.stg.codes - stg.git/commitdiff
Fixed processing of coma-separated lists.
authorMaxim Mamontov <faust.madf@gmail.com>
Thu, 29 May 2014 20:15:19 +0000 (23:15 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Thu, 29 May 2014 20:15:19 +0000 (23:15 +0300)
projects/sgconf/tariffs.cpp
projects/sgconf/users.cpp
stglibs/srvconf.lib/parsers/chg_user.cpp

index cf9f49c9752d4d6a288a28563496fb9eea3e714b..0c9f97512599e0f76f0396884953464c49fc3f61 100644 (file)
@@ -112,7 +112,7 @@ return res;
 
 void Splice(std::vector<DIRPRICE_DATA_RES> & lhs, const std::vector<DIRPRICE_DATA_RES> & 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]);
 }
 
index e9be65a608b9df6815a069fd020079107fcaadb0..fe74e67795c9f448a32fb2436136a3ad0627af7b 100644 (file)
@@ -131,7 +131,7 @@ res = !value.empty() && value[0] == 'y';
 
 void Splice(std::vector<RESETABLE<std::string> > & lhs, const std::vector<RESETABLE<std::string> > & 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<RESETABLE<std::string> > & res)
 {
-value.erase(std::remove(value.begin(), value.end(), ' '), value.end());
 Splice(res, Split<std::vector<RESETABLE<std::string> > >(value, ',', ConvString));
 }
 
index 74247c3161d0ff6a714b671d5ca265c334690864..01361d08fb076312837002b95675c3204d4ae096 100644 (file)
@@ -102,7 +102,7 @@ appendResetable(stream, "ip", conf.ips); // TODO: ip -> ips
 if (!conf.nextTariff.empty())
     stream << "<tariff delayed=\"" << conf.nextTariff.data() << "\"/>";
 else if (!conf.tariffName.empty())
-    stream << "<tariff now=\"" << conf.nextTariff.data() << "\"/>";
+    stream << "<tariff now=\"" << conf.tariffName.data() << "\"/>";
 
 appendResetable(stream, "note", MaybeEncode(conf.note));
 appendResetable(stream, "name", MaybeEncode(conf.realName)); // TODO: name -> realName