From a17a8a071640cce2fa2a9bf35333e11c4da726e0 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 9 Apr 2009 08:59:27 +0000 Subject: The correct way to detect unknown parameter for getopt_long_only() is looking for '?' param, not \0. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11298 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index f54b60f03..f53484b74 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -445,7 +445,8 @@ InspIRCd::InspIRCd(int argc, char** argv) { 0, 0, 0, 0 } }; - while ((c = getopt_long_only(argc, argv, ":f:", longopts, NULL)) != -1) + int index; + while ((c = getopt_long_only(argc, argv, ":f:", longopts, &index)) != -1) { switch (c) { @@ -460,8 +461,9 @@ InspIRCd::InspIRCd(int argc, char** argv) case 0: /* getopt_long_only() set an int variable, just keep going */ break; - default: - /* Unknown parameter! DANGER, INTRUDER.... err.... yeah. */ + case '?': + /* Unknown parameter */ + printf("Uknown parameter '%s'\n", argv[index]); printf("Usage: %s [--nofork] [--nolog] [--debug] [--logfile ]\n\ [--runasroot] [--version] [--config ] [--testsuite]\n", argv[0]); Exit(EXIT_STATUS_ARGV); -- cgit v1.2.3