6:be923400164c | 7:1b55f3fa52c9 |
---|---|
63 "\n (separated by commas)" | 63 "\n (separated by commas)" |
64 "\n -r, -R - includes subdirectories" | 64 "\n -r, -R - includes subdirectories" |
65 "\n\n" | 65 "\n\n" |
66 "The default call without any options is:" | 66 "The default call without any options is:" |
67 "\n %s ./\n" | 67 "\n %s ./\n" |
68 "That means each file in each subdirectory is counted. If you want to count" | 68 "So each file in the working directory is counted. If you want to count C" |
69 "\nC source code in your working directory and its subdirectories, type:" | 69 "\nsource code in your working directory and its subdirectories, type:" |
70 "\n %s -rs .c\n"; | 70 "\n %s -rs .c\n"; |
71 | 71 |
72 printf(helpText, prgName, prgName, prgName, prgName); | 72 printf(helpText, prgName, prgName, prgName, prgName); |
73 } | 73 } |
74 | 74 |
88 prgName = argv[0]; | 88 prgName = argv[0]; |
89 } else { | 89 } else { |
90 prgName++; | 90 prgName++; |
91 } | 91 } |
92 | 92 |
93 // Defaults | |
94 char* _suffix = " "; | |
95 char _directory[3]; | |
96 _directory[0] = '.'; | |
97 _directory[1] = settings->fileSeparator; | |
98 _directory[2] = 0; | |
99 | |
100 // Get arguments | 93 // Get arguments |
101 char* directory; | 94 char* directory = "./"; |
102 char* suffix; | 95 char* suffix = " "; |
103 bool showHelp = false; | 96 bool showHelp = false; |
104 char checked = 0; | 97 char checked = 0; |
105 | 98 |
106 for (int t = 1 ; t < argc ; t++) { | 99 for (int t = 1 ; t < argc ; t++) { |
107 | 100 |
185 // Show help and quit | 178 // Show help and quit |
186 if (showHelp) { | 179 if (showHelp) { |
187 printHelpText(prgName); | 180 printHelpText(prgName); |
188 destroy_settings_t(settings); | 181 destroy_settings_t(settings); |
189 return 0; | 182 return 0; |
190 } | |
191 | |
192 // Default values | |
193 if ((checked & 1) == 0) { | |
194 suffix = _suffix; | |
195 } | |
196 | |
197 if ((checked & 8) == 0) { | |
198 directory = _directory; | |
199 } | 183 } |
200 | 184 |
201 // Find tokens | 185 // Find tokens |
202 char* finder = strtok(suffix, ","); | 186 char* finder = strtok(suffix, ","); |
203 while (finder != NULL) { | 187 while (finder != NULL) { |
214 } | 198 } |
215 | 199 |
216 // Scan directory | 200 // Scan directory |
217 int lines = scanDirectory(dir, 0, directory, settings); | 201 int lines = scanDirectory(dir, 0, directory, settings); |
218 closedir(dir); | 202 closedir(dir); |
203 destroy_settings_t(settings); | |
219 | 204 |
220 // Print double line and line count | 205 // Print double line and line count |
221 #ifdef _WIN32 | 206 #ifdef _WIN32 |
222 const int columns = 79; | 207 const int columns = 79; |
223 #else | 208 #else |
231 printf("\n%73d lines\n", lines); | 216 printf("\n%73d lines\n", lines); |
232 #else | 217 #else |
233 printf("\n%74d lines\n", lines); | 218 printf("\n%74d lines\n", lines); |
234 #endif /* _WIN32 */ | 219 #endif /* _WIN32 */ |
235 | 220 |
236 destroy_settings_t(settings); | |
237 | |
238 return 0; | 221 return 0; |
239 } | 222 } |