Skip to content
Snippets Groups Projects
Commit 99211441 authored by Andreas Gattringer's avatar Andreas Gattringer
Browse files

fixed command line parsing

parent 6fa634cf
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "cats_global.h" #include "cats_global.h"
#include <string.h> #include <string.h>
#include <assert.h>
#include "command_line_options.h" #include "command_line_options.h"
#include "command_line_info.h" #include "command_line_info.h"
...@@ -91,10 +92,10 @@ struct program_options check_cats_main_arguments(int argc, char **argv) ...@@ -91,10 +92,10 @@ struct program_options check_cats_main_arguments(int argc, char **argv)
int opt; int opt;
int error = 0; int error = 0;
int option_index = 0;
// FIXME unify error messages, start with Error: // FIXME unify error messages, start with Error:
while ((opt = getopt_long(argc, argv, "qs:r:l:v:ho:", while ((opt = getopt_long(argc, argv, "qs:r:l:v:ho:",
longopts, &optind)) != -1) { longopts, &option_index)) != -1) {
bool success; bool success;
bool conversion_success; bool conversion_success;
...@@ -288,9 +289,9 @@ struct program_options check_cats_main_arguments(int argc, char **argv) ...@@ -288,9 +289,9 @@ struct program_options check_cats_main_arguments(int argc, char **argv)
exit_cats(EXIT_FAILURE); exit_cats(EXIT_FAILURE);
} }
for (int index = optind; index < argc; index++) { assert(optind < argc);
options.configuration_file = argv[index]; if (options.configuration_file == NULL && options.need_conf == true) {
break; options.configuration_file = strdup(argv[optind]);
} }
if (options.configuration_file == NULL && options.need_conf == true) { if (options.configuration_file == NULL && options.need_conf == true) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment