Skip to content

Commit

Permalink
[ObjC] Boolean generation options support no value as "true".
Browse files Browse the repository at this point in the history
Slightly shortens what is required to enable generation options.

PiperOrigin-RevId: 493347244
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Dec 6, 2022
1 parent f1b0045 commit 7935932
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/google/protobuf/compiler/objectivec/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ namespace objectivec {
namespace {

// Convert a string with "yes"/"no" (case insensitive) to a boolean, returning
// true/false for if the input string was a valid value. If the input string is
// invalid, `result` is unchanged.
// true/false for if the input string was a valid value. The empty string is
// also treated as a true value. If the input string is invalid, `result` is
// unchanged.
bool StringToBool(const std::string& value, bool* result) {
std::string upper_value(value);
absl::AsciiStrToUpper(&upper_value);
if (upper_value == "NO") {
*result = false;
return true;
}
if (upper_value == "YES") {
if (upper_value == "YES" || upper_value.empty()) {
*result = true;
return true;
}
Expand Down

0 comments on commit 7935932

Please sign in to comment.