=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/format.c,v retrieving revision 1.216 retrieving revision 1.217 diff -u -r1.216 -r1.217 --- src/usr.bin/tmux/format.c 2019/11/25 15:02:48 1.216 +++ src/usr.bin/tmux/format.c 2019/11/25 15:04:15 1.217 @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.216 2019/11/25 15:02:48 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.217 2019/11/25 15:04:15 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -1299,7 +1299,7 @@ } /* Now try single character with arguments. */ - if (strchr("mCs=", cp[0]) == NULL) + if (strchr("mCs=p", cp[0]) == NULL) break; c = cp[0]; @@ -1565,7 +1565,7 @@ char *copy0, *condition, *found, *new; char *value, *left, *right; size_t valuelen; - int modifiers = 0, limit = 0, j; + int modifiers = 0, limit = 0, width = 0, j; struct format_modifier *list, *fm, *cmp = NULL, *search = NULL; struct format_modifier **sub = NULL; u_int i, count, nsub = 0; @@ -1611,6 +1611,14 @@ if (fm->argc >= 2 && fm->argv[1] != NULL) marker = fm->argv[1]; break; + case 'p': + if (fm->argc < 1) + break; + width = strtonum(fm->argv[0], INT_MIN, INT_MAX, + &errptr); + if (errptr != NULL) + width = 0; + break; case 'l': modifiers |= FORMAT_LITERAL; break; @@ -1843,6 +1851,19 @@ value = new; } format_log(ft, "applied length limit %d: %s", limit, value); + } + + /* Pad the value if needed. */ + if (width > 0) { + new = utf8_padcstr(value, width); + free(value); + value = new; + format_log(ft, "applied padding width %d: %s", width, value); + } else if (width < 0) { + new = utf8_rpadcstr(value, -width); + free(value); + value = new; + format_log(ft, "applied padding width %d: %s", width, value); } /* Expand the buffer and copy in the value. */