cline.c

changeset 22
4508da679ffb
parent 21
91e0890464b0
child 23
778388400f7b
     1.1 --- a/cline.c	Thu Oct 20 15:21:53 2011 +0200
     1.2 +++ b/cline.c	Thu Oct 20 17:29:23 2011 +0200
     1.3 @@ -54,14 +54,14 @@
     1.4  
     1.5  int main(int argc, char** argv) {
     1.6  
     1.7 -  // Settings
     1.8 +  /* Settings */
     1.9    settings_t *settings = new_settings_t();
    1.10    if (settings == NULL) {
    1.11      fprintf(stderr, "Memory allocation failed.\n");
    1.12      return 1;
    1.13    }
    1.14  
    1.15 -  // Get arguments
    1.16 +  /* Get arguments */
    1.17    char* directory = "./";
    1.18    char* suffix = " ";
    1.19    int checked = 0;
    1.20 @@ -70,7 +70,7 @@
    1.21  
    1.22      int argflags = checkArgument(argv[t], "hsSrRmvVb");
    1.23  
    1.24 -    // s, S
    1.25 +    /* s, S */
    1.26      if ((argflags & 6) > 0) {
    1.27        if (registerArgument(&checked, 6)) {
    1.28          return exit_with_help(settings, 1);
    1.29 @@ -82,36 +82,36 @@
    1.30        }
    1.31        suffix = argv[t]; 
    1.32      }
    1.33 -    // h
    1.34 +    /* h */
    1.35      if ((argflags & 1) > 0 || strcmp(argv[t], "--help") == 0) {
    1.36        return exit_with_help(settings, 0);
    1.37      }
    1.38 -    // r, R
    1.39 +    /* r, R */
    1.40      if ((argflags & 24) > 0) {
    1.41        if (registerArgument(&checked, 24)) {
    1.42          return exit_with_help(settings, 1);
    1.43        }
    1.44        settings->recursive = true;
    1.45      }
    1.46 -    // m
    1.47 +    /* m */
    1.48      if ((argflags & 32) > 0) {
    1.49        if (registerArgument(&checked, 32)) {
    1.50          return exit_with_help(settings, 1);
    1.51        }
    1.52        settings->matchesOnly = true;
    1.53      }
    1.54 -    // v
    1.55 +    /* v */
    1.56      if ((argflags & 64) > 0 || strcmp(argv[t], "--version") == 0) {
    1.57        return exit_with_version(settings);
    1.58      }
    1.59 -    // V
    1.60 +    /* V */
    1.61      if ((argflags & 128) > 0) {
    1.62        if (registerArgument(&checked, 128)) {
    1.63          return exit_with_help(settings, 1);
    1.64        }
    1.65        settings->verbose = false;
    1.66      }
    1.67 -    // b
    1.68 +    /* b */
    1.69      if ((argflags & 256) > 0) {
    1.70        if (registerArgument(&checked, 256)) {
    1.71          return exit_with_help(settings, 1);
    1.72 @@ -132,7 +132,7 @@
    1.73          return exit_with_help(settings, 1);
    1.74        }
    1.75      }
    1.76 -    // Path
    1.77 +    /* Path */
    1.78      if (argflags == 0) {
    1.79        if (registerArgument(&checked, 1024)) {
    1.80          return exit_with_help(settings, 1);
    1.81 @@ -141,19 +141,19 @@
    1.82      }
    1.83    }
    1.84  
    1.85 -  // Configure output
    1.86 +  /* Configure output */
    1.87    if (!settings->verbose) {
    1.88      close_stdout();
    1.89    }
    1.90  
    1.91 -  // Find tokens
    1.92 +  /* Find tokens */
    1.93    char* finder = strtok(suffix, ",");
    1.94    while (finder != NULL) {
    1.95      add_string(settings->suffixList, finder);
    1.96      finder = strtok(NULL, ",");
    1.97    }
    1.98  
    1.99 -  // Open directory
   1.100 +  /* Open directory */
   1.101    DIR *dir = opendir(directory);
   1.102    if (dir == NULL) {
   1.103      perror("Operation failed");
   1.104 @@ -161,12 +161,12 @@
   1.105      return 1;
   1.106    }
   1.107  
   1.108 -  // Scan directory
   1.109 +  /* Scan directory */
   1.110    int lines = scanDirectory(dir, 0, directory, settings);
   1.111    closedir(dir);
   1.112    destroy_settings_t(settings);
   1.113  
   1.114 -  // Print double line and line count
   1.115 +  /* Print double line and line count */
   1.116    for (int t = 0 ; t < 79 ; t++) {
   1.117      printf("=");
   1.118    }

mercurial