1.1 --- a/cline.c Mon Sep 19 08:11:08 2011 +0200 1.2 +++ b/cline.c Tue Sep 20 15:19:28 2011 +0200 1.3 @@ -9,6 +9,7 @@ 1.4 #include "scanner.h" 1.5 #include "settings.h" 1.6 #include "arguments.h" 1.7 +#include "stream.h" 1.8 1.9 void printHelpText() { 1.10 const char* helpText = 1.11 @@ -26,6 +27,7 @@ 1.12 "\n (separated by commas)" 1.13 "\n -r, -R - includes subdirectories" 1.14 "\n -v, --version - print out version information" 1.15 + "\n -V - turn verbose output off, print the result only" 1.16 "\n\n" 1.17 "The default call without any options is:" 1.18 "\n cline ./\n" 1.19 @@ -37,7 +39,7 @@ 1.20 } 1.21 1.22 int exit_with_version(settings_t* settings) { 1.23 - printf("cline - Version: %s", VERSION); 1.24 + printf("cline - Revision: %s", VERSION); 1.25 destroy_settings_t(settings); 1.26 return 0; 1.27 } 1.28 @@ -64,7 +66,7 @@ 1.29 1.30 for (int t = 1 ; t < argc ; t++) { 1.31 1.32 - int argflags = checkArgument(argv[t], "hsSrRmv"); 1.33 + int argflags = checkArgument(argv[t], "hsSrRmvV"); 1.34 1.35 // s, S 1.36 if ((argflags & 6) > 0) { 1.37 @@ -100,6 +102,13 @@ 1.38 if ((argflags & 64) > 0 || strcmp(argv[t], "--version") == 0) { 1.39 return exit_with_version(settings); 1.40 } 1.41 + // V 1.42 + if ((argflags & 128) > 0) { 1.43 + if (registerArgument(&checked, 128)) { 1.44 + return exit_with_help(settings, 1); 1.45 + } 1.46 + settings->verbose = false; 1.47 + } 1.48 // Path 1.49 if (argflags == 0) { 1.50 if (registerArgument(&checked, 1024)) { 1.51 @@ -109,6 +118,11 @@ 1.52 } 1.53 } 1.54 1.55 + // Configure output 1.56 + if (!settings->verbose) { 1.57 + close_stdout(); 1.58 + } 1.59 + 1.60 // Find tokens 1.61 char* finder = strtok(suffix, ","); 1.62 while (finder != NULL) { 1.63 @@ -130,20 +144,26 @@ 1.64 destroy_settings_t(settings); 1.65 1.66 // Print double line and line count 1.67 - #ifdef _WIN32 1.68 +#ifdef _WIN32 1.69 const int columns = 79; 1.70 - #else 1.71 +#else 1.72 const int columns = 80; 1.73 - #endif /* _WIN32 */ 1.74 +#endif /* _WIN32 */ 1.75 1.76 for (int t = 0 ; t < columns ; t++) { 1.77 printf("="); 1.78 } 1.79 - #ifdef _WIN32 1.80 +#ifdef _WIN32 1.81 printf("\n%73d lines\n", lines); 1.82 - #else 1.83 +#else 1.84 printf("\n%74d lines\n", lines); 1.85 - #endif /* _WIN32 */ 1.86 +#endif /* _WIN32 */ 1.87 1.88 + if (!settings->verbose) { 1.89 + reopen_stdout(); 1.90 + printf("%d", lines); 1.91 + } 1.92 + 1.93 + fflush(stdout); 1.94 return 0; 1.95 }