Ticket #3817: mcview: fix read of filtering data from pipe.

(mcview_eol): grow buffer every time when it really needed.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Egmont Koblinger 2017-05-04 10:15:56 +03:00 committed by Andrew Borodin
parent ed0ed4ac72
commit 27c30e8f5f
3 changed files with 8 additions and 10 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;