diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-15 15:23:47 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-15 15:23:47 +0200 |
commit | e58b44755dbac7c55bf602f7f76dfb37b47323f5 (patch) | |
tree | 8f9c2935a08e1f9083636479767fa64770bb8b7f /miscutils | |
parent | f3fa86525850620d31e48a742a25fd4965b1dba2 (diff) | |
download | busybox-w32-e58b44755dbac7c55bf602f7f76dfb37b47323f5.tar.gz busybox-w32-e58b44755dbac7c55bf602f7f76dfb37b47323f5.tar.bz2 busybox-w32-e58b44755dbac7c55bf602f7f76dfb37b47323f5.zip |
hexedit: code shrink
function old new delta
hexedit_main 1171 1170 -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/hexedit.c | 19 |
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(); |