diff --git a/src/builtins/md1.c b/src/builtins/md1.c index e0d2a2e7..c4fbd30a 100644 --- a/src/builtins/md1.c +++ b/src/builtins/md1.c @@ -66,8 +66,8 @@ bool isPervasiveDyExt(B x) { return false; } -B slash_c2(B f, B w, B x); -B shape_c2(B f, B w, B x); +B slash_c2(B t, B w, B x); +B shape_c2(B t, B w, B x); B tbl_c2(Md1D* d, B w, B x) { B f = d->f; if (isAtm(w)) w = m_atomUnit(w); if (isAtm(x)) x = m_atomUnit(x); diff --git a/src/builtins/scan.c b/src/builtins/scan.c index 37f9e3c9..640cc75f 100644 --- a/src/builtins/scan.c +++ b/src/builtins/scan.c @@ -55,7 +55,7 @@ static B scan_and(B x, u64 ia) { // consumes x decG(x); return FL_SET(r, fl_dsc|fl_squoze); } -B slash_c1(B f, B x); +B slash_c1(B t, B x); B scan_add_bool(B x, u64 ia) { // consumes x u64* xp = bitarr_ptr(x); u64 xs = bit_sum(xp, ia); diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index ab6e8038..f9eca3f7 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -1110,6 +1110,26 @@ B getTermNS(void) { return incG(termNS); } +static bool name_isUpper(u32 c) { return (c>='A' & c<='Z') || (c>=U'À' && c<=U'Þ'); } +B slash_c2(B, B, B); +B ne_c2(B, B, B); +static NOINLINE B name_normalize(B x) { + usz ia = IA(x); SGetU(x) + for (ux i = 0; i < ia; i++) { + u32 c0 = o2cG(GetU(x, i)); + if (name_isUpper(c0) || c0=='_') { + u32* rp; B r = m_c32arrv(&rp, ia); + COPY_TO(rp, el_c32, 0, x, 0, i); + while (i < ia) { + u32 c = o2cG(GetU(x, i)); + rp[i] = name_isUpper(c)? c+32 : c; + i++; + } + return C2(slash, C2(ne, x, m_c32('_')), r); + } + } + return x; +} B nKeys_c1(B t, B x) { if (!isNsp(x)) thrM("•ns.Keys: 𝕩 must be a namespace"); @@ -1129,13 +1149,15 @@ B nKeys_c1(B t, B x) { B nGet_c2(B t, B w, B x) { if (!isNsp(w)) thrM("•ns.Has: 𝕨 must be a namespace"); vfyStr(x, "•ns.Get", "𝕩"); + x = name_normalize(x); B r = ns_getNU(w, x, true); decG(w); decG(x); return inc(r); } B nHas_c2(B t, B w, B x) { if (!isNsp(w)) thrM("•ns.Has: 𝕨 must be a namespace"); - vfyStr(x, "•ns.Get", "𝕩"); + vfyStr(x, "•ns.Has", "𝕩"); + x = name_normalize(x); B r = ns_getNU(w, x, false); decG(w); decG(x); return m_i32(!q_N(r));