-/* $OpenBSD: format.c,v 1.68 2015/05/27 13:28:04 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.69 2015/05/29 23:12:38 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
char *
format_expand(struct format_tree *ft, const char *fmt)
{
- char *buf, *tmp;
+ char *buf, *tmp, *cmd;
const char *ptr, *s;
size_t off, len, n, slen;
int ch, brackets;
tmp = xmalloc(n + 1);
memcpy(tmp, fmt, n);
tmp[n] = '\0';
+ cmd = format_expand(ft, tmp);
- s = format_job_get(ft, tmp);
+ s = format_job_get(ft, cmd);
slen = strlen(s);
+ free(cmd);
+ free(tmp);
+
while (len - off < slen + 1) {
buf = xreallocarray(buf, 2, len);
len *= 2;