diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-23 20:29:13 +0300 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-23 20:29:13 +0300 |
commit | 42843e2c444edc98632e8e5b8073c184332bdd94 (patch) | |
tree | 4c57548a5d82c7596a31341cd9aa468166d169ea | |
parent | cad238d30483de885f37019d159b5119edaaa611 (diff) |
memview: Fix region names
The old way failed for spaces, this is much better anyways
-rw-r--r-- | src/memview.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/memview.c b/src/memview.c index e9a9d10..c64d9fd 100644 --- a/src/memview.c +++ b/src/memview.c @@ -764,6 +764,13 @@ basename(const char *path) return (base ? base + 1 : path); } +static const char* +skip_ws(const char *str) +{ + const size_t skipped = strspn(str, " \t\n"); + return str + skipped; +} + static void region_cb(const char *line, void *data) { @@ -777,10 +784,9 @@ region_cb(const char *line, void *data) if (!region_parse(&ctx.named[ctx.num_regions].region, line)) return; - char path[255] = {0}; int region_len_without_name = strlen(line); - sscanf(line, "%*s %*s %*s %*s %*s%n %254s", ®ion_len_without_name, path); - const char *base = basename(path); + sscanf(line, "%*s %*s %*s %*s %*s%n", ®ion_len_without_name); + const char *base = basename(skip_ws(line + region_len_without_name)); char *name; size_t name_sz = region_len_without_name + 1 + strlen(base) + 1; |