summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-10-23 20:29:13 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-10-23 20:29:13 +0300
commit42843e2c444edc98632e8e5b8073c184332bdd94 (patch)
tree4c57548a5d82c7596a31341cd9aa468166d169ea /src
parentcad238d30483de885f37019d159b5119edaaa611 (diff)
memview: Fix region names
The old way failed for spaces, this is much better anyways
Diffstat (limited to 'src')
-rw-r--r--src/memview.c12
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", &region_len_without_name, path);
- const char *base = basename(path);
+ sscanf(line, "%*s %*s %*s %*s %*s%n", &region_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;