From dcecc70c259682fe3729e7b0b1121d2b1ffe3aa9 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 10 Mar 2025 20:26:38 -0400 Subject: [PATCH] More careful fill handling with characters in insert_scal --- src/builtins/fold.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/builtins/fold.c b/src/builtins/fold.c index 5682568f..68d13eec 100644 --- a/src/builtins/fold.c +++ b/src/builtins/fold.c @@ -383,6 +383,19 @@ static B m1c1(B t, B f, B x) { // consumes x } extern B insert_base(B f, B x, bool has_w, B w); // from cells.c +static bool fillNumeric(B x) { + if (x.u==0) return true; + if (isAtm(x)) return false; + u8 xe = TI(x,elType); + usz ia = IA(x); + if (xe!=el_B) return ia==0 || elNum(xe); + if (!fillNumeric(getFillN(x))) return false; + if (ia==0) return true; + SGetU(x) + for (usz i=0; i1) shcpy(rsh, SH(x)+1, rr); usz xi = xia - csz; + B xf = getFillN(x); B rf; if (has_w) { + // fxw is (โŠขห๐•ฉ)๐”ฝ๐•จ so shape errors have been caught rf = getFillR(fxw); - COPY_TO(r.a, el_B, 0, fxw, 0, csz); // (โŠขห๐•ฉ)๐”ฝ๐•จ so errors have been caught + COPY_TO(r.a, el_B, 0, fxw, 0, csz); decG(fxw); } else { - rf = getFillR(x); + rf = inc(xf); COPY_TO(r.a, el_B, 0, x, xi, csz); } @@ -406,6 +421,26 @@ static B insert_scal(B f, FC2 fc2, B x, bool has_w, B fxw, usz xia, ur rr) { xi -= csz; for (usz i=0; i 2); + #if SEMANTIC_CATCH + if (CATCH) { + freeThrown(); + rf = bi_noFill; + } else { + if (!has_w) rf = fc2(f, inc(xf), rf); + if (n%2 == !has_w) rf = fc2(f, inc(xf), rf); + else fc2(f, inc(xf), inc(rf)); // could error, -หœห"abc" + popCatch(); + } + #else + if (n%2 == 0) { dec(rf); rf = bi_noFill; } + #endif + } decG(x); return withFill(r.b, rf); }