diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-09-27 21:41:30 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-09-27 21:41:30 -0700 |
| commit | 117ccaa1dc8b3dfcd992b05c4f9bae4140545705 (patch) | |
| tree | 95177dd00c625897b7787f86fbab58bf1e923028 /bp.c | |
| parent | c60c1db8a230bb6e834366d8766d4013680f06c4 (diff) | |
Cleanup for trailing line printing
Diffstat (limited to 'bp.c')
| -rw-r--r-- | bp.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -371,18 +371,17 @@ static int print_matches(FILE *out, file_t *f, pat_t *pattern) fprint_context(out, f, prev, m->start); if (print_opts.normal_color) fprintf(out, "%s", print_opts.normal_color); fprint_match(out, f->start, m, &print_opts); - size_t linenum = get_line_number(f, m->end); - if (last_line_num < (int)linenum) { - fprint_linenum(out, f, linenum, print_opts.normal_color); - fputc('\n', out); - last_line_num = (int)linenum; - } if (print_opts.normal_color) fprintf(out, "%s", print_opts.normal_color); prev = m->end; } // Print trailing context if needed: - if (matches > 0) + if (matches > 0) { fprint_context(out, f, prev, NULL); + if (last_line_num < 0) { + fprint_linenum(out, f, f->nlines, print_opts.normal_color); + fputc('\n', out); + } + } printing_file = NULL; last_line_num = -1; |
