aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/hexedit.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/miscutils/hexedit.c b/miscutils/hexedit.c
index 8334181c7..bafb834b5 100644
--- a/miscutils/hexedit.c
+++ b/miscutils/hexedit.c
@@ -432,28 +432,27 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv)
432 printf(ESC"[999;1H" CLEAR_TILL_EOL); /* go to last line */ 432 printf(ESC"[999;1H" CLEAR_TILL_EOL); /* go to last line */
433 if (read_line_input(NULL, "Go to (dec,0Xhex,0oct): ", buf, sizeof(buf)) > 0) { 433 if (read_line_input(NULL, "Go to (dec,0Xhex,0oct): ", buf, sizeof(buf)) > 0) {
434 off_t t; 434 off_t t;
435 unsigned pgmask; 435 unsigned cursor;
436 436
437 t = bb_strtoull(buf, NULL, 0); 437 t = bb_strtoull(buf, NULL, 0);
438 if (t >= G.size) 438 if (t >= G.size)
439 t = G.size - 1; 439 t = G.size - 1;
440 pgmask = G_pagesize - 1; 440 cursor = t & (G_pagesize - 1);
441 cnt = t & pgmask; 441 t -= cursor;
442 t = t & ~(off_t)pgmask;
443 if (t < 0) 442 if (t < 0)
444 cnt = t = 0; 443 cursor = t = 0;
445 if (t != 0 && cnt < 0x1ff) { 444 if (t != 0 && cursor < 0x1ff) {
446 /* very close to end of page, possibly to EOF */ 445 /* very close to end of page, possibly to EOF */
447 /* move one page lower */ 446 /* move one page lower */
448 t -= G_pagesize; 447 t -= G_pagesize;
449 cnt += G_pagesize; 448 cursor += G_pagesize;
450 } 449 }
451 G.offset = t; 450 G.offset = t;
452 remap(cnt); 451 remap(cursor);
453 redraw(cnt); 452 redraw(cursor);
454 break; 453 break;
455 } 454 }
456 /* EOF/error on input: fall through to exiting */ 455 /* ^C/EOF/error: fall through to exiting */
457 } 456 }
458 case CTRL('X'): 457 case CTRL('X'):
459 restore_term(); 458 restore_term();