Fix literal word-regexp.

This commit is contained in:
yamagata 2016-01-14 01:17:52 +09:00
parent 6d35745e6d
commit aedd3ef37a
2 changed files with 42 additions and 2 deletions

View file

@ -66,8 +66,8 @@ void search_buf(const char *buf, const size_t buf_len,
/* It's a match */
} else {
/* It's not a match */
match_ptr += opts.query_len;
buf_offset = end - buf;
match_ptr += find_skip_lookup[0] - opts.query_len + 1;
buf_offset = match_ptr - buf;
continue;
}
}

View file

@ -0,0 +1,40 @@
Setup:
$ . $TESTDIR/setup.sh
$ echo 'blah abc def' > blah1.txt
$ echo 'abc blah def' > blah2.txt
$ echo 'abc def blah' > blah3.txt
$ echo 'abcblah def' > blah4.txt
$ echo 'abc blahdef' >> blah4.txt
$ echo 'blahx blah' > blah5.txt
$ echo 'abcblah blah blah' > blah6.txt
Match a word of the beginning:
$ ag -wF --column 'blah' blah1.txt
1:1:blah abc def
Match a middle word:
$ ag -wF --column 'blah' blah2.txt
1:5:abc blah def
Match a last word:
$ ag -wF --column 'blah' blah3.txt
1:9:abc def blah
No match:
$ ag -wF --column 'blah' blah4.txt
[1]
Match:
$ ag -wF --column 'blah' blah5.txt
1:7:blahx blah
Case of a word repeating the same part:
$ ag -wF --column 'blah blah' blah6.txt
1:9:abcblah blah blah