1616#include <sys/stat.h>
1717#endif
1818#include "csloc.h"
19- #define VERSION_MINOR "8 "
20- #define VERSION_PATCH "4 "
19+ #define VERSION_MINOR "9 "
20+ #define VERSION_PATCH "0-rc1 "
2121int main (int argl ,char * argv [])
2222{
2323 if (argl == 1 )
@@ -26,6 +26,7 @@ int main(int argl,char*argv[])
2626 printf ("csloc version 1.%s.%s\n" ,VERSION_MINOR ,VERSION_PATCH );
2727 printf ("Usage: %s [OPTIONS...] FILES... [-x] [EXTENSIONS...]\nCommand line options...\n\n" , argv [0 ]);
2828 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." );
2930 puts ("-l to ignore symbolic links." );
3031 puts ("-o to write output to a file instead of stdout, the next argument MUST be that file." );
3132 puts ("-e to alternate colours in -s mode, making output easier to read." );
@@ -107,7 +108,8 @@ int main(int argl,char*argv[])
107108 {
108109 case 'y' :
109110 options |= CSLOC_SIF ;
110- exttots = malloc (fel * sizeof (* exttots ));
111+ if (fel != 0 )
112+ exttots = malloc (fel * sizeof (* exttots ));
111113 break ;
112114 case 'l' :
113115 options |= CSLOC_NOLNK ;
@@ -215,6 +217,11 @@ int main(int argl,char*argv[])
215217 fprintf (ofh , "All files in %s combined have a grand total of %zu bytes.\n" ,dir ,total );
216218 else
217219 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+ }
218225 }
219226 else
220227 {
@@ -232,6 +239,8 @@ int main(int argl,char*argv[])
232239 puts ("Specify a directory, run with no arguments for help message." );
233240 if (fexts )
234241 free (fexts );
242+ if (exttots )
243+ free (exttots );
235244 if (ofh != stdout )
236245 fclose (ofh );
237246 }
0 commit comments