From 9cc2a0368fb0a3aa8b878d1795ed76734beadc02 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 23 Apr 2024 22:45:04 +0200 Subject: Don’t return local arrays, lol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/optparse/optparse.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/optparse') diff --git a/lib/optparse/optparse.c b/lib/optparse/optparse.c index cf0c7dc..6c05d64 100644 --- a/lib/optparse/optparse.c +++ b/lib/optparse/optparse.c @@ -149,14 +149,11 @@ error_s(struct optparse *st, const char *msg, struct u8view s) return -1; } -/* clang-format off */ - rune error_r(struct optparse *st, const char *msg, rune ch) { char buf[U8_LEN_MAX + 1] = {}; - return error_s(st, msg, (struct u8view){ - .p = buf, - .len = rtou8(buf, ch, sizeof(buf)), - }); + snprintf(st->errmsg, sizeof(st->errmsg), u8"%s — ‘%.*s’", msg, + rtou8(buf, sizeof(buf), ch), buf); + return -1; } -- cgit v1.2.3