hexedit: code shrink

function                                             old     new   delta
hexedit_main                                        1171    1170      -1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2017-09-15 15:23:47 +02:00
parent f3fa865258
commit e58b44755d

View File

@ -432,28 +432,27 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv)
printf(ESC"[999;1H" CLEAR_TILL_EOL); /* go to last line */ printf(ESC"[999;1H" CLEAR_TILL_EOL); /* go to last line */
if (read_line_input(NULL, "Go to (dec,0Xhex,0oct): ", buf, sizeof(buf)) > 0) { if (read_line_input(NULL, "Go to (dec,0Xhex,0oct): ", buf, sizeof(buf)) > 0) {
off_t t; off_t t;
unsigned pgmask; unsigned cursor;
t = bb_strtoull(buf, NULL, 0); t = bb_strtoull(buf, NULL, 0);
if (t >= G.size) if (t >= G.size)
t = G.size - 1; t = G.size - 1;
pgmask = G_pagesize - 1; cursor = t & (G_pagesize - 1);
cnt = t & pgmask; t -= cursor;
t = t & ~(off_t)pgmask;
if (t < 0) if (t < 0)
cnt = t = 0; cursor = t = 0;
if (t != 0 && cnt < 0x1ff) { if (t != 0 && cursor < 0x1ff) {
/* very close to end of page, possibly to EOF */ /* very close to end of page, possibly to EOF */
/* move one page lower */ /* move one page lower */
t -= G_pagesize; t -= G_pagesize;
cnt += G_pagesize; cursor += G_pagesize;
} }
G.offset = t; G.offset = t;
remap(cnt); remap(cursor);
redraw(cnt); redraw(cursor);
break; break;
} }
/* EOF/error on input: fall through to exiting */ /* ^C/EOF/error: fall through to exiting */
} }
case CTRL('X'): case CTRL('X'):
restore_term(); restore_term();