Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixe setoption behaviour. #1945

Closed
wants to merge 5 commits into from
Closed

Conversation

ContradNamiseb
Copy link
Contributor

@ContradNamiseb ContradNamiseb commented Jan 19, 2024

This pr partially fixes issue #1843

I had the changes wrongly in the uci protocol and that was pointed out to me by borg. So Moving the relevant changes to the right place in optionsparser.cc
@mooskagh
Copy link
Member

It doesn't look like the code does what you described.
And I don't think that the behaviour you described is what's needed.

setoption name a name b value 1 value 2

should set an option "a name b" to value "1 value 2"

@ContradNamiseb
Copy link
Contributor Author

Sorry meant to edit the comments not close the pr. I changed the described behavior of the code after talking with borg he recommended to keep this current changes in the pr.

@ContradNamiseb
Copy link
Contributor Author

@mooskagh this is what I originally had.

                                 const std::string& value,
                                 const std::string& context) {
   if (name.empty()) {
      throw Exception("An option name must be provided");
    } else {
        // Split the names and values by space.
        std::vector<std::string> names = SplitString(name, ' ');
        std::vector<std::string> values = SplitString(value, ' ');
        // Check that the number of names and values match
        if (names.size() != values.size()) {
            throw Exception("Mismatched number of names and values");
        }
        // Set the UCI options for each name-value pair
        for (size_t i = 0; i < names.size(); ++i) {
            const std::string& name = names[i];
            const std::string& value = values[i];
            auto option = FindOptionByUciName(name);
            if (option) {
            option->SetValue(value, GetMutableOptions(context));
            } else {
            // If name is not valid throw an error.
            throw Exception("Unknown option: " + name);
            }
        }
        return;
    }
}```

@mooskagh
Copy link
Member

It doesn't look to me that the code snippet from your latest comment does what is needed either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants