@@ -254,6 +254,10 @@ DControllerBase::parseArgs(int argc, char* argv[]) {
254
254
opterr = 0 ;
255
255
optind = 1 ;
256
256
std::string opts (" dvVWc:t:" + getCustomOpts ());
257
+
258
+ // Defer exhausting of arguments to the end.
259
+ ExhaustOptions e (argc, argv, opts);
260
+
257
261
while ((ch = getopt (argc, argv, opts.c_str ())) != -1 ) {
258
262
switch (ch) {
259
263
case ' d' :
@@ -297,10 +301,6 @@ DControllerBase::parseArgs(int argc, char* argv[]) {
297
301
char const saved_optopt (optopt );
298
302
std::string const saved_optarg (optarg ? optarg : std::string ());
299
303
300
- // Exhaust all remaining options in case parseArgs() is called again.
301
- while (getopt (argc, argv, opts.c_str ()) != -1 ) {
302
- }
303
-
304
304
// We hit an invalid option.
305
305
isc_throw (InvalidUsage, " unsupported option: -" << saved_optopt <<
306
306
(saved_optarg.empty () ? std::string () : " " + saved_optarg));
@@ -314,10 +314,6 @@ DControllerBase::parseArgs(int argc, char* argv[]) {
314
314
char const saved_optopt (optopt );
315
315
std::string const saved_optarg (optarg ? optarg : std::string ());
316
316
317
- // Exhaust all remaining options in case parseArgs() is called again.
318
- while (getopt (argc, argv, opts.c_str ()) != -1 ) {
319
- }
320
-
321
317
// We hit an invalid option.
322
318
isc_throw (InvalidUsage, " unsupported option: -" << saved_optopt <<
323
319
(saved_optarg.empty () ? std::string () : " " + saved_optarg));
0 commit comments