strcpy(output_filename, "");
int i = 1;
- while(i < argc) {
+ int error = 0, show_help = 0;
+
+ while(!error && !show_help && i < argc) {
if(strcmp(argv[i], "-o") == 0) {
check_opt(argc, argv, i, 1, "<output filename>");
i += 5;
}
+ else if(strcmp(argv[i], "-h") == 0) {
+ show_help = 1;
+ i++;
+ }
+
else {
- cerr << "Selector version " << VERSION << "-R" << REVISION_NUMBER
- << endl
- << "Written by Francois Fleuret <francois@fleuret.org>"
- << endl
- << argv[0]
- << " [-h]"
- << " [-v]"
- << " [-m]"
- << " [-d]"
- << " [-e]"
- << " [-z]"
- << " [-i]"
- << " [-c <fg modeline> <bg modeline> <fg highlight> <bg highlight>]"
- << " [-o <output filename>]"
- << " [-s <pattern separator>]"
- << " [-l <max number of lines>]"
- << " -f <input filename>"
- << endl;
- if(strcmp(argv[i], "-h") == 0) {
- exit(0);
- } else {
- exit(1);
- }
+ cerr << "Unknown argument " << argv[i] << "." << endl;
+ error = 1;
}
}
+ if(show_help || error) {
+ cerr << "Selector version " << VERSION << "-R" << REVISION_NUMBER
+ << endl
+ << "Written by Francois Fleuret <francois@fleuret.org>"
+ << endl
+ << argv[0]
+ << " [-h]"
+ << " [-v]"
+ << " [-m]"
+ << " [-d]"
+ << " [-e]"
+ << " [-z]"
+ << " [-i]"
+ << " [-c <fg modeline> <bg modeline> <fg highlight> <bg highlight>]"
+ << " [-o <output filename>]"
+ << " [-s <pattern separator>]"
+ << " [-l <max number of lines>]"
+ << " -f <input filename>"
+ << endl;
+
+ exit(error);
+ }
+
char **lines = new char *[nb_lines_max];
if(!input_filename[0]) {