diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-24 02:36:37 +0300 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-24 02:36:37 +0300 |
commit | 8447865a5c559c50dfbebc7124171bcaa73b2cd1 (patch) | |
tree | 58ff096cdca047a8a4f58d7ac4a98b7cea8110c8 | |
parent | 199c8fcfa3917609ced0614c0a258a164d33ec24 (diff) |
memview: fix -/+ offset inputs
-rw-r--r-- | src/memview.c | 10 |
1 files 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; } |