ggreer/the_silver_searcher — pull request #110 by AndrewRadev (2012-11-17 20:32:53+00:00)
Title: Remove a leading "./" before printing

There's a small difference between `ack` and `ag` in the current directory:

Here's the output of `ack --nogroup --nocolor --column print_binary_file_matches`:

```
src/search.c:135:13: print_binary_file_matches(dir_full_path);
src/print.h:7:6:void print_binary_file_matches(const char* path);
src/print.c:34:6:void print_binary_file_matches(const char* path) {
```

And here's the one from `ag --nogroup --nocolor --column print_binary_file_matches`:

```
./src/print.h:7:6:void print_binary_file_matches(const char* path);
./src/search.c:135:13: print_binary_file_matches(dir_full_path);
./src/print.c:33:6:void print_binary_file_matches(const char* path) {
```

This turns out to be particularly weird when fed to Vim, since it normalizes some of the paths and leaves others as-is, for some reason.

I've added a simple check to print `path + 2` instead of `path` whenever a path starts with `./`, and this seems to work just fine.

Bear in mind that I'm not very proficient with C and I can't say I've experimented a lot with the fix (in that line of thought, +1 to @sjl for #73), so if you have a better idea, feel free to ignore the code.