diff --git a/src/viewer/ascii.c b/src/viewer/ascii.c index 2e23db076..f4b9dcbb4 100644 --- a/src/viewer/ascii.c +++ b/src/viewer/ascii.c @@ -599,7 +599,7 @@ mcview_display_line (WView * view, mcview_state_machine_t * state, int row, off_t eol; int retval; - eol = mcview_eol (view, state->offset, mcview_get_filesize (view)); + eol = mcview_eol (view, state->offset); retval = (eol > state->offset) ? 1 : 0; mcview_state_machine_init (state, eol); @@ -737,7 +737,7 @@ mcview_display_line (WView * view, mcview_state_machine_t * state, int row, * parsing and then not actually displaying it. */ off_t eol; - eol = mcview_eol (view, state->offset, mcview_get_filesize (view)); + eol = mcview_eol (view, state->offset); mcview_state_machine_init (state, eol); return 1; } @@ -942,7 +942,7 @@ mcview_ascii_move_down (WView * view, off_t lines) * EOF, that can't happen. */ if (!view->text_wrap_mode) { - view->dpy_start = mcview_eol (view, view->dpy_start, mcview_get_filesize (view)); + view->dpy_start = mcview_eol (view, view->dpy_start); view->dpy_paragraph_skip_lines = 0; view->dpy_wrap_dirty = TRUE; } diff --git a/src/viewer/internal.h b/src/viewer/internal.h index 2b2886a94..2d8817c9a 100644 --- a/src/viewer/internal.h +++ b/src/viewer/internal.h @@ -314,7 +314,7 @@ void mcview_select_encoding (WView * view); void mcview_set_codeset (WView * view); void mcview_show_error (WView * view, const char *error); off_t mcview_bol (WView * view, off_t current, off_t limit); -off_t mcview_eol (WView * view, off_t current, off_t limit); +off_t mcview_eol (WView * view, off_t current); char *mcview_get_title (const WDialog * h, size_t len); int mcview_calc_percent (WView * view, off_t p); diff --git a/src/viewer/lib.c b/src/viewer/lib.c index f16618438..2049ba6ac 100644 --- a/src/viewer/lib.c +++ b/src/viewer/lib.c @@ -357,16 +357,14 @@ mcview_bol (WView * view, off_t current, off_t limit) */ off_t -mcview_eol (WView * view, off_t current, off_t limit) +mcview_eol (WView * view, off_t current) { int c, prev_ch = 0; - off_t filesize; - filesize = mcview_get_filesize (view); + if (current < 0) return 0; - if (current >= filesize) - return filesize; - while (current < filesize && current < limit) + + while (TRUE) { if (!mcview_get_byte (view, current, &c)) break;