@@ -254,6 +254,10 @@ DControllerBase::parseArgs(int argc, char* argv[]) {
254254 opterr = 0 ;
255255 optind = 1 ;
256256 std::string opts (" dvVWc:t:" + getCustomOpts ());
257+
258+ // Defer exhausting of arguments to the end.
259+ ExhaustOptions e (argc, argv, opts);
260+
257261 while ((ch = getopt (argc, argv, opts.c_str ())) != -1 ) {
258262 switch (ch) {
259263 case ' d' :
@@ -297,10 +301,6 @@ DControllerBase::parseArgs(int argc, char* argv[]) {
297301 char const saved_optopt (optopt);
298302 std::string const saved_optarg (optarg ? optarg : std::string ());
299303
300- // Exhaust all remaining options in case parseArgs() is called again.
301- while (getopt (argc, argv, opts.c_str ()) != -1 ) {
302- }
303-
304304 // We hit an invalid option.
305305 isc_throw (InvalidUsage, " unsupported option: -" << saved_optopt <<
306306 (saved_optarg.empty () ? std::string () : " " + saved_optarg));
@@ -314,10 +314,6 @@ DControllerBase::parseArgs(int argc, char* argv[]) {
314314 char const saved_optopt (optopt);
315315 std::string const saved_optarg (optarg ? optarg : std::string ());
316316
317- // Exhaust all remaining options in case parseArgs() is called again.
318- while (getopt (argc, argv, opts.c_str ()) != -1 ) {
319- }
320-
321317 // We hit an invalid option.
322318 isc_throw (InvalidUsage, " unsupported option: -" << saved_optopt <<
323319 (saved_optarg.empty () ? std::string () : " " + saved_optarg));
0 commit comments