diff --git a/src/main.zig b/src/main.zig index f5241d0..78213b3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -153,7 +153,11 @@ fn dumpInput(config: Config, in: fs.File, out: fs.File, allocator: mem.Allocator } else { if (config.token) |token| { if (line) |memory| { - c += mem.count(u8, memory, token); + if (config.ignoreExtras) { + c += 1; + } else { + c += mem.count(u8, memory, token); + } } } else { c += 1; diff --git a/test.sh b/test.sh index ce149ea..1036877 100755 --- a/test.sh +++ b/test.sh @@ -88,7 +88,7 @@ diff --brief test.expect.err test.err rm test.expect test.out rm test.expect.err test.err -echo "> skip lines until 3 tokens seen - ignored extra tokens on same line" +echo "> skip lines until 4 tokens seen - ignored extra tokens on same line" cat< test.in Lorem ipsum dolor sit amet, consectetur adipiscing elit, @@ -104,7 +104,7 @@ quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. EOF -./skip 3 test.in --token m --ignore-extras > test.out +./skip 4 test.in --token m --ignore-extras > test.out diff --brief test.expect test.out rm test.in test.expect test.out