File tree 1 file changed +11
-5
lines changed
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(
315
315
if (equals_index != std::string::npos)
316
316
original_name += ' =' ;
317
317
318
+ auto missing_argument = [&]() {
319
+ errors->push_back (RequiresArgumentErr (original_name));
320
+ };
321
+
318
322
// Normalize by replacing `_` with `-` in options.
319
323
for (std::string::size_type i = 2 ; i < name.size (); ++i) {
320
324
if (name[i] == ' _' )
@@ -381,18 +385,20 @@ void OptionsParser<Options>::Parse(
381
385
if (equals_index != std::string::npos) {
382
386
value = arg.substr (equals_index + 1 );
383
387
if (value.empty ()) {
384
- missing_argument:
385
- errors->push_back (RequiresArgumentErr (original_name));
388
+ missing_argument ();
386
389
break ;
387
390
}
388
391
} else {
389
- if (args.empty ())
390
- goto missing_argument;
392
+ if (args.empty ()) {
393
+ missing_argument ();
394
+ break ;
395
+ }
391
396
392
397
value = args.pop_first ();
393
398
394
399
if (!value.empty () && value[0 ] == ' -' ) {
395
- goto missing_argument;
400
+ missing_argument ();
401
+ break ;
396
402
} else {
397
403
if (!value.empty () && value[0 ] == ' \\ ' && value[1 ] == ' -' )
398
404
value = value.substr (1 ); // Treat \- as escaping an -.
You can’t perform that action at this time.
0 commit comments