diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-04-09 08:59:27 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-04-09 08:59:27 +0000 |
commit | a17a8a071640cce2fa2a9bf35333e11c4da726e0 (patch) | |
tree | 379114e49a8eb4ca3be80558af42e652facb6174 | |
parent | 014317c4d81fec979c9442d37cff80ca800bfce3 (diff) |
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
-rw-r--r-- | src/inspircd.cpp | 8 |
1 files 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 <filename>]\n\ [--runasroot] [--version] [--config <config>] [--testsuite]\n", argv[0]); Exit(EXIT_STATUS_ARGV); |