diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-25 11:35:31 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-25 11:35:31 +0000 |
commit | 6dec153c674794298c76c4fd46b96ba1e2cbecfb (patch) | |
tree | 631778bb1f245a615b9fc5a1e1ceea40829fb36f /usr.bin/tmux/layout-custom.c | |
parent | 201f39e93a90f7c7ed44799da74d181fb4cad8fb (diff) |
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 'usr.bin/tmux/layout-custom.c')
-rw-r--r-- | usr.bin/tmux/layout-custom.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/tmux/layout-custom.c b/usr.bin/tmux/layout-custom.c index 360ccbdb51e..b911276b359 100644 --- a/usr.bin/tmux/layout-custom.c +++ b/usr.bin/tmux/layout-custom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: layout-custom.c,v 1.5 2012/03/17 22:35:09 nicm Exp $ */ +/* $OpenBSD: layout-custom.c,v 1.6 2013/03/25 11:35:30 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); |