File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -315,6 +315,10 @@ void OptionsParser<Options>::Parse(
315315 if (equals_index != std::string::npos)
316316 original_name += ' =' ;
317317
318+ auto missing_argument = [&]() {
319+ errors->push_back (RequiresArgumentErr (original_name));
320+ };
321+
318322 // Normalize by replacing `_` with `-` in options.
319323 for (std::string::size_type i = 2 ; i < name.size (); ++i) {
320324 if (name[i] == ' _' )
@@ -381,18 +385,20 @@ void OptionsParser<Options>::Parse(
381385 if (equals_index != std::string::npos) {
382386 value = arg.substr (equals_index + 1 );
383387 if (value.empty ()) {
384- missing_argument:
385- errors->push_back (RequiresArgumentErr (original_name));
388+ missing_argument ();
386389 break ;
387390 }
388391 } else {
389- if (args.empty ())
390- goto missing_argument;
392+ if (args.empty ()) {
393+ missing_argument ();
394+ break ;
395+ }
391396
392397 value = args.pop_first ();
393398
394399 if (!value.empty () && value[0 ] == ' -' ) {
395- goto missing_argument;
400+ missing_argument ();
401+ break ;
396402 } else {
397403 if (!value.empty () && value[0 ] == ' \\ ' && value[1 ] == ' -' )
398404 value = value.substr (1 ); // Treat \- as escaping an -.
You can’t perform that action at this time.
0 commit comments