harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3fecfcfd18fb73fab06e8a2593085307e424ca15
parent 833f2305adc84fd7c68efbf351ccbd23fad38766
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Mon, 23 Aug 2021 04:27:04 +0200

do not treat Hare literals as C strings

Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>

Diffstat:
Msrc/check.c | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -415,13 +415,14 @@ check_expr_assert(struct context *ctx, } assert(expr->assert.message->type == EXPR_CONSTANT); - int n = snprintf(NULL, 0, "%s:%d:%d: %s", - aexpr->loc.path, aexpr->loc.lineno, aexpr->loc.colno, - expr->assert.message->constant.string.value); - char *s = xcalloc(1, n + 1); - snprintf(s, n + 1, "%s:%d:%d: %s", - aexpr->loc.path, aexpr->loc.lineno, aexpr->loc.colno, - expr->assert.message->constant.string.value); + size_t n = snprintf(NULL, 0, "%s:%d:%d: ", + aexpr->loc.path, aexpr->loc.lineno, aexpr->loc.colno); + size_t s_len = expr->assert.message->constant.string.len; + char *s = xcalloc(1, s_len + n + 1); + snprintf(s, n + 1, "%s:%d:%d: ", + aexpr->loc.path, aexpr->loc.lineno, aexpr->loc.colno); + memcpy(s+n, expr->assert.message->constant.string.value, s_len); + s[n + s_len] = '\0'; expr->assert.message->constant.string.value = s; expr->assert.message->constant.string.len = n;