Skip to content

Commit

Permalink
Fixed sig fault 11 with command line parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Carter authored and Simon Carter committed Sep 12, 2013
1 parent a7a11a0 commit bbd4e47
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/sta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <getopt.h>
#include <string>
#include <map>

using namespace std;

/* FLAGS */
Expand Down Expand Up @@ -169,16 +170,12 @@ void read_parameters(int argc, char **argv){
{"var", no_argument, &var_flag, 1},
{"n", no_argument, &n_flag, 1},
{"population", no_argument, &population_flag, 1},
{"sample", no_argument, &sample_flag, 1},
{"compensated", no_argument, &comp_flag, 1},
{"compensated", no_argument, &comp_flag, 1},
{0, 0, 0, 0}
};
/* getopt_long stores the option index here. */
int option_index = 0;

c = getopt_long (argc, argv, "abc:d:f:",
c = getopt_long_only (argc, argv, "",
long_options, &option_index);

/* Detect the end of the options. */
if (c == -1)
break;

Expand All @@ -193,13 +190,9 @@ void read_parameters(int argc, char **argv){
printf (" with arg %s", optarg);
printf ("\n");
break;

case '?':
/* getopt_long already printed an error message. */
break;

default:
abort ();
abort;
}
}

Expand Down Expand Up @@ -245,7 +238,6 @@ void read_parameters(int argc, char **argv){
(*opts)["mean"] = 1;
(*opts)["sd"] = 1;
}

}

int main (int argc, char **argv){
Expand Down

0 comments on commit bbd4e47

Please sign in to comment.