Ticket #3258: mc-3258-mcview-hex-percent.patch

File mc-3258-mcview-hex-percent.patch, 613 bytes (added by egmont, 10 years ago)

Fix

  • src/viewer/lib.c

    diff --git a/src/viewer/lib.c b/src/viewer/lib.c
    index 46b12c9..bbac08e 100644
    a b mcview_calc_percent (mcview_t * view, off_t p) 
    430430        return (-1); 
    431431 
    432432    filesize = mcview_get_filesize (view); 
     433    if (view->hex_mode && filesize > 0) { 
     434        /* p can't be beyond the last char, only over that. Compensate for this. */ 
     435        filesize--; 
     436    } 
    433437 
    434     if (filesize == 0 || view->dpy_end == filesize) 
     438    if (filesize == 0 || p >= filesize) 
    435439        percent = 100; 
    436440    else if (p > (INT_MAX / 100)) 
    437441        percent = p / (filesize / 100);