I think this is what I intended: diff --git a/layout-custom.c b/layout-custom.c index c076232..ab89a3f 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); }
On Sat, Mar 09, 2013 at 06:29:33PM -0600, Chris Johnsen wrote: > The leading checksum value of custom layout strings output by the > list-windows command (generated by layout_dump) is printed as a four > character field ("%4x"). For values less than 0x1000 this means that > spaces are added to the left side to pad it out to four characters. > > These leading spaces are easy to accidentally (or unintentionally) > omit when copying the custom layout string for use with the > select-layout command. > > Technically, a "short" checksum value is correctly parsed by the > current code, but the pointer is advanced as if it were always four > characters long. This effectively mangles the rest of the custom > layout string by skipping one or more of the next characters (i.e. > the width of the top-level window). This likely invalidates the > checksum, and would certainly disturb the relationship among the > widths of the panes represented by the layout string. > > Advance the pointer according to the actual length of the parsed > value instead of assuming that it is four characters long. > > --- > > For testing purposes, here are some layouts that have "short" > checksums (for two and six panes): > > 75b,193x41,0,0[193x30,0,0,0,193x7,0,31,1,193x2,0,39,2] > > > 94,118x40,0,0{100x40,0,0,0,17x40,101,0[17x10,101,0,3,17x9,101,11{2x9,101,11,5,11x9,104,11,8,2x9,116,11,7},17x19,101,21,4]} > --- > layout-custom.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/layout-custom.c b/layout-custom.c > index c076232..aa70e16 100644 > --- a/layout-custom.c > +++ b/layout-custom.c > @@ -121,11 +121,12 @@ layout_parse(struct window *w, const char *layout) > struct window_pane *wp; > u_int npanes, ncells, sx, sy; > u_short csum; > + int size; > > /* Check validity. */ > - if (sscanf(layout, "%hx,", &csum) != 1) > + if (sscanf(layout, "%hx,%n", &csum, &size) != 1) > return (-1); > - layout += 5; > + layout += size; > if (csum != layout_checksum(layout)) > return (-1); > > -- > 1.8.1.3 > > > ------------------------------------------------------------------------------ > Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester > Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the > endpoint security space. For insight on selecting the right partner to > tackle endpoint security challenges, access the full report. > http://p.sf.net/sfu/symantec-dev2dev > _______________________________________________ > tmux-users mailing list > tmux-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/tmux-users ------------------------------------------------------------------------------ Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users