Fix search for option aliases in UCI dialects (#415)
authorcloudfish <13962946+cloudfish@users.noreply.github.com>
Wed, 1 Dec 2021 08:05:54 +0000 (16:05 +0800)
committerGitHub <noreply@github.com>
Wed, 1 Dec 2021 08:05:54 +0000 (09:05 +0100)
src/uci.cpp

index 1903731..73acbf7 100644 (file)
@@ -115,7 +115,7 @@ namespace {
 
     if (Options.count(name))
         Options[name] = value;
-    // UCI dialects do not allow spaces
+    // Deal with option name aliases in UCI dialects
     else if (is_valid_option(Options, name))
         Options[name] = value;
     else
@@ -568,7 +568,8 @@ bool UCI::is_valid_option(UCI::OptionsMap& options, std::string& name) {
   std::string protocol = options["Protocol"];
   for (const auto& it : options)
   {
-      if (options.key_comp()(option_name(it.first, protocol), name))
+      std::string optionName = option_name(it.first, protocol);
+      if (!options.key_comp()(optionName, name) && !options.key_comp()(name, optionName))
       {
           name = it.first;
           return true;