--- a/cline.c Thu Feb 02 16:55:51 2012 +0100 +++ b/cline.c Thu Feb 09 15:56:18 2012 +0100 @@ -75,24 +75,36 @@ /* Get arguments */ char* directory = "./"; - char* suffix = " "; + char* includeSuffix = NULL; + char* excludeSuffix = NULL; int checked = 0; for (int t = 1 ; t < argc ; t++) { int argflags = checkArgument(argv[t], "hsSrRmvVbeE"); + int paropt = 0; - /* s, S */ - if ((argflags & 6) > 0) { - if (registerArgument(&checked, 6)) { + /* s */ + if ((argflags & 2) > 0) { + if (!checkParamOpt(&paropt) || registerArgument(&checked, 2)) { return exit_with_help(settings, 1); } - settings->includeSuffixes = (argflags & 2) > 0; t++; if (t >= argc) { return exit_with_help(settings, 1); } - suffix = argv[t]; + includeSuffix = argv[t]; + } + /* S */ + if ((argflags & 4) > 0) { + if (!checkParamOpt(&paropt) || registerArgument(&checked, 4)) { + return exit_with_help(settings, 1); + } + t++; + if (t >= argc) { + return exit_with_help(settings, 1); + } + excludeSuffix = argv[t]; } /* h */ if ((argflags & 1) > 0 || strcmp(argv[t], "--help") == 0) { @@ -125,7 +137,7 @@ } /* b */ if ((argflags & 256) > 0) { - if (registerArgument(&checked, 256)) { + if (!checkParamOpt(&paropt) || registerArgument(&checked, 256)) { return exit_with_help(settings, 1); } t++; @@ -146,7 +158,7 @@ } /* e */ if ((argflags & 512) > 0) { - if (t + 2 >= argc) { + if (!checkParamOpt(&paropt) || t + 2 >= argc) { return exit_with_help(settings, 1); } t++; add_string(settings->regex->pattern_list, argv[t]); @@ -155,7 +167,7 @@ /* E */ if ((argflags & 1024) > 0) { t++; - if (t >= argc) { + if (!checkParamOpt(&paropt) || t >= argc) { return exit_with_help(settings, 1); } add_string(settings->regex->pattern_list, argv[t]); @@ -176,11 +188,8 @@ } /* Find tokens */ - char* finder = strtok(suffix, ","); - while (finder != NULL) { - add_string(settings->suffixList, finder); - finder = strtok(NULL, ","); - } + parseCSL(includeSuffix, settings->includeSuffixes); + parseCSL(excludeSuffix, settings->excludeSuffixes); /* Scan directory */ if (regex_compile_all(settings->regex)) {