From 8447865a5c559c50dfbebc7124171bcaa73b2cd1 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Wed, 24 Oct 2018 02:36:37 +0300 Subject: memview: fix -/+ offset inputs --- src/memview.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/memview.c b/src/memview.c index 48837fa..2d11cb7 100644 --- a/src/memview.c +++ b/src/memview.c @@ -756,7 +756,9 @@ goto_offset(void *arg) return; char *invalid; - const size_t ret = hexdecstrtoull(v, &invalid); + const bool is_plus = (v[0] == '+'); + const bool is_minus = (v[0] == '-'); + const size_t ret = hexdecstrtoull(v + (is_plus | is_minus), &invalid); if (*invalid != 0) { error("invalid offset `%s`", v); @@ -765,10 +767,10 @@ goto_offset(void *arg) store_offset(ctx.hexview.offset); - if (v[0] == '+') { + if (is_plus) { ctx.hexview.offset += ret; - } else if (v[0] == '-') { - ctx.hexview.offset -= hexdecstrtoull(v + 1, NULL); + } else if (is_minus) { + ctx.hexview.offset -= ret; } else { ctx.hexview.offset = ret; } -- cgit v1.2.3