Skip to content

Commit 6047ae9

Browse files
Ultra quiet option.
1 parent bd71772 commit 6047ae9

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

csloc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
#define CSLOC_ISFSIZE(n)((n) & 020)
1717
#define CSLOC_ISRSORT(n)((n) & 040)
1818
#define CSLOC_ISNOLNK(n)((n) & 0100)
19+
#define CSLOC_ISUQUIET(n)((n) & 0200)
1920
#define CSLOC_QUIET 1
2021
#define CSLOC_IGNDOT 2
2122
#define CSLOC_SIF 4
2223
#define CSLOC_SORT 014
2324
#define CSLOC_FSIZE 020
2425
#define CSLOC_RSORT 054
2526
#define CSLOC_NOLNK 0100
27+
#define CSLOC_ULTRAQUIET 0201
2628

2729
struct csloc_file_entry
2830
{

main.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#endif
1818
#include"csloc.h"
1919
#define VERSION_MINOR "9"
20-
#define VERSION_PATCH "2"
20+
#define VERSION_PATCH "3"
2121
int main(int argl,char*argv[])
2222
{
2323
if(argl==1)
@@ -39,6 +39,7 @@ int main(int argl,char*argv[])
3939
puts("-h to not count files beginning with a ., such files are considered hidden on linux.");
4040
puts("-cNUM specifies that NUM non-whitespace characters are required to count as a valid line.");
4141
puts("-q to not output complete sentences.");
42+
puts("-u to not show the file names, only the numbers.");
4243
puts("-x to specify file extensions to count, without the . in the front.");
4344
puts("This option must come last, as all other args after it are considered to be in the list of file extensions.");
4445
puts("Add ! in front of an extension to forbid counting all files with that extension.");
@@ -106,6 +107,9 @@ int main(int argl,char*argv[])
106107
currop = *it;
107108
switch(currop)
108109
{
110+
case'u':
111+
options |= CSLOC_ULTRAQUIET;
112+
break;
109113
case'y':
110114
options |= CSLOC_SIF;
111115
if(fel != 0)
@@ -197,7 +201,9 @@ int main(int argl,char*argv[])
197201
fprintf(ofh, "\033\133%im", col);
198202
if(CSLOC_ISQUIET(options))
199203
{
200-
if(numfirst)
204+
if(CSLOC_ISUQUIET(options))
205+
fprintf(ofh, "%zu\n", dat[i].val);
206+
else if(numfirst)
201207
fprintf(ofh, "%zu %s\n", dat[i].val, dat[i].name);
202208
else
203209
fprintf(ofh, "%s %zu\n", dat[i].name, dat[i].val);
@@ -219,7 +225,9 @@ int main(int argl,char*argv[])
219225
}
220226
if(CSLOC_ISQUIET(options))
221227
{
222-
if(numfirst)
228+
if(CSLOC_ISUQUIET(options))
229+
fprintf(ofh, "%zu\n", total);
230+
else if(numfirst)
223231
fprintf(ofh, "%zu %s\n", total, dir);
224232
else
225233
fprintf(ofh, "%s %zu\n", dir, total);
@@ -239,7 +247,9 @@ int main(int argl,char*argv[])
239247
total = cnt_single_file(dir, cr);
240248
if(CSLOC_ISQUIET(options))
241249
{
242-
if(numfirst)
250+
if(CSLOC_ISUQUIET(options))
251+
fprintf(ofh, "%zu\n", total);
252+
else if(numfirst)
243253
fprintf(ofh, "%zu %s\n", total, dir);
244254
else
245255
fprintf(ofh, "%s %zu\n", dir, total);

0 commit comments

Comments
 (0)