=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/format.c,v retrieving revision 1.305 retrieving revision 1.306 diff -c -r1.305 -r1.306 *** src/usr.bin/tmux/format.c 2022/06/21 09:30:01 1.305 --- src/usr.bin/tmux/format.c 2022/06/27 09:14:49 1.306 *************** *** 1,4 **** ! /* $OpenBSD: format.c,v 1.305 2022/06/21 09:30:01 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: format.c,v 1.306 2022/06/27 09:14:49 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott *************** *** 4606,4612 **** { struct format_tree *ft = es->ft; char *buf, *out, *name; ! const char *ptr, *s; size_t off, len, n, outlen; int ch, brackets; char expanded[8192]; --- 4606,4612 ---- { struct format_tree *ft = es->ft; char *buf, *out, *name; ! const char *ptr, *s, *style_end = NULL; size_t off, len, n, outlen; int ch, brackets; char expanded[8192]; *************** *** 4701,4713 **** break; fmt += n + 1; continue; case '#': /* * If ##[ (with two or more #s), then it is a style and * can be left for format_draw to handle. */ ! ptr = fmt; ! n = 2; while (*ptr == '#') { ptr++; n++; --- 4701,4714 ---- break; fmt += n + 1; continue; + case '[': case '#': /* * If ##[ (with two or more #s), then it is a style and * can be left for format_draw to handle. */ ! ptr = fmt - (ch == '['); ! n = 2 - (ch == '['); while (*ptr == '#') { ptr++; n++; *************** *** 4721,4726 **** --- 4722,4728 ---- memcpy(buf + off, fmt - 2, n + 1); off += n + 1; fmt = ptr + 1; + style_end = format_skip(fmt - 2, "]"); continue; } /* FALLTHROUGH */ *************** *** 4735,4744 **** continue; default: s = NULL; ! if (ch >= 'A' && ch <= 'Z') ! s = format_upper[ch - 'A']; ! else if (ch >= 'a' && ch <= 'z') ! s = format_lower[ch - 'a']; if (s == NULL) { while (len - off < 3) { buf = xreallocarray(buf, 2, len); --- 4737,4748 ---- continue; default: s = NULL; ! if (fmt > style_end) { /* skip inside #[] */ ! if (ch >= 'A' && ch <= 'Z') ! s = format_upper[ch - 'A']; ! else if (ch >= 'a' && ch <= 'z') ! s = format_lower[ch - 'a']; ! } if (s == NULL) { while (len - off < 3) { buf = xreallocarray(buf, 2, len);