aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-04-23 22:45:04 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-04-23 22:45:04 +0200
commit9cc2a0368fb0a3aa8b878d1795ed76734beadc02 (patch)
treea589537811f2fc677e18db5d266b467ba338564f
parentf8727410e6c83a8390eb9a4812bd8831d07d49e4 (diff)
Don’t return local arrays, lol
-rw-r--r--lib/optparse/optparse.c9
1 files changed, 3 insertions, 6 deletions
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;
}