Copy all #s at once when multiple are seen before [ rather than only

copying one at a time which can be very slow.

(cherry picked from commit 5fbfaca6a8)
This commit is contained in:
nicm
2026-09-28 16:23:56 +00:00
committed by Nicholas Marriott
parent 28bfa971da
commit 02a0bef92b

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: format.c,v 1.419 2026/09/28 16:00:28 nicm Exp $ */
/* $OpenBSD: format.c,v 1.420 2026/09/28 16:23:56 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -6824,6 +6824,19 @@ format_expand1(struct format_expand_state *es, const char *fmt)
fmt = ptr + 1;
continue;
}
if (ch == '#') {
while (len - off < (n / 2) + 1) {
buf = xreallocarray(buf, 2, len);
len *= 2;
}
memset(buf + off, '#', n / 2);
off += (n / 2);
if (n % 2 != 0)
fmt = ptr - 1;
else
fmt = ptr;
continue;
}
/* FALLTHROUGH */
case '}':
case ',':