X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fconfigparser.cpp;h=7c03fe58a1ad4869c6fc8acd8704f8e7a0cf5da1;hb=6ad780e527094d5d1cb68af1ec326b58db182c80;hp=3be1ac9c53d39ce44f0a79dcd6d81defa55735f9;hpb=5267fb9d362aeb326c9e64f7171c957f76776f90;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configparser.cpp b/src/configparser.cpp index 3be1ac9c5..7c03fe58a 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -91,7 +91,7 @@ struct Parser unget(ch); } - bool kv(std::vector* items, std::set& seen) + bool kv(ConfigItems* items) { std::string key; nextword(key); @@ -173,14 +173,14 @@ struct Parser } else if (ch == '"') break; - else + else if (ch != '\r') value.push_back(ch); } - if (!seen.insert(key).second) + if (items->find(key) != items->end()) throw CoreException("Duplicate key '" + key + "' found"); - items->push_back(KeyVal(key, value)); + (*items)[key] = value; return true; } @@ -199,11 +199,10 @@ struct Parser if (name.empty()) throw CoreException("Empty tag name"); - std::vector* items; - std::set seen; + ConfigItems* items; tag = ConfigTag::create(name, current.filename, current.line, items); - while (kv(items, seen)) + while (kv(items)) { // Do nothing here (silences a GCC warning). } @@ -220,14 +219,14 @@ struct Parser } else if (name == "files") { - for(std::vector::iterator i = items->begin(); i != items->end(); i++) + for(ConfigItems::iterator i = items->begin(); i != items->end(); i++) { stack.DoReadFile(i->first, i->second, flags, false); } } else if (name == "execfiles") { - for(std::vector::iterator i = items->begin(); i != items->end(); i++) + for(ConfigItems::iterator i = items->begin(); i != items->end(); i++) { stack.DoReadFile(i->first, i->second, flags, true); } @@ -385,7 +384,7 @@ bool ParseStack::ParseFile(const std::string& path, int flags, const std::string bool ConfigTag::readString(const std::string& key, std::string& value, bool allow_lf) { - for(std::vector::iterator j = items.begin(); j != items.end(); ++j) + for(ConfigItems::iterator j = items.begin(); j != items.end(); ++j) { if(j->first != key) continue; @@ -488,7 +487,7 @@ std::string ConfigTag::getTagLocation() return src_name + ":" + ConvToStr(src_line); } -ConfigTag* ConfigTag::create(const std::string& Tag, const std::string& file, int line, std::vector*& Items) +ConfigTag* ConfigTag::create(const std::string& Tag, const std::string& file, int line, ConfigItems*& Items) { ConfigTag* rv = new ConfigTag(Tag, file, line); Items = &rv->items;