]> git.sesse.net Git - cubemap/commitdiff
Do not segfault on unknown options.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 17 Apr 2013 18:14:59 +0000 (20:14 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 17 Apr 2013 18:14:59 +0000 (20:14 +0200)
main.cpp

index 55548bae91e832c02450a2196bf9778cea39453f..e953a8cea29d79da4579adb06a3580e989598a28 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -248,9 +248,10 @@ int main(int argc, char **argv)
                static const option long_options[] = {
                        { "state", required_argument, 0, 's' },
                        { "test-config", no_argument, 0, 't' },
                static const option long_options[] = {
                        { "state", required_argument, 0, 's' },
                        { "test-config", no_argument, 0, 't' },
+                       { 0, 0, 0, 0 }
                };
                int option_index = 0;
                };
                int option_index = 0;
-               int c = getopt_long (argc, argv, "s:t", long_options, &option_index);
+               int c = getopt_long(argc, argv, "s:t", long_options, &option_index);
      
                if (c == -1) {
                        break;
      
                if (c == -1) {
                        break;
@@ -263,7 +264,8 @@ int main(int argc, char **argv)
                        test_config = true;
                        break;
                default:
                        test_config = true;
                        break;
                default:
-                       assert(false);
+                       fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
+                       exit(1);
                }
        }
 
                }
        }