aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-02 19:05:06 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-02 19:05:06 -0400
commit94761d9a5a2460b5a43489526e1f404611ddb750 (patch)
tree74cdb2fea33a6559cb97b017e32ed2001e5f1e31
parent185ddaca82c8b9ad28baccc9879f48a50cc5ed8b (diff)
Fix some stuff
-rw-r--r--builtins/functions.c3
-rw-r--r--builtins/text.c2
-rw-r--r--compile.c3
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)) {