[Branch,~jesse-barker/libmatrix/trunk] Rev 29: Unrecognized options were triggering verbose output. This is because the option

Message ID 20111017184912.4729.26525.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Jesse Barker Oct. 17, 2011, 6:49 p.m.
------------------------------------------------------------
revno: 29
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Mon 2011-10-17 11:46:36 -0700
message:
  Unrecognized options were triggering verbose output.  This is because the option
  parser was not detecting when getopt_long was signaling an unrecognized option
  (see comment in code for more details).
modified:
  test/options.cc


--
lp:libmatrix
https://code.launchpad.net/~jesse-barker/libmatrix/trunk

You are subscribed to branch lp:libmatrix.
To unsubscribe from this branch go to https://code.launchpad.net/~jesse-barker/libmatrix/trunk/+edit-subscription

Patch

=== modified file 'test/options.cc'
--- test/options.cc	2011-06-22 23:11:46 +0000
+++ test/options.cc	2011-10-17 18:46:36 +0000
@@ -32,6 +32,15 @@ 
     int c =  getopt_long(argc, argv, "", long_options, &option_index);
     while (c != -1) 
     {
+        // getopt_long() returns '?' and prints an "unrecognized option" error
+        // to stderr if it does not recognize an option.  Just trigger
+        // the help/usage message, stop processing and get out.
+        if (c == '?')
+        {
+            show_help_ = true;
+            break;
+        }
+
         std::string optname(long_options[option_index].name);
 
         if (optname == verbose_name_)