From: Fabian Fichter Date: Thu, 14 Jan 2021 19:35:59 +0000 (+0100) Subject: Remove spaces from USI option names X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=e1a81ae712d4c314906babc1fe33f702d629fab3;p=fairystockfish.git Remove spaces from USI option names USI does not allow spaces in option names: http://hgm.nubati.net/usi.html Some GUIs seem to rely on that and do not display options containing spaces, so spaces in option names are now replaced by underscores. Closes #237. --- diff --git a/src/uci.cpp b/src/uci.cpp index 6580e4d..2b0c6a4 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -112,7 +112,9 @@ namespace { if (Options.count(name)) Options[name] = value; - else if (Options["Protocol"] == "ucci" && (std::replace(name.begin(), name.end(), '_', ' '), Options.count(name))) + // UCI dialects do not allow spaces + else if ( (Options["Protocol"] == "ucci" || Options["Protocol"] == "usi") + && (std::replace(name.begin(), name.end(), '_', ' '), Options.count(name))) Options[name] = value; else sync_cout << "No such option: " << name << sync_endl; diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 21473cc..4a7820a 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -232,11 +232,13 @@ std::ostream& operator<<(std::ostream& os, const OptionsMap& om) { if (it.second.idx == idx) { const Option& o = it.second; - if (Options["Protocol"] == "ucci") + // UCI dialects do not allow spaces + if (Options["Protocol"] == "ucci" || Options["Protocol"] == "usi") { string name = it.first; std::replace(name.begin(), name.end(), ' ', '_'); - os << "\noption " << name << " type " << o.type; + // UCCI skips "name" + os << "\noption " << (Options["Protocol"] == "ucci" ? "" : "name ") << name << " type " << o.type; } else os << "\noption name " << it.first << " type " << o.type;