aboutsummaryrefslogtreecommitdiff
path: root/layout-custom.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-03-10 23:41:59 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-03-10 23:41:59 +0000
commita060aa2bf091c7befbb37f86ef450cd575a3e53e (patch)
tree27ae32376a7d2e52caa3ced2732b00e2a3a1ad32 /layout-custom.c
parent2ac6501698d5499967b33013d9f3fc8091fddc41 (diff)
downloadrtmux-a060aa2bf091c7befbb37f86ef450cd575a3e53e.tar.gz
rtmux-a060aa2bf091c7befbb37f86ef450cd575a3e53e.tar.bz2
rtmux-a060aa2bf091c7befbb37f86ef450cd575a3e53e.zip
Fix handling of short (< 4 character) checksums and a bug with parsing
old-style custom layouts. Based on fix from Chris Johnsen.
Diffstat (limited to 'layout-custom.c')
-rw-r--r--layout-custom.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/layout-custom.c b/layout-custom.c
index c076232f..e32d9d9d 100644
--- a/layout-custom.c
+++ b/layout-custom.c
@@ -63,7 +63,7 @@ layout_dump(struct window *w)
if (layout_append(w->layout_root, layout, sizeof layout) != 0)
return (NULL);
- xasprintf(&out, "%4x,%s", layout_checksum(layout), layout);
+ xasprintf(&out, "%04x,%s", layout_checksum(layout), layout);
return (out);
}
@@ -206,11 +206,11 @@ layout_construct(struct layout_cell *lcparent, const char **layout)
{
struct layout_cell *lc, *lcchild;
u_int sx, sy, xoff, yoff;
+ const char *saved;
if (!isdigit((u_char) **layout))
return (NULL);
- if (sscanf(*layout, "%ux%u,%u,%u,%*u", &sx, &sy, &xoff, &yoff) != 4 &&
- sscanf(*layout, "%ux%u,%u,%u", &sx, &sy, &xoff, &yoff) != 4)
+ if (sscanf(*layout, "%ux%u,%u,%u", &sx, &sy, &xoff, &yoff) != 4)
return (NULL);
while (isdigit((u_char) **layout))
@@ -231,9 +231,12 @@ layout_construct(struct layout_cell *lcparent, const char **layout)
while (isdigit((u_char) **layout))
(*layout)++;
if (**layout == ',') {
+ saved = *layout;
(*layout)++;
while (isdigit((u_char) **layout))
(*layout)++;
+ if (**layout == 'x')
+ *layout = saved;
}
lc = layout_create_cell(lcparent);