16
16
#include <sys/stat.h>
17
17
#endif
18
18
#include "csloc.h"
19
- #define VERSION_MINOR "8 "
20
- #define VERSION_PATCH "4 "
19
+ #define VERSION_MINOR "9 "
20
+ #define VERSION_PATCH "0-rc1 "
21
21
int main (int argl ,char * argv [])
22
22
{
23
23
if (argl == 1 )
@@ -26,6 +26,7 @@ int main(int argl,char*argv[])
26
26
printf ("csloc version 1.%s.%s\n" ,VERSION_MINOR ,VERSION_PATCH );
27
27
printf ("Usage: %s [OPTIONS...] FILES... [-x] [EXTENSIONS...]\nCommand line options...\n\n" , argv [0 ]);
28
28
puts ("If a file starts with '-', escape it with a \\, otherwise the first \\ of an argument is ignored." );
29
+ puts ("-y to show subtotals for each file type, this automatically enables -s." );
29
30
puts ("-l to ignore symbolic links." );
30
31
puts ("-o to write output to a file instead of stdout, the next argument MUST be that file." );
31
32
puts ("-e to alternate colours in -s mode, making output easier to read." );
@@ -107,7 +108,8 @@ int main(int argl,char*argv[])
107
108
{
108
109
case 'y' :
109
110
options |= CSLOC_SIF ;
110
- exttots = malloc (fel * sizeof (* exttots ));
111
+ if (fel != 0 )
112
+ exttots = malloc (fel * sizeof (* exttots ));
111
113
break ;
112
114
case 'l' :
113
115
options |= CSLOC_NOLNK ;
@@ -215,6 +217,11 @@ int main(int argl,char*argv[])
215
217
fprintf (ofh , "All files in %s combined have a grand total of %zu bytes.\n" ,dir ,total );
216
218
else
217
219
fprintf (ofh , "All files in %s combined have %zu source lines of code.\n" ,dir ,total );
220
+ if (exttots )
221
+ {
222
+ for (size_t j = 0 ; j < fel ; ++ j )
223
+ fprintf (ofh , "Total ending with .%s: %zu\n" , fexts [j ], exttots [j ]);
224
+ }
218
225
}
219
226
else
220
227
{
@@ -232,6 +239,8 @@ int main(int argl,char*argv[])
232
239
puts ("Specify a directory, run with no arguments for help message." );
233
240
if (fexts )
234
241
free (fexts );
242
+ if (exttots )
243
+ free (exttots );
235
244
if (ofh != stdout )
236
245
fclose (ofh );
237
246
}
0 commit comments