diff options
author | Adam Chlipala <adam@chlipala.net> | 2019-07-04 13:56:28 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2019-07-04 13:56:28 -0400 |
commit | ea30ab5c6e5ff7cfa6576f8ef9b8f19876247279 (patch) | |
tree | af518ef170934ec400ebc9966d511d57c5dd2289 | |
parent | 3101960af6d13eb44c12dfb1ca2381fd16136f0a (diff) |
Make uw_set_error_message actually act printf-y
-rw-r--r-- | src/c/urweb.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 8a7c439a..b820354f 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -902,9 +902,12 @@ char *uw_error_message(uw_context ctx) { return ctx->error_message; } -void uw_set_error_message(uw_context ctx, const char *msg) { - strncpy(ctx->error_message, msg, sizeof(ctx->error_message)); - ctx->error_message[sizeof(ctx->error_message)-1] = 0; +void uw_set_error_message(uw_context ctx, const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + + vsnprintf(ctx->error_message, ERROR_BUF_LEN, fmt, ap); + ctx->error_message[ERROR_BUF_LEN-1] = 0; } static input *INP(uw_context ctx) { |