Skip to content

Commit 454a98e

Browse files
Option to ignore symlinks.
1 parent 14b6624 commit 454a98e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

csloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ csloc(const char *dir, csloc_filenp *dat, size_t *sz, unsigned ops, size_t cr, c
361361
}
362362
}
363363
}
364-
else if(CSLOCSYMLINK==tps[i])
364+
else if(!CSLOC_ISNOLNK(ops)&&CSLOCSYMLINK==tps[i])
365365
{
366366
realpath(subdir, lnpath);
367367
if(apath==NULL)

csloc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
#define CSLOC_ISSORT(n)((n) & 010)
1616
#define CSLOC_ISFSIZE(n)((n) & 020)
1717
#define CSLOC_ISRSORT(n)((n) & 040)
18+
#define CSLOC_ISNOLNK(n)((n) & 0100)
1819
#define CSLOC_QUIET 1
1920
#define CSLOC_IGNDOT 2
2021
#define CSLOC_SIF 4
2122
#define CSLOC_SORT 014
2223
#define CSLOC_FSIZE 020
2324
#define CSLOC_RSORT 054
25+
#define CSLOC_NOLNK 0100
26+
2427
struct csloc_file_entry
2528
{
2629
size_t val;

main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#endif
1818
#include"csloc.h"
1919
#define VERSION_MINOR "8"
20-
#define VERSION_PATCH "3"
20+
#define VERSION_PATCH "4"
2121
int 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("-l to ignore symbolic links.");
2930
puts("-o to write output to a file instead of stdout, the next argument MUST be that file.");
3031
puts("-e to alternate colours in -s mode, making output easier to read.");
3132
puts("-n to list the number before the path in -qs mode.");
@@ -95,6 +96,9 @@ int main(int argl,char*argv[])
9596
currop = *it;
9697
switch(currop)
9798
{
99+
case'l':
100+
options |= CSLOC_NOLNK;
101+
break;
98102
case'o':
99103
ofile = 1;
100104
break;
@@ -124,7 +128,7 @@ int main(int argl,char*argv[])
124128
break;
125129
case'c':
126130
cp = it + 1;
127-
cr = strtoul(cp + 1, &numend, 10);
131+
cr = strtoul(cp, &numend, 10);
128132
it = numend - 1;
129133
break;
130134
default:

0 commit comments

Comments
 (0)