From: Fabian Fichter Date: Fri, 5 Nov 2021 21:25:39 +0000 (+0100) Subject: Validate variants.ini syntax X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=ad1a69b975c362aa0e22dc5df97860c3098310b8;p=fairystockfish.git Validate variants.ini syntax Closes #388. --- diff --git a/src/variant.cpp b/src/variant.cpp index 5e3ca67..f6ebc5a 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -1484,8 +1484,13 @@ void VariantMap::parse_istream(std::istream& file) { while (file.peek() != '[' && std::getline(file, input)) { std::stringstream ss(input); - if (ss.peek() != '#' && std::getline(std::getline(ss, key, '=') >> std::ws, value) && !key.empty()) - attribs[key.erase(key.find_last_not_of(" ") + 1)] = value; + if (ss.peek() != ';' && ss.peek() != '#') + { + if (DoCheck && !input.empty() && input.find('=') == std::string::npos) + std::cerr << "Invalid sytax: '" << input << "'." << std::endl; + if (std::getline(std::getline(ss, key, '=') >> std::ws, value) && !key.empty()) + attribs[key.erase(key.find_last_not_of(" ") + 1)] = value; + } } // Create variant