=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/format.c,v retrieving revision 1.309 retrieving revision 1.310 diff -c -r1.309 -r1.310 *** src/usr.bin/tmux/format.c 2022/07/19 06:46:57 1.309 --- src/usr.bin/tmux/format.c 2022/11/04 08:03:23 1.310 *************** *** 1,4 **** ! /* $OpenBSD: format.c,v 1.309 2022/07/19 06:46:57 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: format.c,v 1.310 2022/11/04 08:03:23 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott *************** *** 3575,3582 **** return (found); } ! /* Remove escaped characters from string. */ static char * format_strip(const char *s) { char *out, *cp; --- 3575,3607 ---- return (found); } ! /* Unescape escaped characters. */ static char * + format_unescape(const char *s) + { + char *out, *cp; + int brackets = 0; + + cp = out = xmalloc(strlen(s) + 1); + for (; *s != '\0'; s++) { + if (*s == '#' && s[1] == '{') + brackets++; + if (brackets == 0 && + *s == '#' && + strchr(",#{}:", s[1]) != NULL) { + *cp++ = *++s; + continue; + } + if (*s == '}') + brackets--; + *cp++ = *s; + } + *cp = '\0'; + return (out); + } + + /* Remove escaped characters. */ + static char * format_strip(const char *s) { char *out, *cp; *************** *** 4338,4344 **** /* Is this a literal string? */ if (modifiers & FORMAT_LITERAL) { ! value = xstrdup(copy); goto done; } --- 4363,4370 ---- /* Is this a literal string? */ if (modifiers & FORMAT_LITERAL) { ! format_log(es, "literal string is '%s'", copy); ! value = format_unescape(copy); goto done; }