cline.c

changeset 30
d642fdb6745e
parent 28
72a98cbcb9f1
child 31
27c3c1c6b768
     1.1 --- a/cline.c	Thu Feb 02 16:55:51 2012 +0100
     1.2 +++ b/cline.c	Thu Feb 09 15:56:18 2012 +0100
     1.3 @@ -75,24 +75,36 @@
     1.4  
     1.5    /* Get arguments */
     1.6    char* directory = "./";
     1.7 -  char* suffix = " ";
     1.8 +  char* includeSuffix = NULL;
     1.9 +  char* excludeSuffix = NULL;
    1.10    int checked = 0;
    1.11  
    1.12    for (int t = 1 ; t < argc ; t++) {
    1.13  
    1.14      int argflags = checkArgument(argv[t], "hsSrRmvVbeE");
    1.15 +    int paropt = 0;
    1.16  
    1.17 -    /* s, S */
    1.18 -    if ((argflags & 6) > 0) {
    1.19 -      if (registerArgument(&checked, 6)) {
    1.20 +    /* s */
    1.21 +    if ((argflags & 2) > 0) {
    1.22 +      if (!checkParamOpt(&paropt) || registerArgument(&checked, 2)) {
    1.23          return exit_with_help(settings, 1);
    1.24        }
    1.25 -      settings->includeSuffixes = (argflags & 2) > 0;
    1.26        t++;
    1.27        if (t >= argc) {
    1.28          return exit_with_help(settings, 1);
    1.29        }
    1.30 -      suffix = argv[t]; 
    1.31 +      includeSuffix = argv[t];
    1.32 +    }
    1.33 +    /* S */
    1.34 +    if ((argflags & 4) > 0) {
    1.35 +      if (!checkParamOpt(&paropt) || registerArgument(&checked, 4)) {
    1.36 +        return exit_with_help(settings, 1);
    1.37 +      }
    1.38 +      t++;
    1.39 +      if (t >= argc) {
    1.40 +        return exit_with_help(settings, 1);
    1.41 +      }
    1.42 +      excludeSuffix = argv[t];
    1.43      }
    1.44      /* h */
    1.45      if ((argflags & 1) > 0 || strcmp(argv[t], "--help") == 0) {
    1.46 @@ -125,7 +137,7 @@
    1.47      }
    1.48      /* b */
    1.49      if ((argflags & 256) > 0) {
    1.50 -      if (registerArgument(&checked, 256)) {
    1.51 +      if (!checkParamOpt(&paropt) || registerArgument(&checked, 256)) {
    1.52          return exit_with_help(settings, 1);
    1.53        }
    1.54        t++;
    1.55 @@ -146,7 +158,7 @@
    1.56      }
    1.57      /* e */
    1.58      if ((argflags & 512) > 0) {
    1.59 -      if (t + 2 >= argc) {
    1.60 +      if (!checkParamOpt(&paropt) || t + 2 >= argc) {
    1.61          return exit_with_help(settings, 1);
    1.62        }
    1.63        t++; add_string(settings->regex->pattern_list, argv[t]);
    1.64 @@ -155,7 +167,7 @@
    1.65      /* E */
    1.66      if ((argflags & 1024) > 0) {
    1.67        t++;
    1.68 -      if (t >= argc) {
    1.69 +      if (!checkParamOpt(&paropt) || t >= argc) {
    1.70          return exit_with_help(settings, 1);
    1.71        }
    1.72        add_string(settings->regex->pattern_list, argv[t]);
    1.73 @@ -176,11 +188,8 @@
    1.74    }
    1.75  
    1.76    /* Find tokens */
    1.77 -  char* finder = strtok(suffix, ",");
    1.78 -  while (finder != NULL) {
    1.79 -    add_string(settings->suffixList, finder);
    1.80 -    finder = strtok(NULL, ",");
    1.81 -  }
    1.82 +  parseCSL(includeSuffix, settings->includeSuffixes);
    1.83 +  parseCSL(excludeSuffix, settings->excludeSuffixes);
    1.84  
    1.85    /* Scan directory */
    1.86    if (regex_compile_all(settings->regex)) {

mercurial