From 94761d9a5a2460b5a43489526e1f404611ddb750 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 2 Sep 2024 19:05:06 -0400 Subject: Fix some stuff --- builtins/functions.c | 3 +++ builtins/text.c | 2 +- compile.c | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/builtins/functions.c b/builtins/functions.c index 06636cba..1628d303 100644 --- a/builtins/functions.c +++ b/builtins/functions.c @@ -218,10 +218,13 @@ public void end_test(void *expr, const TypeInfo *type, const char *expected, con Text_t expr_plain = USE_COLOR ? generic_as_text(expr, false, type) : expr_text; bool success = Text$equal(&expr_plain, &expected_text); if (!success) { + printf("Not equal: %k vs %k\n", &expr_plain, &expected_text); Int_t colon = Text$find(expected_text, Text$from_str(":"), I_small(0), NULL); if (colon.small != I_small(0).small) { Text_t with_type = Text$concat(expr_plain, Text$from_str(" : "), type_name); success = Text$equal(&with_type, &expected_text); + if (!success) + printf("Not equal: %k vs %k\n", &with_type, &expected_text); } } diff --git a/builtins/text.c b/builtins/text.c index 839159e4..3c90a06f 100644 --- a/builtins/text.c +++ b/builtins/text.c @@ -614,7 +614,7 @@ int32_t _next_grapheme(Text_t text, iteration_state_t *state, int64_t index) } for (;;) { if (index < state->sum_of_previous_subtexts + text.subtexts[state->subtext].length) - return _next_grapheme(text.subtexts[state->subtext], NULL, index); + return _next_grapheme(text.subtexts[state->subtext], NULL, index - state->sum_of_previous_subtexts); state->sum_of_previous_subtexts += text.subtexts[state->subtext].length; state->subtext += 1; } diff --git a/compile.c b/compile.c index 0bc09c74..50e39fe8 100644 --- a/compile.c +++ b/compile.c @@ -328,7 +328,6 @@ CORD compile_statement(env_t *env, ast_t *ast) uint8_t *norm = u8_normalize(UNINORM_NFD, (uint8_t*)raw, strlen((char*)raw)+1, buf, &norm_len); assert(norm[norm_len-1] == 0); output = CORD_from_char_star((char*)norm); - CORD_printf("OUTPUT: %r\n", output); if (norm && norm != buf) free(norm); } @@ -595,7 +594,7 @@ CORD compile_statement(env_t *env, ast_t *ast) return CORD_all(lhs, " ^= ", rhs, ";"); case BINOP_CONCAT: { if (lhs_t->tag == TextType) { - return CORD_all(lhs, " = CORD_cat(", lhs, ", ", rhs, ");"); + return CORD_all(lhs, " = Text$concat(", lhs, ", ", rhs, ");"); } else if (lhs_t->tag == ArrayType) { CORD padded_item_size = CORD_asprintf("%ld", padded_type_size(Match(lhs_t, ArrayType)->item_type)); if (promote(env, &rhs, rhs_t, Match(lhs_t, ArrayType)->item_type)) { -- cgit v1.2.3