| 79 "\n\nExample (C without comments):" |
79 "\n\nExample (C without comments):" |
| 80 "\n cline -s .c,.h --exclude-cstyle-comments" |
80 "\n cline -s .c,.h --exclude-cstyle-comments" |
| 81 "\n"); |
81 "\n"); |
| 82 } |
82 } |
| 83 |
83 |
| 84 static int exit_with_version(settings* settings) { |
84 static int exit_with_version(settings *settings) { |
| 85 printf("cline - Version: " VERSION "\n"); |
85 printf("cline - Version: " VERSION "\n"); |
| 86 destroy_settings(settings); |
86 destroy_settings(settings); |
| 87 return 0; |
87 return 0; |
| 88 } |
88 } |
| 89 |
89 |
| 90 static int exit_with_help(settings* settings, int code) { |
90 static int exit_with_help(settings *settings, int code) { |
| 91 printf("cline - Version: " VERSION "\n"); |
91 printf("cline - Version: " VERSION "\n"); |
| 92 printHelpText(); |
92 printHelpText(); |
| 93 destroy_settings(settings); |
93 destroy_settings(settings); |
| 94 return code; |
94 return code; |
| 95 } |
95 } |
| 119 |
119 |
| 120 /* tell the string list to free the items */ |
120 /* tell the string list to free the items */ |
| 121 settings->excludeDirs->free_item = free; |
121 settings->excludeDirs->free_item = free; |
| 122 } |
122 } |
| 123 |
123 |
| 124 static const char * sepline_double = "===============================================================================\n"; |
124 static const char *sepline_double = "===============================================================================\n"; |
| 125 static const char * sepline_single = "-------------------------------------------------------------------------------\n"; |
125 static const char *sepline_single = "-------------------------------------------------------------------------------\n"; |
| 126 |
126 |
| 127 int main(int argc, char** argv) { |
127 int main(int argc, char **argv) { |
| 128 |
128 |
| 129 /* Settings */ |
129 /* Settings */ |
| 130 settings *settings = new_settings(); |
130 settings *settings = new_settings(); |
| 131 if (settings == NULL) { |
131 if (settings == NULL) { |
| 132 fprintf(stderr, "Memory allocation failed.\n"); |
132 fprintf(stderr, "Memory allocation failed.\n"); |
| 137 string_list *directories = new_string_list(); |
137 string_list *directories = new_string_list(); |
| 138 if (directories == NULL) { |
138 if (directories == NULL) { |
| 139 fprintf(stderr, "Memory allocation failed.\n"); |
139 fprintf(stderr, "Memory allocation failed.\n"); |
| 140 return 1; |
140 return 1; |
| 141 } |
141 } |
| 142 char* includeSuffix = NULL; |
142 const char *includeSuffix = NULL; |
| 143 char* excludeSuffix = NULL; |
143 const char *excludeSuffix = NULL; |
| 144 int checked = 0; |
144 int checked = 0; |
| 145 |
145 |
| 146 for (int t = 1 ; t < argc ; t++) { |
146 for (int t = 1 ; t < argc ; t++) { |
| 147 |
147 |
| 148 int argflags = checkArgument(argv[t], "hsSrRmvVbeEicdD"); |
148 int argflags = checkArgument(argv[t], "hsSrRmvVbeEicdD"); |
| 307 |
307 |
| 308 /* Normalize paths for excluded directories */ |
308 /* Normalize paths for excluded directories */ |
| 309 normalize_excluded_dirs(settings); |
309 normalize_excluded_dirs(settings); |
| 310 |
310 |
| 311 /* Scan directories */ |
311 /* Scan directories */ |
| 312 scanresult* result = new_scanresult(settings); |
312 scanresult *result = new_scanresult(settings); |
| 313 const char* result_type = settings->count_chars ? "chars" : "lines"; |
313 const char *result_type = settings->count_chars ? "chars" : "lines"; |
| 314 bool has_output = false; |
314 bool has_output = false; |
| 315 unsigned total = 0; |
315 unsigned total = 0; |
| 316 if (directories->count == 0) { |
316 if (directories->count == 0) { |
| 317 add_string(directories, "."); |
317 add_string(directories, "."); |
| 318 } |
318 } |