diff options
-rw-r--r-- | Makefile | 46 | ||||
-rw-r--r-- | loc.c | 2 | ||||
-rw-r--r-- | tests/0 | 0 | ||||
-rw-r--r-- | tests/1 | 1 | ||||
-rw-r--r-- | tests/10 | 2 | ||||
-rw-r--r-- | tests/11 | 1 | ||||
-rw-r--r-- | tests/12 | 1 | ||||
-rw-r--r-- | tests/13 | 2 | ||||
-rw-r--r-- | tests/14 | 1 | ||||
-rw-r--r-- | tests/15 | 1 | ||||
-rw-r--r-- | tests/16 | 1 | ||||
-rw-r--r-- | tests/17 | 1 | ||||
-rw-r--r-- | tests/18 | 1 | ||||
-rw-r--r-- | tests/19 | 1 | ||||
-rw-r--r-- | tests/2 | 1 | ||||
-rw-r--r-- | tests/20 | 1 | ||||
-rw-r--r-- | tests/21 | 1 | ||||
-rw-r--r-- | tests/22 | 1 | ||||
-rw-r--r-- | tests/23 | 1 | ||||
-rw-r--r-- | tests/24 | 1 | ||||
-rw-r--r-- | tests/25 | 3 | ||||
-rw-r--r-- | tests/26 | 3 | ||||
-rw-r--r-- | tests/27 | 3 | ||||
-rw-r--r-- | tests/28 | 3 | ||||
-rw-r--r-- | tests/29 | 3 | ||||
-rw-r--r-- | tests/3 | 3 | ||||
-rw-r--r-- | tests/30 | 3 | ||||
-rw-r--r-- | tests/31 | 3 | ||||
-rw-r--r-- | tests/32 | 3 | ||||
-rw-r--r-- | tests/33 | 3 | ||||
-rw-r--r-- | tests/34 | 3 | ||||
-rw-r--r-- | tests/35 | 3 | ||||
-rw-r--r-- | tests/36 | 3 | ||||
-rw-r--r-- | tests/37 | 1 | ||||
-rw-r--r-- | tests/38 | 1 | ||||
-rw-r--r-- | tests/39 | 1 | ||||
-rw-r--r-- | tests/4 | 2 | ||||
-rw-r--r-- | tests/5 | 2 | ||||
-rw-r--r-- | tests/6 | 1 | ||||
-rw-r--r-- | tests/7 | 1 | ||||
-rw-r--r-- | tests/8 | 1 | ||||
-rw-r--r-- | tests/9 | 2 |
42 files changed, 116 insertions, 2 deletions
@@ -9,8 +9,50 @@ loc.o: loc.c arg.h loc: loc.o $(CC) -o $@ loc.o $(LDFLAGS) -check: - true +check: loc + test "$$(./loc < tests/0)" = 0 + test "$$(./loc - < tests/0)" = 0 + test "$$(./loc tests/1 tests/2 | sed 's/: */: /')" = "$$(printf '%s\n' 'tests/1: 0' 'tests/2: 1')" + test "$$(./loc tests/0)" = 0 + test "$$(./loc tests/1)" = 0 + test "$$(./loc tests/2)" = 1 + test "$$(./loc tests/3)" = 0 + test "$$(./loc tests/4)" = 2 + test "$$(./loc tests/5)" = 2 + test "$$(./loc tests/6)" = 1 + test "$$(./loc tests/7)" = 0 + test "$$(./loc tests/8)" = 1 + test "$$(./loc tests/9)" = 1 + test "$$(./loc tests/10)" = 2 + test "$$(./loc tests/11)" = 0 + test "$$(./loc tests/12)" = 1 + test "$$(./loc tests/13)" = 2 + test "$$(./loc tests/14)" = 1 + test "$$(./loc tests/15)" = 0 + test "$$(./loc tests/16)" = 0 + test "$$(./loc tests/17)" = 1 + test "$$(./loc tests/18)" = 0 + test "$$(./loc tests/19)" = 1 + test "$$(./loc tests/20)" = 1 + test "$$(./loc tests/21)" = 1 + test "$$(./loc tests/22)" = 1 + test "$$(./loc tests/23)" = 1 + test "$$(./loc tests/24)" = 1 + test "$$(./loc tests/25)" = 0 + test "$$(./loc tests/26)" = 3 + test "$$(./loc tests/27)" = 3 + test "$$(./loc tests/28)" = 3 + test "$$(./loc tests/29)" = 3 + test "$$(./loc tests/30)" = 1 + test "$$(./loc tests/31)" = 1 + test "$$(./loc tests/32)" = 1 + test "$$(./loc tests/33)" = 1 + test "$$(./loc tests/34)" = 2 + test "$$(./loc tests/35)" = 2 + test "$$(./loc tests/36)" = 2 + test "$$(./loc tests/37)" = 1 + test "$$(./loc tests/38)" = 0 + test "$$(./loc tests/39)" = 1 install: loc mkdir -p -- "$(DESTDIR)$(PREFIX)/bin/" @@ -52,6 +52,7 @@ count(int fd, const char *fname) ret += (ssize_t)!beginning; beginning = 1; escaped = 0; + continue; } else if (escaped) { escaped = 0; } else if (buf[i] == quote) { @@ -59,6 +60,7 @@ count(int fd, const char *fname) } else if (buf[i] == '\\') { escaped = 1; } + beginning = 0; } else if (c_comment) { if (buf[i] == '\n') { ret += (ssize_t)!beginning; @@ -0,0 +1 @@ + diff --git a/tests/10 b/tests/10 new file mode 100644 index 0000000..a5b8098 --- /dev/null +++ b/tests/10 @@ -0,0 +1,2 @@ +x//y +z diff --git a/tests/11 b/tests/11 new file mode 100644 index 0000000..b4d07ff --- /dev/null +++ b/tests/11 @@ -0,0 +1 @@ +/* x */ diff --git a/tests/12 b/tests/12 new file mode 100644 index 0000000..5d10bae --- /dev/null +++ b/tests/12 @@ -0,0 +1 @@ +x/* y */ diff --git a/tests/13 b/tests/13 new file mode 100644 index 0000000..54d7eb2 --- /dev/null +++ b/tests/13 @@ -0,0 +1,2 @@ +x/* y */ +x diff --git a/tests/14 b/tests/14 new file mode 100644 index 0000000..80d4ce8 --- /dev/null +++ b/tests/14 @@ -0,0 +1 @@ +/* x */y diff --git a/tests/15 b/tests/15 new file mode 100644 index 0000000..79beb60 --- /dev/null +++ b/tests/15 @@ -0,0 +1 @@ +/* x *//* y */ diff --git a/tests/16 b/tests/16 new file mode 100644 index 0000000..ad5f298 --- /dev/null +++ b/tests/16 @@ -0,0 +1 @@ +/*x*///y diff --git a/tests/17 b/tests/17 new file mode 100644 index 0000000..67d8a7f --- /dev/null +++ b/tests/17 @@ -0,0 +1 @@ +/*x*//y diff --git a/tests/18 b/tests/18 new file mode 100644 index 0000000..287548a --- /dev/null +++ b/tests/18 @@ -0,0 +1 @@ +/* x \*/ diff --git a/tests/19 b/tests/19 new file mode 100644 index 0000000..92272fb --- /dev/null +++ b/tests/19 @@ -0,0 +1 @@ +\/* x */ @@ -0,0 +1 @@ +x diff --git a/tests/20 b/tests/20 new file mode 100644 index 0000000..5b547a5 --- /dev/null +++ b/tests/20 @@ -0,0 +1 @@ +\// diff --git a/tests/21 b/tests/21 new file mode 100644 index 0000000..ecd2475 --- /dev/null +++ b/tests/21 @@ -0,0 +1 @@ +\/ * diff --git a/tests/22 b/tests/22 new file mode 100644 index 0000000..3acbcec --- /dev/null +++ b/tests/22 @@ -0,0 +1 @@ +/* x */ */ diff --git a/tests/23 b/tests/23 new file mode 100644 index 0000000..f714113 --- /dev/null +++ b/tests/23 @@ -0,0 +1 @@ +/* x "*/" */ diff --git a/tests/24 b/tests/24 new file mode 100644 index 0000000..6cd8dff --- /dev/null +++ b/tests/24 @@ -0,0 +1 @@ +/* x '*/' */ diff --git a/tests/25 b/tests/25 new file mode 100644 index 0000000..9350792 --- /dev/null +++ b/tests/25 @@ -0,0 +1,3 @@ +/* +x +*/ diff --git a/tests/26 b/tests/26 new file mode 100644 index 0000000..24f012c --- /dev/null +++ b/tests/26 @@ -0,0 +1,3 @@ +"/* +x +*/" diff --git a/tests/27 b/tests/27 new file mode 100644 index 0000000..32dc19f --- /dev/null +++ b/tests/27 @@ -0,0 +1,3 @@ +'/* +x +*/' diff --git a/tests/28 b/tests/28 new file mode 100644 index 0000000..43a0b9a --- /dev/null +++ b/tests/28 @@ -0,0 +1,3 @@ +"\"/* +x +*/ diff --git a/tests/29 b/tests/29 new file mode 100644 index 0000000..7dd24bf --- /dev/null +++ b/tests/29 @@ -0,0 +1,3 @@ +'\'/* +x +*/ @@ -0,0 +1,3 @@ + {}()
[]; + +; diff --git a/tests/30 b/tests/30 new file mode 100644 index 0000000..c739847 --- /dev/null +++ b/tests/30 @@ -0,0 +1,3 @@ +" "/* +x +*/ diff --git a/tests/31 b/tests/31 new file mode 100644 index 0000000..2ebd547 --- /dev/null +++ b/tests/31 @@ -0,0 +1,3 @@ +' '/* +x +*/ diff --git a/tests/32 b/tests/32 new file mode 100644 index 0000000..8470c9c --- /dev/null +++ b/tests/32 @@ -0,0 +1,3 @@ +'"'/* +x +*/ diff --git a/tests/33 b/tests/33 new file mode 100644 index 0000000..8782f15 --- /dev/null +++ b/tests/33 @@ -0,0 +1,3 @@ +"'"/* +x +*/ diff --git a/tests/34 b/tests/34 new file mode 100644 index 0000000..85bf9aa --- /dev/null +++ b/tests/34 @@ -0,0 +1,3 @@ +" + +" diff --git a/tests/35 b/tests/35 new file mode 100644 index 0000000..8e38ed0 --- /dev/null +++ b/tests/35 @@ -0,0 +1,3 @@ +' + +' diff --git a/tests/36 b/tests/36 new file mode 100644 index 0000000..1e6f762 --- /dev/null +++ b/tests/36 @@ -0,0 +1,3 @@ +x + +x diff --git a/tests/37 b/tests/37 new file mode 100644 index 0000000..1bc266d --- /dev/null +++ b/tests/37 @@ -0,0 +1 @@ +/* // */ x diff --git a/tests/38 b/tests/38 new file mode 100644 index 0000000..50da1b9 --- /dev/null +++ b/tests/38 @@ -0,0 +1 @@ +// /* */ x diff --git a/tests/39 b/tests/39 new file mode 100644 index 0000000..e5409e8 --- /dev/null +++ b/tests/39 @@ -0,0 +1 @@ +/**//**/x @@ -0,0 +1,2 @@ +x +y @@ -0,0 +1,2 @@ +x\ +y @@ -0,0 +1 @@ +x
\ No newline at end of file @@ -0,0 +1 @@ +//x @@ -0,0 +1 @@ +x//x @@ -0,0 +1,2 @@ +x//y\ +z |