diff -r 51d6e45a7592 -r 1a2d7298bc82 cline.c --- a/cline.c Tue Aug 28 16:44:32 2012 +0200 +++ b/cline.c Tue Oct 02 10:49:25 2012 +0200 @@ -15,10 +15,10 @@ void printHelpText() { const char* helpText = "\nUsage:" - "\n cline [Options] [Directory]" - "\n cline [Options] [Directory]" + "\n cline [Options] [Directories...]" + "\n cline [Options] [Directories...]" "\n\nCounts the line terminator characters (\\n) within all" - " files in the specified\ndirectory." + " files in the specified\ndirectories." "\n\nOptions:" "\n -b - binary file heuristics level (default medium)" "\n One of: ignore low medium high" @@ -77,7 +77,11 @@ } /* Get arguments */ - char* directory = "./"; + string_list_t *directories = new_string_list_t(); + if (directories == NULL) { + fprintf(stderr, "Memory allocation failed.\n"); + return 1; + } char* includeSuffix = NULL; char* excludeSuffix = NULL; int checked = 0; @@ -186,10 +190,9 @@ add_string(settings->regex->pattern_list, "\\*/\\s*"); } /* Path */ - else if (registerArgument(&checked, 1024)) { - return exit_with_help(settings, 1); + else { + add_string(directories, argv[t]); } - directory = argv[t]; } } @@ -202,10 +205,22 @@ parseCSL(includeSuffix, settings->includeSuffixes); parseCSL(excludeSuffix, settings->excludeSuffixes); - /* Scan directory */ + /* Scan directories */ if (regex_compile_all(settings->regex)) { - int lines = scanDirectory((scanner_t){directory, 0}, settings); - destroy_settings_t(settings); + int lines = 0; + if (directories->count == 0) { + add_string(directories, "."); + } + for (int t = 0 ; t < directories->count ; t++) { + if (t > 0) { + for (int u = 0 ; u < 79 ; u++) { + printf("-"); + } + printf("\n"); + } + lines += scanDirectory((scanner_t){directories->items[t], 0}, settings); + } + destroy_string_list_t(directories); /* Print double line and line count */ for (int t = 0 ; t < 79 ; t++) { @@ -223,6 +238,7 @@ reopen_stdout(); printf("%d", lines); } + destroy_settings_t(settings); } fflush(stdout);