diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-11-07 12:27:42 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-11-07 12:27:42 -0800 |
| commit | 3aabbb6dc5343d4f8cd61a4f83c8eeba14aaef8b (patch) | |
| tree | f208aae88d6b44765265e58e09c2113adfc49bde /bp.c | |
| parent | 486fe98a9c7f751998aeb6837dabfea7ac33938d (diff) | |
Fix to ensure proper line numbering
Diffstat (limited to 'bp.c')
| -rw-r--r-- | bp.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -287,7 +287,7 @@ static file_t *printing_file = NULL; static int last_line_num = -1; static void _fprint_between(FILE *out, const char *start, const char *end, const char *normal_color) { - while (start < end) { + do { // Cheeky lookbehind to see if line number should be printed if (start == printing_file->start || start[-1] == '\n') { int linenum = (int)get_line_number(printing_file, start); @@ -301,10 +301,10 @@ static void _fprint_between(FILE *out, const char *start, const char *end, const fwrite(start, sizeof(char), (size_t)(line_end - start + 1), out); start = line_end + 1; } else { - fwrite(start, sizeof(char), (size_t)(end - start), out); + if (end > start) fwrite(start, sizeof(char), (size_t)(end - start), out); break; } - } + } while (start < end); } static void fprint_context(FILE *out, file_t *f, const char *prev, const char *next) |
