diff --git a/src/node_options-inl.h b/src/node_options-inl.h index 885cb849744205..682a1c6c47d020 100644 --- a/src/node_options-inl.h +++ b/src/node_options-inl.h @@ -315,6 +315,10 @@ void OptionsParser::Parse( if (equals_index != std::string::npos) original_name += '='; + auto missing_argument = [&]() { + errors->push_back(RequiresArgumentErr(original_name)); + }; + // Normalize by replacing `_` with `-` in options. for (std::string::size_type i = 2; i < name.size(); ++i) { if (name[i] == '_') @@ -381,18 +385,20 @@ void OptionsParser::Parse( if (equals_index != std::string::npos) { value = arg.substr(equals_index + 1); if (value.empty()) { - missing_argument: - errors->push_back(RequiresArgumentErr(original_name)); + missing_argument(); break; } } else { - if (args.empty()) - goto missing_argument; + if (args.empty()) { + missing_argument(); + break; + } value = args.pop_first(); if (!value.empty() && value[0] == '-') { - goto missing_argument; + missing_argument(); + break; } else { if (!value.empty() && value[0] == '\\' && value[1] == '-') value = value.substr(1); // Treat \- as escaping an -.