diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index cfaf41a785..58051dd481 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -70,10 +70,10 @@ u3_noun u3qc_swp(u3_atom, u3_atom); u3_noun u3qc_sqt(u3_atom); - u3_noun po_find_prefix(char one, char two, char three); - u3_noun po_find_suffix(char one, char two, char three); - void po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); - void po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); + u3_noun u3_po_find_prefix(c3_y one, c3_y two, c3_y three); + u3_noun u3_po_find_suffix(c3_y one, c3_y two, c3_y three); + void u3_po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); + void u3_po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); /** Tier 4. **/ diff --git a/pkg/urbit/jets/c/po.c b/pkg/urbit/jets/c/po.c index 95e359f87f..c907ad48a1 100644 --- a/pkg/urbit/jets/c/po.c +++ b/pkg/urbit/jets/c/po.c @@ -4,7 +4,7 @@ #include "all.h" u3_noun -po_find_prefix(char one, char two, char three) { +u3_po_find_prefix(c3_y one, c3_y two, c3_y three) { switch (one) { case 'b': switch (two) { case 'a': switch (three) { @@ -411,7 +411,7 @@ po_find_prefix(char one, char two, char three) { } void -po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) +u3_po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) { switch (id) { case 0: *a = 'd'; *b = 'o'; *c = 'z'; break; @@ -674,9 +674,8 @@ po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) } } - u3_noun -po_find_suffix(char one, char two, char three) { +u3_po_find_suffix(c3_y one, c3_y two, c3_y three) { switch (one) { case 'b': switch (two) { case 'e': switch (three) { @@ -1083,7 +1082,7 @@ po_find_suffix(char one, char two, char three) { } void -po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) +u3_po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) { switch (id) { case 0: *a = 'z'; *b = 'o'; *c = 'd'; break; @@ -1352,21 +1351,20 @@ u3qc_po_ins(u3_noun a) c3_y byt_y[3]; u3r_bytes(0, 3, byt_y, a); - return po_find_prefix(byt_y[0], byt_y[1], byt_y[2]); + return u3_po_find_prefix(byt_y[0], byt_y[1], byt_y[2]); } u3_noun u3wcp_ins(u3_noun cor) { u3_noun a; + u3x_mean(cor, u3x_sam, &a, 0); - if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) || - (c3n == u3ud(a)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qc_po_ins(a); + if ( c3n == u3ud(a) ) { + return u3m_bail(c3__fail); } + + return u3qc_po_ins(a); } u3_noun @@ -1375,21 +1373,20 @@ u3qc_po_ind(u3_noun a) c3_y byt_y[3]; u3r_bytes(0, 3, byt_y, a); - return po_find_suffix(byt_y[0], byt_y[1], byt_y[2]); + return u3_po_find_suffix(byt_y[0], byt_y[1], byt_y[2]); } u3_noun u3wcp_ind(u3_noun cor) { u3_noun a; + u3x_mean(cor, u3x_sam, &a, 0); - if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) || - (c3n == u3ud(a)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qc_po_ind(a); + if ( c3n == u3ud(a) ) { + return u3m_bail(c3__fail); } + + return u3qc_po_ind(a); } u3_noun @@ -1405,7 +1402,7 @@ u3wcp_tos(u3_noun cor) } else { c3_y byt_y[3]; - po_to_prefix(a, &byt_y[0], &byt_y[1], &byt_y[2]); + u3_po_to_prefix(a, &byt_y[0], &byt_y[1], &byt_y[2]); return (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); } } @@ -1422,7 +1419,7 @@ u3wcp_tod(u3_noun cor) return u3m_bail(c3__exit); } else { c3_y byt_y[3]; - po_to_suffix(a, &byt_y[0], &byt_y[1], &byt_y[2]); + u3_po_to_suffix(a, &byt_y[0], &byt_y[1], &byt_y[2]); return (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); } } diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index f20d446120..05b4f39383 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -6,7 +6,7 @@ #include static -c3_y to_digit(u3_atom tig) +c3_y to_digit(c3_y tig) { if (tig >= 10) { return 87 + tig; @@ -16,7 +16,7 @@ c3_y to_digit(u3_atom tig) } static -c3_y to_w_digit(u3_atom tig) +c3_y to_w_digit(c3_y tig) { if (tig == 63) { return '~'; @@ -34,7 +34,7 @@ c3_y to_w_digit(u3_atom tig) // gives the characters for a four 'digit' small hex atom. static void -_x_co_four(u3_atom src, c3_y* a, c3_y* b, c3_y* c, c3_y* d) +_x_co_four(c3_w src, c3_y* a, c3_y* b, c3_y* c, c3_y* d) { *d = to_digit(src & 0xF); src >>= 4; @@ -48,7 +48,7 @@ _x_co_four(u3_atom src, c3_y* a, c3_y* b, c3_y* c, c3_y* d) // The parser always prints two digits on 0 in y-co. static void -_y_co_two(u3_atom src, c3_y* a, c3_y* b) +_y_co_two(c3_w src, c3_y* a, c3_y* b) { *b = to_digit(src % 10); *a = to_digit(src / 10); @@ -57,7 +57,7 @@ _y_co_two(u3_atom src, c3_y* a, c3_y* b) // static u3_noun -_add_year(u3_atom year, u3_noun out) +_add_year(c3_w year, u3_noun out) { while (year > 0) { out = u3nc(to_digit(year % 10), out); @@ -69,7 +69,7 @@ _add_year(u3_atom year, u3_noun out) static u3_noun -_print_da(u3_atom cor, u3_atom raw_da) +_print_da(u3_noun cor, u3_atom raw_da) { u3_noun hok = u3j_cook("u3we_scow_print_da", u3k(cor), "yore"); u3_noun yod = u3n_slam_on(hok, u3k(raw_da)); @@ -89,7 +89,7 @@ _print_da(u3_atom cor, u3_atom raw_da) return u3m_bail(c3__exit); } - if (c3n == u3r_sing(f, 0)) { + if (f != 0) { u3_noun f_list = u3qb_flop(f); for (u3_noun cur = f_list; @@ -113,10 +113,7 @@ _print_da(u3_atom cor, u3_atom raw_da) } // if there isn't a hex list and the h/m/s are all 0, skip printing hours. - if (c3n == u3r_sing(f, 0) || - c3n == u3r_sing(hour, 0) || - c3n == u3r_sing(min, 0) || - c3n == u3r_sing(sec, 0)) { + if (f != 0 || hour != 0 || min != 0 || sec != 0) { if (!_(u3a_is_cat(hour)) || !_(u3a_is_cat(min)) || !_(u3a_is_cat(sec))) { @@ -155,15 +152,17 @@ _print_da(u3_atom cor, u3_atom raw_da) c3_y da, db; _y_co_two(day, &da, &db); out = u3nc(db, out); - if (da != '0') + if (da != '0') { out = u3nc(da, out); + } out = u3nc('.', out); c3_y ma, mb; _y_co_two(month, &ma, &mb); out = u3nc(mb, out); - if (ma != '0') + if (ma != '0') { out = u3nc(ma, out); + } out = u3nc('.', out); // suffix the year with a '-' for BC dates @@ -191,27 +190,29 @@ _print_p(u3_atom cor, u3_atom p) u3_atom sxz = u3n_slam_on(hok, u3k(p)); // Simple galaxy case - if (c3y == u3qa_lte(u3k(sxz), 256)) { + if (c3y == u3qa_lte(sxz, 256)) { c3_y a, b, c; - po_to_suffix(sxz, &a, &b, &c); + u3_po_to_suffix(sxz, &a, &b, &c); u3z(sxz); return u3nq('~', a, b, u3nc(c, 0)); } - u3_atom dyy = u3qc_met(4, u3k(sxz)); + u3_atom dyy = u3qc_met(4, sxz); if (!_(u3a_is_cat(dyy))) { + u3z(sxz); + u3z(dyy); return u3_none; } u3_noun list = 0; for (c3_w imp = 0; imp != dyy; ++imp) { - u3_noun log = u3qc_end(4, 1, u3k(sxz)); - u3_noun prefix = u3qc_rsh(3, 1, u3k(log)); - u3_noun suffix = u3qc_end(3, 1, log); + c3_w log = u3qc_end(4, 1, sxz); + c3_w prefix = u3qc_rsh(3, 1, log); + c3_w suffix = u3qc_end(3, 1, log); c3_y a, b, c, d, e, f; - po_to_prefix(prefix, &a, &b, &c); - po_to_suffix(suffix, &d, &e, &f); + u3_po_to_prefix(prefix, &a, &b, &c); + u3_po_to_suffix(suffix, &d, &e, &f); if (imp % 4 == 0) { if (imp != 0) { @@ -235,11 +236,9 @@ u3_noun _print_ud(u3_atom ud) { // number of characters printed "between" periods. - int between = 0; + c3_i between = 0; u3_atom list = 0; - u3k(ud); - do { if (between == 3) { list = u3nc('.', list); @@ -259,7 +258,7 @@ u3_noun _print_uv(u3_atom uv) { // number of characters printed "between" periods. - int between = 0; + c3_i between = 0; u3_atom list = 0; u3k(uv); @@ -270,7 +269,7 @@ _print_uv(u3_atom uv) between = 0; } - u3_atom tig = u3qa_mod(uv, 32); + c3_y tig = u3qa_mod(uv, 32); list = u3nc(to_digit(tig), list); between++; uv = u3ka_div(uv, 32); @@ -284,7 +283,7 @@ u3_noun _print_uw(u3_atom uw) { // number of characters printed "between" periods. - int between = 0; + c3_i between = 0; u3_atom list = 0; u3k(uw); @@ -295,7 +294,7 @@ _print_uw(u3_atom uw) between = 0; } - u3_atom tig = u3qa_mod(uw, 64); + c3_y tig = u3qa_mod(uw, 64); list = u3nc(to_w_digit(tig), list); between++; uw = u3ka_div(uw, 64); @@ -315,10 +314,6 @@ u3we_scow(u3_noun cor) return u3m_bail(c3__exit); } - if (!_(u3a_is_cat(mod))) { - return u3_none; - } - switch (mod) { case c3__da: return _print_da(cor, atom); @@ -351,10 +346,6 @@ u3we_scot(u3_noun cor) return u3m_bail(c3__exit); } - if (!_(u3a_is_cat(mod))) { - return u3_none; - } - u3_noun tape; switch (mod) { case c3__da: diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 0e8aa11075..b2e8133c45 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -17,7 +17,7 @@ _parse_ud(u3_noun txt) { u3a_free(c); return u3_none; } - c3_w total = cur[0] - '0'; + u3_atom total = cur[0] - '0'; cur++; int since_last_period = 0; @@ -121,7 +121,7 @@ _parse_p(u3_noun cor, u3_noun txt) { // check for validity since its already a (unit @). if (*cur == 0) { u3a_free(c); - return po_find_suffix(a_one, a_two, a_three); + return u3_po_find_suffix(a_one, a_two, a_three); } TRY_GET_SYLLABLE(b); @@ -129,8 +129,8 @@ _parse_p(u3_noun cor, u3_noun txt) { // There were only two syllables. If they are a valid prefix and suffix, then // it's a star. if (*cur == 0) { - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); u3_atom combined = combine(b_part, a_part); u3a_free(c); return combined; @@ -146,10 +146,10 @@ _parse_p(u3_noun cor, u3_noun txt) { TRY_GET_SYLLABLE(d); if (*cur == 0) { - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); - u3_noun c_part = po_find_prefix(c_one, c_two, c_three); - u3_noun d_part = po_find_suffix(d_one, d_two, d_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = u3_po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = u3_po_find_suffix(d_one, d_two, d_three); u3_noun m = combine(d_part, combine(c_part, combine(b_part, a_part))); u3a_free(c); @@ -163,7 +163,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); - return u3nc(0, u3n_slam_on(hok, u3k(raw))); + return u3nc(0, u3n_slam_on(hok, raw)); } // There must now be a - or it is invalid. @@ -177,12 +177,12 @@ _parse_p(u3_noun cor, u3_noun txt) { TRY_GET_SYLLABLE(f); if (*cur == 0) { - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); - u3_noun c_part = po_find_prefix(c_one, c_two, c_three); - u3_noun d_part = po_find_suffix(d_one, d_two, d_three); - u3_noun e_part = po_find_prefix(e_one, e_two, e_three); - u3_noun f_part = po_find_suffix(f_one, f_two, f_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = u3_po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = u3_po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = u3_po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = u3_po_find_suffix(f_one, f_two, f_three); u3_noun m = combine(f_part, combine(e_part, combine(d_part, combine(c_part, combine(b_part, a_part))))); @@ -196,7 +196,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3z(m); u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); - return u3nc(0, u3n_slam_on(hok, u3k(raw))); + return u3nc(0, u3n_slam_on(hok, raw)); } // There must now be a - or it is invalid. @@ -210,14 +210,14 @@ _parse_p(u3_noun cor, u3_noun txt) { TRY_GET_SYLLABLE(h); if (*cur == 0) { - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); - u3_noun c_part = po_find_prefix(c_one, c_two, c_three); - u3_noun d_part = po_find_suffix(d_one, d_two, d_three); - u3_noun e_part = po_find_prefix(e_one, e_two, e_three); - u3_noun f_part = po_find_suffix(f_one, f_two, f_three); - u3_noun g_part = po_find_prefix(g_one, g_two, g_three); - u3_noun h_part = po_find_suffix(h_one, h_two, h_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = u3_po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = u3_po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = u3_po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = u3_po_find_suffix(f_one, f_two, f_three); + u3_noun g_part = u3_po_find_prefix(g_one, g_two, g_three); + u3_noun h_part = u3_po_find_suffix(h_one, h_two, h_three); u3_noun m = combine(h_part, combine(g_part, combine(f_part, combine(e_part, combine(d_part, combine(c_part, @@ -232,7 +232,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3z(m); u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); - return u3nc(0, u3n_slam_on(hok, u3k(raw))); + return u3nc(0, u3n_slam_on(hok, raw)); } // At this point, the only thing it could be is a long comet, of the form @@ -266,22 +266,22 @@ _parse_p(u3_noun cor, u3_noun txt) { // We have a long comet. Time to jam it all together. We rely on combine() // for the error checking and we don't have to scramble comet names. - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); - u3_noun c_part = po_find_prefix(c_one, c_two, c_three); - u3_noun d_part = po_find_suffix(d_one, d_two, d_three); - u3_noun e_part = po_find_prefix(e_one, e_two, e_three); - u3_noun f_part = po_find_suffix(f_one, f_two, f_three); - u3_noun g_part = po_find_prefix(g_one, g_two, g_three); - u3_noun h_part = po_find_suffix(h_one, h_two, h_three); - u3_noun i_part = po_find_prefix(i_one, i_two, i_three); - u3_noun j_part = po_find_suffix(j_one, j_two, j_three); - u3_noun k_part = po_find_prefix(k_one, k_two, k_three); - u3_noun l_part = po_find_suffix(l_one, l_two, l_three); - u3_noun m_part = po_find_prefix(m_one, m_two, m_three); - u3_noun n_part = po_find_suffix(n_one, n_two, n_three); - u3_noun o_part = po_find_prefix(o_one, o_two, o_three); - u3_noun p_part = po_find_suffix(p_one, p_two, p_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = u3_po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = u3_po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = u3_po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = u3_po_find_suffix(f_one, f_two, f_three); + u3_noun g_part = u3_po_find_prefix(g_one, g_two, g_three); + u3_noun h_part = u3_po_find_suffix(h_one, h_two, h_three); + u3_noun i_part = u3_po_find_prefix(i_one, i_two, i_three); + u3_noun j_part = u3_po_find_suffix(j_one, j_two, j_three); + u3_noun k_part = u3_po_find_prefix(k_one, k_two, k_three); + u3_noun l_part = u3_po_find_suffix(l_one, l_two, l_three); + u3_noun m_part = u3_po_find_prefix(m_one, m_two, m_three); + u3_noun n_part = u3_po_find_suffix(n_one, n_two, n_three); + u3_noun o_part = u3_po_find_prefix(o_one, o_two, o_three); + u3_noun p_part = u3_po_find_suffix(p_one, p_two, p_three); u3a_free(c); @@ -358,7 +358,7 @@ _parse_da(u3_noun cor, u3_noun txt) { CONSUME('.'); // Parse out a two digit month (mot:ag). Either a single digit 1-9 or 1[012]. - c3_w month; + c3_y month; if (cur[0] == '1') { if (cur[1] <= '2' && cur[1] >= '0') { // This is a two number month. @@ -414,18 +414,18 @@ _parse_da(u3_noun cor, u3_noun txt) { CONSUME('.'); // Now we have to parse a list of hexidecimal numbers 0-f of length 4 only - // (zero padded otherwise) separated by dots. Wat. + // (zero padded otherwise) separated by dots. u3_atom list = 0; while (1) { // Parse 4 hex digits - int one, two, three, four; + c3_y one, two, three, four; PARSE_HEX_DIGIT(one); PARSE_HEX_DIGIT(two); PARSE_HEX_DIGIT(three); PARSE_HEX_DIGIT(four); - int current = (one << 12) + (two << 8) + (three << 4) + four; - list = u3nc(current, list); + c3_w current = (one << 12) + (two << 8) + (three << 4) + four; + list = u3nc(u3i_words(1, ¤t), list); if (cur[0] == 0) { u3a_free(c); @@ -489,10 +489,6 @@ u3we_slaw(u3_noun cor) return u3m_bail(c3__exit); } - if (!_(u3a_is_cat(mod))) { - return u3_none; - } - switch (mod) { case c3__da: return _parse_da(cor, txt);