diff --git a/f/bail.c b/f/bail.c index 9bb3669ba..41ddb9802 100644 --- a/f/bail.c +++ b/f/bail.c @@ -6,7 +6,7 @@ /* u2_bl_bail(): bail out. ** -** Bail codes: +** Bail codes: ** ** c3__exit for normal exit with correct trace ** c3__fail for abnormal failure without assumptions @@ -61,7 +61,7 @@ u2_bl_drop(u2_wire wir_r) /* u2_bl_error(): simple string error. */ -u2_noun +u2_noun u2_bl_error(u2_wire wir_r, const c3_c* err_c) // retain { @@ -148,10 +148,10 @@ u2_bi_frag(u2_ray wir_r, } else return c; } -/* u2_bi_met(): +/* u2_bi_met(): ** ** Return the size of (b) in bits, rounded up to -** (1 << a_y). +** (1 << a_y). ** ** For example, (a_y == 3) returns the size in bytes. */ @@ -192,7 +192,7 @@ u2_bi_byte(u2_ray wir_r, return u2_byte(a_w, b); } - + /* u2_bi_bytes(): ** ** Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c). @@ -276,7 +276,7 @@ u2_bn_string(u2_ray wir_r, return u2_bl_good(wir_r, u2_rl_string(wir_r, a_c)); } -/* u2_bn_cell(): +/* u2_bn_cell(): ** ** Produce the cell [a b]. */ @@ -343,7 +343,7 @@ u2_bn_list(u2_ray wir_r, ...) } } } - + /* u2_bn_molt(): ** ** Mutate `som` with a 0-terminated list of axis, noun pairs. @@ -499,7 +499,7 @@ u2_bn_molt(u2_wire wir_r, */ return _molt_apply(wir_r, som, len_w, pms_m); } - + /* u2_bn_mp(): ** ** Copy the GMP integer [a] into an atom. @@ -538,8 +538,8 @@ u2_bn_nock(u2_ray wir_r, u2_noun bus, u2_noun fol) /* u2_bn_mang(): ** ** Kick a gate, substituting axes with nouns. -** -** Caller retains arguments; function transfers result. +** +** Caller retains arguments; function transfers result. */ u2_noun u2_bn_mang(u2_wire wir_r, @@ -561,7 +561,7 @@ u2_bn_mang(u2_wire wir_r, /* u2_bn_hook(): ** ** Execute hook from core. -*/ +*/ u2_noun u2_bn_hook(u2_wire wir_r, u2_noun cor, @@ -621,7 +621,7 @@ u2_bn_cook(u2_wire wir_r, } } -/* u2_bn_mong(): +/* u2_bn_mong(): ** ** Call by gate and sample (new convention). ** Caller retains `gat`, transfers `sam`. @@ -692,7 +692,7 @@ u2_bn_wait(u2_wire wir_r, #endif } -/* u2_bn_qual(): +/* u2_bn_qual(): ** ** Produce the quadruple [a b c d]. */ @@ -706,7 +706,7 @@ u2_bn_qual(u2_ray wir_r, return u2_bl_good(wir_r, u2_rl_qual(wir_r, a, b, c, d)); } -/* u2_bn_quil(): +/* u2_bn_quil(): ** ** Produce the quintuple [a b c d]. */ @@ -725,7 +725,7 @@ u2_bn_quil(u2_ray wir_r, ** ** Create an atomic string from a list of bytes. */ -u2_noun +u2_noun u2_bn_tape(u2_ray wir_r, u2_list lit) { @@ -796,7 +796,7 @@ u2_bn_heximal(u2_ray wir_r, return u2_bn_mp(wir_r, mp); } -/* u2_bn_trel(): +/* u2_bn_trel(): ** ** Produce the triple [a b c]. */ @@ -849,7 +849,7 @@ u2_bn_slaq(u2_wire wir_r, ** Factor `a` as a cell `[b c]. */ void -u2_bi_cell(u2_wire wir_r, +u2_bi_cell(u2_wire wir_r, u2_noun a, u2_noun* b, u2_noun* c) @@ -864,7 +864,7 @@ u2_bi_cell(u2_wire wir_r, ** Factor `a` as a quadruple `[b c d e]`. */ void -u2_bi_qual(u2_wire wir_r, +u2_bi_qual(u2_wire wir_r, u2_noun a, u2_noun* b, u2_noun* c, diff --git a/f/benx.c b/f/benx.c index 410bc919d..8bd8091fd 100644 --- a/f/benx.c +++ b/f/benx.c @@ -3,7 +3,7 @@ ** This file is in the public domain. */ #include "all.h" - + /* u2_bx_boot(): reset the performance log. */ void @@ -27,7 +27,7 @@ u2_bx_boot(u2_ray wir_r) u2_benx_be(bex_r, c3_w, wax_w) = 0; u2_benx_be(bex_r, c3_w, lif_w) = u2_soup_liv_w(u2_rail_rut_r(wir_r)); - u2_benx_be(bex_r, c3_w, bos_w) = + u2_benx_be(bex_r, c3_w, bos_w) = u2_soup_liv_w(u2_rail_rut_r(u2_wire_bas_r(wir_r))); { @@ -57,7 +57,7 @@ u2_bx_boot(u2_ray wir_r) u2_bean u2_bx_post(u2_ray wir_r, u2_noun* zat, - u2_noun* zof, + u2_noun* zof, c3_d* sap_d, c3_d* cop_d, c3_d* det_d, @@ -86,10 +86,10 @@ u2_bx_post(u2_ray wir_r, *wax_w = u2_benx_at(bex_r, wax_w); - *viq_ws = u2_soup_liv_w(u2_rail_rut_r(wir_r)) - + *viq_ws = u2_soup_liv_w(u2_rail_rut_r(wir_r)) - u2_benx_be(bex_r, c3_w, lif_w); - *zor_ws = u2_soup_liv_w(u2_rail_rut_r(u2_wire_bas_r(wir_r))) - + *zor_ws = u2_soup_liv_w(u2_rail_rut_r(u2_wire_bas_r(wir_r))) - u2_benx_be(bex_r, c3_w, bos_w); sec_w = u2_benx_at(bex_r, sec_w); @@ -131,7 +131,7 @@ u2_bx_step(u2_ray wir_r) /* u2_bx_copy(): note `cop` copied words. */ -void +void u2_bx_copy(u2_ray wir_r, c3_w cop_w) { @@ -146,7 +146,7 @@ u2_bx_copy(u2_ray wir_r, /* u2_bx_dent(): note `det` identical comparisons. */ -void +void u2_bx_dent(u2_ray wir_r, c3_w det_w) { @@ -179,7 +179,7 @@ u2_bx_sink(u2_ray wir_r) /* u2_bx_rise(): go shallower (return) in the C stack. */ -void +void u2_bx_rise(u2_ray wir_r) { u2_ray bex_r; @@ -232,7 +232,7 @@ u2_bx_spot(u2_ray wir_r, { u2_rl_lose(wir_r, hod); return; - } + } else { u2_noun sud = u2_rl_take(bas_r, hod); @@ -255,7 +255,7 @@ u2_bx_spot_out(u2_ray wir_r) (0 == (bas_r = u2_wire_bas_r(wir_r))) ) { return; - } + } else { u2_noun zat = u2_benx_at(bex_r, zat); @@ -279,15 +279,15 @@ u2_bx_bean_ent(u2_ray wir_r, { u2_rl_lose(wir_r, hod); return; - } + } else { u2_noun naz = u2_rl_uniq(wir_r, hod); u2_rl_lose(wir_r, hod); - if ( u2_none != naz ) { + if ( u2_none != naz ) { u2_noun zof = u2_rc (bas_r, u2_rx(bas_r, naz), u2_rx(bas_r, u2_benx_at(bex_r, zof))); - + if ( u2_none != zof ) { u2_rl_lose(bas_r, u2_benx_at(bex_r, zof)); u2_benx_at(bex_r, zof) = zof; @@ -305,7 +305,7 @@ u2_bx_bean_out(u2_ray wir_r) (0 == (bas_r = u2_wire_bas_r(wir_r))) ) { return; - } + } else { u2_noun zof = u2_benx_at(bex_r, zof); @@ -369,7 +369,7 @@ _print_wall(u2_noun wal, wal = u2_t(wal); } } - + /* u2_bx_loaf(): print debug loaf. */ void @@ -468,7 +468,7 @@ _bx_print_superdecimal_d(c3_d d) printf(":"); _bx_print_superdecimal_w((c3_w)(d & 0xffffffffULL)); } - else { + else { _bx_print_superdecimal_w((c3_w) d); } } @@ -485,13 +485,13 @@ u2_bx_show(u2_ray wir_r) if ( u2_no == u2_bx_post(wir_r, &zat, &zof, - &sap_d, - &cop_d, - &det_d, - &jax_d, - &use_d, - &wax_w, - &viq_ws, + &sap_d, + &cop_d, + &det_d, + &jax_d, + &use_d, + &wax_w, + &viq_ws, &zor_ws, &ums_w) ) { @@ -506,7 +506,7 @@ u2_bx_show(u2_ray wir_r) // u2_noun h_zat = u2_h(zat); u2_noun t_zat = u2_t(zat); - printf("place: %d.%d:%d.%d\n", + printf("place: %d.%d:%d.%d\n", u2_h(u2_h(t_zat)), u2_t(u2_h(t_zat)), u2_h(u2_t(t_zat)), u2_t(u2_t(t_zat))); u2_rl_lose(bas_r, zat); @@ -554,7 +554,7 @@ u2_bx_show(u2_ray wir_r) _bx_print_superdecimal_ws(zor_ws); printf(" held"); } - + printf("; "); _bx_print_superdecimal_w(ums_w); printf(" ms>\n"); diff --git a/f/cash.c b/f/cash.c index 46fb6eed5..1d9e872b8 100644 --- a/f/cash.c +++ b/f/cash.c @@ -1,5 +1,5 @@ /* f/cash.c -** +** ** This file is in the public domain. */ #include "all.h" @@ -221,7 +221,7 @@ _cs_find_1(u2_rail ral_r, if ( u2_slot_is_a(tol_r) && (sel_m == u2_slot_a_sel(tol_r)) && - (u2_yes == _cs_find_sap(ral_r, tol_r, sam)) ) + (u2_yes == _cs_find_sap(ral_r, tol_r, sam)) ) { return u2_slot_a_pro(tol_r); } @@ -231,7 +231,7 @@ _cs_find_1(u2_rail ral_r, while ( j_w != i_w ); return u2_none; - } + } else { lot_r = u2_slot_b_sid_i(lot_r, i_w); sif_w += 4; @@ -277,17 +277,17 @@ _cs_find_2(u2_rail ral_r, if ( u2_slot_is_a(tol_r) && (sel_m == u2_slot_a_sel(tol_r)) && - (u2_yes == _cs_find_sap_cell(ral_r, tol_r, a, b)) ) + (u2_yes == _cs_find_sap_cell(ral_r, tol_r, a, b)) ) { return u2_slot_a_pro(tol_r); } - + j_w = ((j_w + 1) & 15); } while ( j_w != i_w ); return u2_none; - } + } else { lot_r = u2_slot_b_sid_i(lot_r, i_w); sif_w += 4; @@ -337,13 +337,13 @@ _cs_find_2m(u2_rail ral_r, { return u2_slot_a_pro(tol_r); } - + j_w = ((j_w + 1) & 15); } while ( j_w != i_w ); return u2_none; - } + } else { lot_r = u2_slot_b_sid_i(lot_r, i_w); sif_w += 4; @@ -394,13 +394,13 @@ _cs_find_3(u2_rail ral_r, { return u2_slot_a_pro(tol_r); } - + j_w = ((j_w + 1) & 15); } while ( j_w != i_w ); return u2_none; - } + } else { lot_r = u2_slot_b_sid_i(lot_r, i_w); sif_w += 4; @@ -452,13 +452,13 @@ _cs_find_4(u2_rail ral_r, { return u2_slot_a_pro(tol_r); } - + j_w = ((j_w + 1) & 15); } while ( j_w != i_w ); return u2_none; - } + } else { lot_r = u2_slot_b_sid_i(lot_r, i_w); sif_w += 4; @@ -626,7 +626,7 @@ _cs_save_b(u2_rail ral_r, if ( u2_slot_gunk_is_coll(gun_w) ) { if ( (u2_slot_b_rag(lot_r) >= u2_tune_cash_hi) && - (sif_w != 32) ) + (sif_w != 32) ) { _cs_more_b(ral_r, lot_r, sif_w); goto top; @@ -660,10 +660,10 @@ _cs_save_b(u2_rail ral_r, return u2_no; } } else { - u2_bean ave = _cs_save_in(ral_r, - u2_slot_b_sid_i(lot_r, i_w), - key_w, - (sif_w + 4), + u2_bean ave = _cs_save_in(ral_r, + u2_slot_b_sid_i(lot_r, i_w), + key_w, + (sif_w + 4), sel_m, sap, pro); if ( u2_yes == ave ) { u2_slot_b_rag(lot_r) += 1; @@ -685,7 +685,7 @@ _cs_save_a(u2_rail ral_r, u2_noun pro) // retain { if ( (sel_m == u2_slot_a_sel(lot_r)) && - (u2_yes == _cs_find_sap(ral_r, lot_r, u2_h(sap)) ) ) + (u2_yes == _cs_find_sap(ral_r, lot_r, u2_h(sap)) ) ) { if ( u2_no == u2_sing(pro, u2_slot_a_pro(lot_r)) ) { u2_rz(ral_r, u2_slot_a_pro(lot_r)); @@ -850,8 +850,8 @@ u2_cs_save_qual(u2_rail ral_r, u2_noun d, // retain u2_noun pro) // transfer { - u2_noun sam = u2_rq(ral_r, u2_rx(ral_r, a), - u2_rx(ral_r, b), + u2_noun sam = u2_rq(ral_r, u2_rx(ral_r, a), + u2_rx(ral_r, b), u2_rx(ral_r, c), u2_rx(ral_r, d)); u2_noun ret = u2_cs_save(ral_r, lot_r, sel_m, sam, pro); diff --git a/f/chad.c b/f/chad.c index 0f69ae2eb..c327f2c3c 100644 --- a/f/chad.c +++ b/f/chad.c @@ -1,5 +1,5 @@ /* f/chad.c -** +** ** This file is in the public domain. */ #include "all.h" @@ -124,7 +124,7 @@ u2_ch_find_cell(u2_ray cad_r, continue; } } - else if ( u2_yes == u2_dust(nom) && + else if ( u2_yes == u2_dust(nom) && (u2_yes == u2_sing(hed, u2_h(nom))) && (u2_yes == u2_sing(tal, u2_t(nom))) ) { @@ -186,7 +186,7 @@ u2_ch_find_mixt(u2_ray cad_r, continue; } } - else if ( u2_yes == u2_dust(nom) && + else if ( u2_yes == u2_dust(nom) && (u2_yes == u2_sing_c(hed_c, u2_h(nom))) && (u2_yes == u2_sing(tal, u2_t(nom))) ) { @@ -244,7 +244,7 @@ _ch_save(u2_ray ral_r, *u2_at(per_r, u2_loom_pear, nam) = nim; *u2_at(per_r, u2_loom_pear, val) = vil; return u2_yes; - } + } else { off_w += 4; continue; @@ -321,7 +321,7 @@ u2_ch_save_cell(u2_ray ral_r, { u2_weak nim, vil; - if ( u2_none == (nim = u2_rl_cell(ral_r, u2_rl_ice(ral_r, hed), + if ( u2_none == (nim = u2_rl_cell(ral_r, u2_rl_ice(ral_r, hed), u2_rl_ice(ral_r, tal))) ) { return u2_none; @@ -354,7 +354,7 @@ u2_ch_save_mixt(u2_ray ral_r, { u2_weak nim, vil; - if ( u2_none == (nim = u2_rl_cell(ral_r, u2_rl_string(ral_r, hed_c), + if ( u2_none == (nim = u2_rl_cell(ral_r, u2_rl_string(ral_r, hed_c), u2_rl_ice(ral_r, tal))) ) { return u2_none; diff --git a/f/coal.c b/f/coal.c index 59e0aed8f..fb4d18977 100644 --- a/f/coal.c +++ b/f/coal.c @@ -54,7 +54,7 @@ if ( buf_c ) u2_cr_bytes(0, met_w, (c3_y*)(buf_c + pos_w), hut); return (pos_w + met_w); - } + } else { c3_w met_w = u2_cr_met(3, u2h(hut)); c3_w end_w = _cf_path_1(buf_c, pos_w, u2t(hut)); @@ -76,8 +76,8 @@ } u2_noun -u2_cf_path(c3_c* top_c, - c3_c* ext_c, +u2_cf_path(c3_c* top_c, + c3_c* ext_c, u2_noun tah) { c3_w top_w = strlen(top_c); @@ -95,7 +95,7 @@ u2_cf_path(c3_c* top_c, pos_w = _cf_path_1(buf_c, pos_w, tah); if ( ext_c ) { - buf_c[pos_w++] = '.'; + buf_c[pos_w++] = '.'; strncpy(buf_c + pos_w, ext_c, buf_w - pos_w); } else { buf_c[pos_w] = 0; @@ -107,7 +107,7 @@ u2_cf_path(c3_c* top_c, u2_cz(tah); return pas; } - + /* u2_cf_flat_date(): date for `pas`. Unix time * 10^6, or 0. */ c3_d @@ -169,7 +169,7 @@ u2_cf_flat_load(u2_noun mod, } close(fid_i); - fil = u2_ci_bytes(fln_w, (c3_y *)fil_c); + fil = u2_ci_bytes(fln_w, (c3_y *)fil_c); free(fil_c); return fil; @@ -178,7 +178,7 @@ u2_cf_flat_load(u2_noun mod, /* u2_cf_list(): list all the files in directory `pas`. List of cask. */ -u2_noun +u2_noun u2_cf_list(u2_noun pas) { c3_c* pas_c = u2_cr_string(pas); @@ -200,7 +200,7 @@ u2_cf_list(u2_noun pas) if ( readdir_r(dir_d, &ent_n, &out_n) != 0 ) { perror(pas_c); return u2_cm_bail(c3__fail); - } + } else if ( !out_n ) { break; } @@ -213,10 +213,10 @@ u2_cf_list(u2_noun pas) } } -/* u2_cf_flat_save(): save `som` as `mod` at `pas`. +/* u2_cf_flat_save(): save `som` as `mod` at `pas`. */ u2_bean -u2_cf_flat_save(u2_noun mod, +u2_cf_flat_save(u2_noun mod, u2_noun pas, u2_noun som) { @@ -241,7 +241,7 @@ u2_cf_flat_save(u2_noun mod, fil_y = malloc(fln_w); u2_cr_bytes(0, fln_w, fil_y, som); u2_cz(som); - + if ( fln_w != write(fid_i, fil_y, fln_w) ) { return u2_no; } @@ -297,7 +297,7 @@ u2_ci_tape(const c3_c* txt_c) /* u2_cr_string(): `a` as malloced C string. */ -c3_c* +c3_c* u2_cr_string(u2_atom a) { c3_w met_w = u2_cr_met(3, a); @@ -310,7 +310,7 @@ u2_cr_string(u2_atom a) /* u2_cr_tape(): `a`, a list of bytes, as malloced C string. */ -c3_y* +c3_y* u2_cr_tape(u2_noun a) { u2_noun b; @@ -432,7 +432,7 @@ u2_cm_rind() // Save the old stack and actions. // u2_kite_tax(kit_r) = u2k(u2_wire_tax(u2_Wire)); - u2_kite_don(kit_r) = u2k(u2_wrac_at(u2_Wire, duz.don)); + u2_kite_don(kit_r) = u2k(u2_wrac_at(u2_Wire, duz.don)); return u2_at_cord(u2_kite_buf_r(kit_r), c3_wiseof(jmp_buf)); } @@ -451,7 +451,7 @@ _cm_jack(u2_noun old, u2_noun nuw) if ( u2ft(cur) == old ) { u2z(old); u2ft(cur) = u2_nul; - + return nuw; } else { cur = u2ft(cur); @@ -468,7 +468,7 @@ _cm_depth(u2_noun old, u2_noun nuw) c3_w dep_w = 0; while ( nuw != old ) { - c3_assert(u2_yes == u2du(nuw)); + c3_assert(u2_yes == u2du(nuw)); nuw = u2t(nuw); dep_w++; @@ -479,14 +479,14 @@ _cm_depth(u2_noun old, u2_noun nuw) /* u2_cm_wail(): produce and reset the local trace, without bailing. */ -u2_noun +u2_noun u2_cm_wail() { u2_ray kit_r = u2_wire_kit_r(u2_Wire); u2_noun old = u2_kite_tax(u2_wire_kit_r(u2_Wire)); u2_noun nuw = u2_wire_tax(u2_Wire); u2_noun jaq; - + jaq = _cm_jack(old, nuw); // c3_assert(1 == u2_rl_refs(u2_Wire, old)); @@ -539,7 +539,7 @@ u2_cm_bail(c3_l how_l) u2_wire_kit_r(u2_Wire) = u2_kite_par_r(kit_r); u2_rl_rfree(u2_Wire, kit_r); } - + // Longjmp with the how-trace pair. XX: no workee with 64-bit nouns. // { @@ -581,7 +581,7 @@ u2_cm_bowl(u2_noun how) u2_wire_kit_r(u2_Wire) = u2_kite_par_r(kit_r); u2_rl_rfree(u2_Wire, kit_r); } - + // Longjmp with the how-trace pair. XX: no workee with 64-bit nouns. // { @@ -647,7 +647,7 @@ u2_cm_mark_internal() { return u2_wr_mark(u2_Wire); } - + /* u2_cm_trac(): extract and clear stack trace. */ u2_noun @@ -695,7 +695,7 @@ u2_cm_foul(const c3_c* err_c) u2_cm_bean(u2_ci_string(err_c)); fprintf(stderr, "foul: %s\n", err_c); - return u2_bl_error(u2_Wire, err_c); + return u2_bl_error(u2_Wire, err_c); } /* u2_cn_cell(): produce the cell `[a b]`. @@ -847,7 +847,7 @@ u2_ckd_by_get(u2_noun a, u2_noun b) u2_cz(a); u2_cz(b); if ( u2_no == u2_cr_du(c) ) { - u2_cz(c); + u2_cz(c); return u2_none; } else { u2_noun pro = u2_ct(u2t(c)); @@ -866,7 +866,7 @@ u2_ckd_by_got(u2_noun a, u2_noun b) if ( u2_none == c ) { return u2_cm_bail(c3__exit); - } + } else return c; } @@ -895,7 +895,7 @@ u2_ckd_by_gas(u2_noun a, u2_noun b) u2_cz(a); u2_cz(b); if ( u2_none == c ) { return u2_cm_bail(c3__exit); - } + } else return c; } @@ -909,7 +909,7 @@ u2_ckd_in_gas(u2_noun a, u2_noun b) u2_cz(a); u2_cz(b); if ( u2_none == c ) { return u2_cm_bail(c3__exit); - } + } else return c; } @@ -923,7 +923,7 @@ u2_ckd_by_has(u2_noun a, u2_noun b) u2_cz(a); u2_cz(b); if ( u2_none == c ) { return u2_cm_bail(c3__exit); - } + } else return c; } @@ -937,7 +937,7 @@ u2_ckd_in_has(u2_noun a, u2_noun b) u2_cz(a); u2_cz(b); if ( u2_none == c ) { return u2_cm_bail(c3__exit); - } + } else return c; } @@ -951,7 +951,7 @@ u2_ckd_in_tap(u2_noun a, u2_noun b) u2_cz(a); u2_cz(b); if ( u2_none == c ) { return u2_cm_bail(c3__exit); - } + } else return c; } @@ -1018,7 +1018,7 @@ u2_ckd_in_tap(u2_noun a, u2_noun b) } u2_noun // transfer - _cue_internal(u2_wire wir_r, + _cue_internal(u2_wire wir_r, u2_atom a) // retain { u2_ray t_r = u2_cs_make(wir_r); diff --git a/f/dash.c b/f/dash.c index 8e6b1d1fd..a8bd74758 100644 --- a/f/dash.c +++ b/f/dash.c @@ -22,11 +22,11 @@ _ds_mate(u2_noun xip, // retain u2_noun axe = u2_h(pet); u2_noun led = u2_t(pet); u2_noun ruc = u2_frag(axe, cor); - + if ( (u2_none == ruc) || (u2_no == _ds_mate(led, ruc)) ) { return u2_no; } - } + } return u2_sing(bat, u2_h(cor)); } @@ -83,7 +83,7 @@ _ds_good_cop(u2_noun cop) while ( i_w < 4 ) { if ( u2_yes == u2_stud(cop) ) { return u2_yes; - } + } if ( u2_no == u2_stud(u2_h(cop)) ) { return u2_no; } @@ -160,7 +160,7 @@ _ds_chip(u2_wire wir_r, } else { u2_noun dac, bat, pet; - + /* disc: dac */ { @@ -206,7 +206,7 @@ _ds_chip(u2_wire wir_r, { if ( _0 == bud_clu ) { pet = u2_nul; - } + } else { while ( _10 == u2_h(bud_clu) ) { bud_clu = u2_t(u2_t(bud_clu)); @@ -240,7 +240,7 @@ _ds_chip(u2_wire wir_r, } } -/* u2_ds_mine(): +/* u2_ds_mine(): ** ** Register and/or save core. */ @@ -272,7 +272,7 @@ u2_ds_mine(u2_wire wir_r, bat_xip = u2_h(u2_t(xip)); #if 0 - { + { c3_c* xip_c = u2_ho_cstring(xip); fprintf(stderr, "!%s - lent %d\r\n", xip_c, u2_ckb_lent(gop)); @@ -282,7 +282,7 @@ u2_ds_mine(u2_wire wir_r, gop = u2_cs_save(bas_r, u2_wire_des_r(wir_r), 0, bat_xip, gop); { u2_noun poo = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat_xip); - + { _ds_scan(poo, cor); } @@ -345,7 +345,7 @@ u2_ds_look(u2_wire wir_r, if ( u2_none == xip ) { return u2_none; - } + } else { c3_l axe_l = _1; diff --git a/f/host.c b/f/host.c index 1d0a3fd32..29b7afec2 100644 --- a/f/host.c +++ b/f/host.c @@ -143,7 +143,7 @@ _cs_save(u2_ho_cash* cas_s, per_p->tag = som; per_p->ptr_v = ptr_v; return; - } + } else { off_w += 4; continue; @@ -313,7 +313,7 @@ _ho_mop_seal(c3_c *buf_c, u2_noun mek) } else { len_w = _ho_mop_term(buf_c, mek); - + return len_w; } } @@ -357,7 +357,7 @@ u2_ho_cstring(u2_noun xip) // retain return cos_c; } -/* u2_ho_boot(): +/* u2_ho_boot(): ** ** Boot driver system. Note that all chips and ** tools are considered permanent between reboots. @@ -368,7 +368,7 @@ _ho_boot(u2_ho_hangar *hag) _cs_init(&hag->bad_s); } -/* _ho_down(): +/* _ho_down(): ** ** Release all resources in `hag`. */ @@ -378,7 +378,7 @@ _ho_down(u2_ho_hangar *hag) _cs_free(&hag->bad_s); } -/* u2_ho_push(): +/* u2_ho_push(): ** ** Push a driver hangar (corresponding to a jet shed). */ @@ -435,7 +435,7 @@ u2_ho_warn(const c3_c* fil_c, /* _ho_abstract(): compute 31-bit jet axis in core battery. */ static c3_l -_ho_abstract(u2_noun xip, // retain +_ho_abstract(u2_noun xip, // retain const c3_c *fcs_c) // retain { if ( *fcs_c == '.' ) { @@ -443,8 +443,8 @@ _ho_abstract(u2_noun xip, // retain c3_l axe_l = 0; sscanf(fcs_c+1, "%llu", &axe_d); - if ( axe_d >> 32ULL || - ((1 << 31) & (axe_l = (c3_w)axe_d)) || + if ( axe_d >> 32ULL || + ((1 << 31) & (axe_l = (c3_w)axe_d)) || (axe_l < 2) ) { u2_ho_warn_here(); @@ -535,7 +535,7 @@ _ho_explore_dummy(u2_rail ral_r, abort(); } dry_d->cos_c = cos_c; - dry_d->sub_d = 0; + dry_d->sub_d = 0; dry_d->xip = xip; if ( !(dry_d->fan_j = malloc(sizeof(u2_ho_jet))) ) { abort(); @@ -588,9 +588,9 @@ _ho_explore_parent(u2_rail ral_r, for ( i_w = 0; par_d->sub_d[i_w].cos_c; i_w++ ) { #if 0 if ( (u2_none == par_d->sub_d[i_w].xip) && - !strcmp(cos_c, par_d->sub_d[i_w].cos_c) ) + !strcmp(cos_c, par_d->sub_d[i_w].cos_c) ) #else - if ( !strcmp(cos_c, par_d->sub_d[i_w].cos_c) ) + if ( !strcmp(cos_c, par_d->sub_d[i_w].cos_c) ) #endif { u2_ho_driver *dry_d = &par_d->sub_d[i_w]; @@ -698,15 +698,15 @@ _ho_conquer(u2_rail ral_r, ** Report result of jet test. `had` is native; `sof` is nock. */ void -u2_ho_test(u2_wire wir_r, +u2_ho_test(u2_wire wir_r, u2_ho_jet* jet_j, u2_noun cor, // retain u2_noun sof, // retain u2_noun had) // retain { - if ( (u2_none == cor) || + if ( (u2_none == cor) || ((u2_none == had) && (u2_none == sof)) || - (u2_none == jet_j->xip) ) + (u2_none == jet_j->xip) ) { return; } else { @@ -734,7 +734,7 @@ u2_ho_test(u2_wire wir_r, // c3_assert(0); #if 0 - + { u2_noun gen; @@ -776,7 +776,7 @@ u2_ho_test(u2_wire wir_r, msg_c = "nice"; } - if ( strcmp("nice", msg_c) ) + if ( strcmp("nice", msg_c) ) { fprintf(stderr, "%s: %8x: %s\n", msg_c, mug_w, cos_c); } @@ -824,7 +824,7 @@ _ho_run(u2_ray wir_r, ** ** u2_b functions may not be used. Trace must be correct. ** - ** Pro: lite jets minimize invocation latency. + ** Pro: lite jets minimize invocation latency. ** Pro: no garbage collection is required on error. ** ** Con: manual programming of large functions in lite mode is difficult. @@ -832,7 +832,7 @@ _ho_run(u2_ray wir_r, { u2_noun hoc = u2_rx(wir_r, u2_wire_tax(wir_r)); u2_ray kit_r = u2_wire_kit_r(wir_r); - u2_noun ret; + u2_noun ret; u2_wire_kit_r(wir_r) = 0; u2_tx_glu_bit(wir_r, u2_no); @@ -886,7 +886,7 @@ _ho_run(u2_ray wir_r, } u2_bl_done(wir_r, kit_r); ret = u2_none; - } + } else { u2_tx_glu_bit(wir_r, u2_no); ret = jet_j->fun_f(wir_r, cor); @@ -934,7 +934,7 @@ u2_ho_use(u2_ray wir_r, pro = u2_rl_save(wir_r, fun_m, key, pro); } u2_rz(wir_r, key); - } + } else { // printf("use %s\n", u2_ho_cstring(jet_j->xip)); pro = u2_cn_nock(u2_rx(wir_r, cor), u2_rx(wir_r, fol)); @@ -944,7 +944,7 @@ u2_ho_use(u2_ray wir_r, if ( !(jet_j->sat_s & u2_jet_test) ) { pro = _ho_run(wir_r, jet_j, cor); } - else { + else { // c3_assert(!"equivalence testing is currently disabled"); #if 1 u2_noun sof; @@ -967,7 +967,7 @@ u2_ho_use(u2_ray wir_r, nex_w = u2_soup_liv_w(u2_rail_rut_r(wir_r)); if ( nex_w > liv_w ) { - fprintf(stderr, "leak: %d, %s\n", + fprintf(stderr, "leak: %d, %s\n", (nex_w - liv_w), u2_ho_cstring(jet_j->xip)); c3_assert(0); @@ -1008,7 +1008,7 @@ u2_ho_kick(u2_ray wir_r, u2_noun cor, // retain u2_atom axe) // retain { - u2_noun fol; + u2_noun fol; u2_ho_jet* jet_j; if ( u2_none == (fol = u2_frag(axe, cor)) ) { @@ -1052,14 +1052,14 @@ u2_ho_kicq(u2_ray wir_r, *pon = 2; u2z(hoe); return pro; - } + } else if ( u2h(hoe) == c3__need ) { pro = u2k(u2t(hoe)); *pon = 1; u2z(hoe); return pro; - } + } else if ( u2h(hoe) == c3__fail ) { fprintf(stderr, "\r\nfail from %s\n", u2_ho_cstring(xip)); // u2_err(u2_Wire, "hhoe", u2h(hoe)); diff --git a/f/loom.c b/f/loom.c index 1f78be1de..00db83b4c 100644 --- a/f/loom.c +++ b/f/loom.c @@ -19,7 +19,7 @@ _loom_stop(c3_i sig) } static c3_i -_loom_sigsegv_handler(void* adr_v, c3_i ser_i) +_loom_sigsegv_handler(void* adr_v, c3_i ser_i) { if ( ser_i ) { c3_w* bas_w = (c3_w*)(void *)(U2_OS_LoomBase); @@ -39,7 +39,7 @@ _loom_sigsegv_handler(void* adr_v, c3_i ser_i) LoomChem[pag_w].mug_e = 0; for ( ceg_u = &LoomSegmentA; ceg_u; ceg_u = ceg_u->nex_u ) { - if ( (pag_w >= ceg_u->bot_w) && + if ( (pag_w >= ceg_u->bot_w) && (win_w=(pag_w - ceg_u->bot_w)) < ceg_u->len_w ) { if ( win_w >= ceg_u->pgs_w ) { @@ -55,7 +55,7 @@ _loom_sigsegv_handler(void* adr_v, c3_i ser_i) if ( -1 == mprotect((void *)(bas_w + (pag_w << LoomPageWords)), (1 << (LoomPageWords + 2)), - (PROT_READ | PROT_WRITE)) ) + (PROT_READ | PROT_WRITE)) ) { perror("mprotect"); exit(1); @@ -108,8 +108,8 @@ _loom_deploy(void) for ( ceg_u = &LoomSegmentA; ceg_u; ceg_u = ceg_u->nex_u ) { u2_chef chf_u; - c3_w i_w; - + c3_w i_w; + /* Load control segment. */ { @@ -119,8 +119,8 @@ _loom_deploy(void) } c3_assert(chf_u.bot_w == ceg_u->bot_w); - if ( u2_no == _loom_read(ceg_u->ctl_i, - (u2_chit*) &LoomChem[ceg_u->bot_w], + if ( u2_no == _loom_read(ceg_u->ctl_i, + (u2_chit*) &LoomChem[ceg_u->bot_w], chf_u.pgs_w) ) { printf("deploy no b\n"); @@ -153,7 +153,7 @@ _loom_deploy(void) res_w << (LoomPageWords + 2), PROT_READ, (MAP_ANON | MAP_FIXED | MAP_PRIVATE), - -1, 0) ) + -1, 0) ) { printf("deploy no d\n"); return u2_no; @@ -180,16 +180,16 @@ _loom_deploy(void) LoomChem[pag_w].mug_e ) { printf("mismatched mug at page %d\n", pag_w); - printf("actual data: %x\n", + printf("actual data: %x\n", (0x3fffffff & u2_mug_words(gaw_w, (1 << LoomPageWords)))); printf("control mug: %x\n", LoomChem[pag_w].mug_e); - printf("deploy no f\n"); + printf("deploy no f\n"); return u2_no; } } #if 0 - fprintf(stderr, "load: %s bot_w %x, pgs_w %d, num_w %d\n", + fprintf(stderr, "load: %s bot_w %x, pgs_w %d, num_w %d\n", ceg_u->nam_c, chf_u.bot_w, chf_u.pgs_w, num_w); #endif } @@ -222,9 +222,9 @@ u2_loom_save(c3_w ent_w) for ( ceg_u = &LoomSegmentA; ceg_u; ceg_u = ceg_u->nex_u ) { u2_chef chf_u; - c3_w i_w; + c3_w i_w; c3_w num_w = 0; - + chf_u.ent_w = ent_w; chf_u.ven_w = LoomVersion; chf_u.bot_w = ceg_u->bot_w; @@ -239,7 +239,7 @@ u2_loom_save(c3_w ent_w) if ( u2_page_tref == LoomChem[pag_w].lif_e ) { lseek(ceg_u->dat_i, (i_w << (LoomPageWords + 2)), SEEK_SET); - if ( u2_no == _loom_write(ceg_u->dat_i, + if ( u2_no == _loom_write(ceg_u->dat_i, mem_w, (1 << LoomPageWords)) ) { fprintf(stderr, "save no a\r\n"); @@ -255,7 +255,7 @@ u2_loom_save(c3_w ent_w) } #if 0 - fprintf(stderr, "save: %s bot_w %x, pgs_w %d, num_w %d\r\n", + fprintf(stderr, "save: %s bot_w %x, pgs_w %d, num_w %d\r\n", ceg_u->nam_c, chf_u.bot_w, chf_u.pgs_w, num_w); #endif @@ -266,7 +266,7 @@ u2_loom_save(c3_w ent_w) fprintf(stderr, "save no b\r\n"); return u2_no; } - if ( u2_no == _loom_write(ceg_u->ctl_i, + if ( u2_no == _loom_write(ceg_u->ctl_i, (u2_chit*)(LoomChem + ceg_u->bot_w), ceg_u->pgs_w) ) { fprintf(stderr, "save no c\r\n"); @@ -275,7 +275,7 @@ u2_loom_save(c3_w ent_w) /* Catch future changes. */ - if ( -1 == mprotect(((c3_w*)U2_OS_LoomBase) + + if ( -1 == mprotect(((c3_w*)U2_OS_LoomBase) + (ceg_u->bot_w << LoomPageWords), (ceg_u->len_w << (LoomPageWords + 2)), PROT_READ) ) @@ -296,13 +296,13 @@ u2_loom_save(c3_w ent_w) fdatasync(ceg_u->ctl_i); fdatasync(ceg_u->dat_i); #elif defined(U2_OS_osx) - fcntl(ceg_u->ctl_i, F_FULLFSYNC); + fcntl(ceg_u->ctl_i, F_FULLFSYNC); fcntl(ceg_u->dat_i, F_FULLFSYNC); #elif defined(U2_OS_bsd) fsync(ceg_u->ctl_i); fsync(ceg_u->dat_i); #else - #error "port: datasync" + #error "port: datasync" #endif } @@ -498,9 +498,9 @@ _frag_word(c3_w a_w, u2_noun b) if ( u2_no == u2_dust(b) ) { return u2_none; } - else { + else { c3_w x = (1 & (a_w >> (dep_w - 1))); - + b = *u2_at_ray(1 + x + u2_pom_a(b)); dep_w--; } @@ -520,9 +520,9 @@ _frag_deep(c3_w a_w, u2_noun b) if ( u2_no == u2_dust(b) ) { return u2_none; } - else { + else { c3_w x = (1 & (a_w >> (dep_w - 1))); - + b = *u2_at_ray(1 + x + u2_pom_a(b)); dep_w--; } @@ -573,7 +573,7 @@ u2_frag(u2_atom a, else { if ( !u2_dog_is_pug(a) ) { return u2_none; - } + } else { return _frag_phat(a, b); #if 0 @@ -583,7 +583,7 @@ u2_frag(u2_atom a, c3_assert(u2_none != b); u2_mp(a_mp, a); - + for ( i_w=0; i_w < fol_w; i_w++ ) { c3_w lum_w = (fol_w - (i_w + 1)); @@ -629,7 +629,7 @@ _mug_both(c3_w lef_w, c3_w rit_w) c3_w bot_w = _mug_fnv(lef_w ^ _mug_fnv(rit_w)); c3_w out_w = _mug_out(bot_w); - if ( 0 != out_w ) { + if ( 0 != out_w ) { return out_w; } else { @@ -660,7 +660,7 @@ _mug_bytes(c3_w off_w, c3_w nby_w, c3_y* byt_y) c3_w has_w = _mug_bytes_in(off_w, nby_w, byt_y); c3_w out_w = _mug_out(has_w); - if ( 0 != out_w ) { + if ( 0 != out_w ) { return out_w; } else { @@ -766,7 +766,7 @@ _mug_words(c3_w off_w, c3_w nwd_w, const c3_w* wod_w) c3_w has_w = _mug_words_in(off_w, nwd_w, wod_w); c3_w out_w = _mug_out(has_w); - if ( 0 != out_w ) { + if ( 0 != out_w ) { return out_w; } else { @@ -780,7 +780,7 @@ _mug_words_buf(c3_w off_w, c3_w nwd_w, u2_noun veb) c3_w has_w = _mug_words_in_buf(off_w, nwd_w, veb); c3_w out_w = _mug_out(has_w); - if ( 0 != out_w ) { + if ( 0 != out_w ) { return out_w; } else { @@ -881,8 +881,8 @@ u2_mug_qual(u2_noun a, u2_noun c, u2_noun d) { - return u2_mug_both(u2_mug(a), - u2_mug_both(u2_mug(b), + return u2_mug_both(u2_mug(a), + u2_mug_both(u2_mug(b), u2_mug_both(u2_mug(c), u2_mug(d)))); } @@ -911,8 +911,8 @@ _sing_x(u2_noun a, #endif if ( u2_fly_is_atom(a) ) { - if ( !u2_fly_is_atom(b) || - u2_fly_is_cat(a) || + if ( !u2_fly_is_atom(b) || + u2_fly_is_cat(a) || u2_fly_is_cat(b) ) { return u2_no; @@ -935,7 +935,7 @@ _sing_x(u2_noun a, c3_w i_w; for ( i_w = 0; i_w < w_rez; i_w++ ) { - if ( (*u2_at_pug_buf(a, i_w)) != + if ( (*u2_at_pug_buf(a, i_w)) != (*u2_at_pug_buf(b, i_w)) ) { return u2_no; @@ -1012,7 +1012,7 @@ u2_sing(u2_noun a, } if ( FUN && (X > 10) ) { // printf("mug %x, X %d\n", u2_mug(a), X); - // if ( u2_mug(a) == 0xe5c2279 ) + // if ( u2_mug(a) == 0xe5c2279 ) // { printf("a %x, b %x\n", a, b); c3_assert(0); } } return sit; @@ -1021,7 +1021,7 @@ u2_sing(u2_noun a, } u2_bean -u2_fing(u2_noun a, +u2_fing(u2_noun a, u2_noun b) { return (a == b) ? u2_yes : u2_no; @@ -1037,7 +1037,7 @@ u2_sing_cell(u2_noun p, u2_noun b) { return u2_and(u2_dust(b), - u2_and(u2_sing(p, u2_h(b)), + u2_and(u2_sing(p, u2_h(b)), u2_sing(q, u2_t(b)))); } u2_bean @@ -1046,7 +1046,7 @@ u2_fing_cell(u2_noun p, u2_noun b) { return u2_and(u2_dust(b), - u2_and(u2_fing(p, u2_h(b)), + u2_and(u2_fing(p, u2_h(b)), u2_fing(q, u2_t(b)))); } @@ -1060,7 +1060,7 @@ u2_sing_mixt(const c3_c* p_c, u2_noun b) { return u2_and(u2_dust(b), - u2_and(u2_sing_c(p_c, u2_h(b)), + u2_and(u2_sing_c(p_c, u2_h(b)), u2_sing(q, u2_t(b)))); } u2_bean @@ -1069,7 +1069,7 @@ u2_fing_mixt(const c3_c* p_c, u2_noun b) { return u2_and(u2_dust(b), - u2_and(u2_sing_c(p_c, u2_h(b)), + u2_and(u2_sing_c(p_c, u2_h(b)), u2_fing(q, u2_t(b)))); } @@ -1084,7 +1084,7 @@ u2_sing_trel(u2_noun p, u2_noun b) { return u2_and(u2_dust(b), - u2_and(u2_sing(p, u2_h(b)), + u2_and(u2_sing(p, u2_h(b)), u2_sing_cell(q, r, u2_t(b)))); } u2_bean @@ -1094,7 +1094,7 @@ u2_fing_trel(u2_noun p, u2_noun b) { return u2_and(u2_dust(b), - u2_and(u2_fing(p, u2_h(b)), + u2_and(u2_fing(p, u2_h(b)), u2_fing_cell(q, r, u2_t(b)))); } @@ -1110,7 +1110,7 @@ u2_sing_qual(u2_noun p, u2_noun b) { return u2_and(u2_dust(b), - u2_and(u2_sing(p, u2_h(b)), + u2_and(u2_sing(p, u2_h(b)), u2_sing_trel(q, r, s, u2_t(b)))); } u2_bean @@ -1121,7 +1121,7 @@ u2_fing_qual(u2_noun p, u2_noun b) { return u2_and(u2_dust(b), - u2_and(u2_fing(p, u2_h(b)), + u2_and(u2_fing(p, u2_h(b)), u2_fing_trel(q, r, s, u2_t(b)))); } @@ -1303,7 +1303,7 @@ u2_as_p(u2_noun a, *c = nux; return u2_yes; } - else return u2_no; + else return u2_no; } /* u2_as_pq(): @@ -1318,7 +1318,7 @@ u2_as_pq(u2_noun a, { u2_noun nux; - if ( (u2_yes == u2_as_p(a, b, &nux)) && + if ( (u2_yes == u2_as_p(a, b, &nux)) && (u2_yes == u2_as_cell(nux, c, d)) ) { return u2_yes; @@ -1339,7 +1339,7 @@ u2_as_pqr(u2_noun a, { u2_noun nux; - if ( (u2_yes == u2_as_p(a, b, &nux)) && + if ( (u2_yes == u2_as_p(a, b, &nux)) && (u2_yes == u2_as_trel(nux, c, d, e)) ) { return u2_yes; @@ -1361,7 +1361,7 @@ u2_as_pqrs(u2_noun a, { u2_noun nux; - if ( (u2_yes == u2_as_p(a, b, &nux)) && + if ( (u2_yes == u2_as_p(a, b, &nux)) && (u2_yes == u2_as_qual(nux, c, d, e, f)) ) { return u2_yes; @@ -1425,7 +1425,7 @@ u2_as_trel(u2_noun a, if ( (u2_yes == u2_as_cell(a, b, &guf)) && (u2_yes == u2_as_cell(guf, c, d)) ) { return u2_yes; - } + } else { return u2_no; } @@ -1451,10 +1451,10 @@ u2_st(u2_noun a) return (a == u2_none) && (u2_yes == u2_dust(a)) ? a : u2_t(a); } -/* u2_met(): +/* u2_met(): ** ** Return the size of (b) in bits, rounded up to -** (1 << a_y). +** (1 << a_y). ** ** For example, (a_y == 3) returns the size in bytes. */ @@ -1482,7 +1482,7 @@ u2_met(c3_y a_y, else { gal_w = (*u2_at_pug_len(b)) - 1; daz_w = (*u2_at_pug_buf(b, gal_w)); - } + } switch ( a_y ) { case 0: @@ -1578,7 +1578,7 @@ u2_byte(c3_w a_w, } } } - + /* u2_bytes(): ** ** Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c). @@ -1716,7 +1716,7 @@ u2_chop(c3_g met_g, c3_assert(u2_fly_is_atom(src)); if ( met_g < 5 ) { - c3_w san_w = (1 << met_g); + c3_w san_w = (1 << met_g); c3_w mek_w = ((1 << san_w) - 1); c3_w baf_w = (fum_w << met_g); c3_w bat_w = (tou_w << met_g); @@ -1750,7 +1750,7 @@ u2_chop(c3_g met_g, c3_w wut_w = (tou_w + i_w) << hut_g; for ( j_w = 0; j_w < san_w; j_w++ ) { - *u2_at_ray(dst_r + wut_w + j_w) ^= + *u2_at_ray(dst_r + wut_w + j_w) ^= ((wuf_w + j_w) >= len_w) ? 0 : u2_atom_word(src, wuf_w + j_w); diff --git a/f/nock.c b/f/nock.c index 7e9841378..f30f530b1 100644 --- a/f/nock.c +++ b/f/nock.c @@ -1,5 +1,5 @@ /* f/nock.c -** +** ** This file is in the public domain. */ #include "all.h" @@ -88,7 +88,7 @@ _nock_pray_cool(u2_noun gof) // transfer if ( 0 == pon ) { return mog; - } + } else if ( 1 == pon ) { return u2_cm_bowl(u2nc(c3__need, mog)); } @@ -111,19 +111,19 @@ _nock_hint(u2_noun zep, // transfer u2_noun pro; switch ( zep ) { - default: u2z(zep); u2z(hod); + default: u2z(zep); u2z(hod); return pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex); case c3__lose: - case c3__yelp: - case c3__bean: + case c3__yelp: + case c3__bean: case c3__mean: case c3__spot: { u2_noun tax = u2_wire_tax(u2_Wire); u2_noun tac = u2nc(zep, hod); #if 0 - if ( c3__spot == zep ) { + if ( c3__spot == zep ) { printf("spot %d/%d : %d/%d\n", u2h(u2h(u2t(hod))), u2t(u2h(u2t(hod))), @@ -153,7 +153,7 @@ _nock_hint(u2_noun zep, // transfer case c3__mine: { pro = pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex); - + if ( !pon || (u2_no != *pon) ) { u2_tx_sys_bit(u2_Wire, u2_yes); pro = u2_ds_mine(u2_Wire, hod, pro); @@ -192,7 +192,7 @@ _nock_hint(u2_noun zep, // transfer u2_tx_sys_bit(u2_Wire, u2_yes); pro = u2_ds_mine(u2_Wire, hod, pro); u2_tx_sys_bit(u2_Wire, u2_no); - } + } u2z(hod); return pro; } @@ -210,8 +210,8 @@ _nock_hint(u2_noun zep, // transfer return pro; } else { u2_noun sav; - - pro = pon ? _nock_mool(u2k(bus), u2k(nex), pon) + + pro = pon ? _nock_mool(u2k(bus), u2k(nex), pon) : _nock_cool(u2k(bus), u2k(nex)); if ( !pon || (u2_no != *pon) ) { @@ -297,7 +297,7 @@ _nock_cool(u2_noun bus, if ( u2_no == u2du(fol) ) { return u2_cm_bail(c3__exit); } - else { + else { hib = u2fh(fol); gal = u2ft(fol); } @@ -415,7 +415,7 @@ _nock_cool(u2_noun bus, case 7: { u2_noun b_gal, c_gal; - + u2_cx_cell(gal, &b_gal, &c_gal); { u2_noun bod = _nock_cool(bus, u2k(b_gal)); @@ -431,7 +431,7 @@ _nock_cool(u2_noun bus, case 8: { u2_noun b_gal, c_gal; - + // c3_assert(!"got 8 (nock)!"); u2_cx_cell(gal, &b_gal, &c_gal); { @@ -448,11 +448,11 @@ _nock_cool(u2_noun bus, case 9: { u2_noun b_gal, c_gal; - + u2_cx_cell(gal, &b_gal, &c_gal); if ( u2_no == u2ud(b_gal) ) { return u2_cm_bail(c3__exit); - } + } else { u2_noun seb = _nock_cool(bus, u2k(c_gal)); u2_weak xip; @@ -462,11 +462,11 @@ _nock_cool(u2_noun bus, if ( u2_none != xip ) { u2_noun pro = u2_ho_kick(u2_Wire, xip, seb, b_gal); - + u2_tx_sys_bit(u2_Wire, u2_no); if ( u2_none == pro ) { return u2_cm_bail(c3__exit); - } + } else { u2z(seb); u2z(fol); return pro; @@ -489,7 +489,7 @@ _nock_cool(u2_noun bus, case 10: { u2_noun p_gal, q_gal; - + u2_cx_cell(gal, &p_gal, &q_gal); { u2_noun zep, hod, nex, pro; @@ -502,7 +502,7 @@ _nock_cool(u2_noun bus, zep = u2k(b_gal); hod = _nock_cool(u2k(bus), u2_ct(c_gal)); nex = u2_ct(d_gal); - } + } else { u2_noun b_gal = p_gal; u2_noun c_gal = q_gal; @@ -514,7 +514,7 @@ _nock_cool(u2_noun bus, u2_cz(fol); pro = _nock_hint(zep, hod, bus, nex, 0); - return pro; + return pro; } } @@ -535,7 +535,7 @@ _nock_cool(u2_noun bus, /* nock_mool(): fast internal mink interface. Arguments transferred. */ u2_noun -_nock_mool(u2_noun bus, +_nock_mool(u2_noun bus, u2_noun fol, u2_kode* pon) { @@ -551,7 +551,7 @@ _nock_mool(u2_noun bus, u2z(bus); u2z(fol); return u2_cm_wail(); } - else { + else { hib = u2fh(fol); gal = u2ft(fol); } @@ -618,10 +618,10 @@ _nock_mool(u2_noun bus, } else { u2_noun neb; - + neb = _nock_mool(bus, u2k(gal), pon); u2z(fol); - if ( 0 != *pon ) { return neb; } + if ( 0 != *pon ) { return neb; } bus = u2k(u2fh(neb)); fol = u2k(u2ft(neb)); @@ -686,7 +686,7 @@ _nock_mool(u2_noun bus, } else { u2_noun tys, nex; - + tys = _nock_mool(u2k(bus), u2k(b_gal), pon); if ( 0 != *pon ) { u2z(bus); u2z(fol); return tys; } @@ -711,16 +711,16 @@ _nock_mool(u2_noun bus, case 7: { u2_noun b_gal, c_gal; - + if ( u2_no == u2_cr_cell(gal, &b_gal, &c_gal) ) { *pon = 2; u2z(bus); u2z(fol); return u2_cm_wail(); } else { u2_noun bod, nex; - + bod = _nock_mool(bus, u2k(b_gal), pon); if ( 0 != *pon ) { u2z(fol); return bod; } - + nex = u2k(c_gal); u2z(fol); @@ -757,18 +757,18 @@ _nock_mool(u2_noun bus, case 9: { u2_noun b_gal, c_gal; - + if ( (u2_no == u2_cr_cell(gal, &b_gal, &c_gal)) || (u2_no == u2ud(b_gal)) ) { *pon = 2; u2z(bus); u2z(fol); return u2_cm_wail(); - } + } else { u2_noun seb; u2_weak xip; seb = _nock_mool(bus, u2k(c_gal), pon); - u2z(fol); + u2z(fol); if ( 0 != *pon ) { return seb; } u2_tx_sys_bit(u2_Wire, u2_yes); @@ -777,15 +777,15 @@ _nock_mool(u2_noun bus, if ( u2_none != xip ) { u2_noun pro; - + u2_tx_sys_bit(u2_Wire, u2_yes); pro = u2_ho_kicq(u2_Wire, xip, seb, b_gal, pon); u2_tx_sys_bit(u2_Wire, u2_no); - u2z(seb); + u2z(seb); if ( u2_none == pro ) { *pon = 2; return u2_cm_wail(); - } + } else return pro; } else { @@ -804,7 +804,7 @@ _nock_mool(u2_noun bus, case 10: { u2_noun p_gal, q_gal; - + if ( u2_no == u2_cr_cell(gal, &p_gal, &q_gal) ) { *pon = 2; u2z(bus); u2z(fol); return u2_cm_wail(); } @@ -817,12 +817,12 @@ _nock_mool(u2_noun bus, u2_noun d_gal = q_gal; hod = _nock_mool(u2k(bus), u2_ct(c_gal), pon); - if ( 0 != *pon ) { u2z(fol); return hod; } + if ( 0 != *pon ) { u2z(fol); return hod; } zep = u2k(b_gal); nex = u2k(d_gal); u2z(fol); - } + } else { u2_noun b_gal = p_gal; u2_noun c_gal = q_gal; @@ -855,7 +855,7 @@ _nock_mool(u2_noun bus, /* nock_molg(): function call (mung) with kode. Arguments transferred. */ static u2_noun -_nock_molg(u2_noun gat, +_nock_molg(u2_noun gat, u2_noun sam, u2_kode* pon) { @@ -893,11 +893,11 @@ _nock_moog(u2_noun bus, c3_assert(0); u2z(hoe); - } + } else if ( u2h(hoe) == c3__need ) { res = u2nc(1, u2k(u2t(hoe))); u2z(hoe); - } + } else { u2_noun wac = u2k(u2h(hoe)); @@ -915,7 +915,7 @@ _nock_moog(u2_noun bus, return res; } -/* u2_cn_nock(): external nock interface. +/* u2_cn_nock(): external nock interface. */ u2_noun u2_cn_nock(u2_noun bus, @@ -934,7 +934,7 @@ u2_cn_nock(u2_noun bus, u2_tx_glu_bit(u2_Wire, bit); return pro; -} +} /* u2_cn_mink(): logical virtual nock. */ @@ -968,7 +968,7 @@ u2_cn_mink(u2_noun bus, u2_tx_glu_bit(u2_Wire, bit); return res; -} +} /* u2_cn_moch(): blind mink with empty fly. */ @@ -980,7 +980,7 @@ u2_cn_moch(u2_noun bus, return u2_cn_mink(bus, fol, fly); } - + /*** Deprecated: ***/ diff --git a/f/rail.c b/f/rail.c index fd6f73e33..cd8ad17f4 100644 --- a/f/rail.c +++ b/f/rail.c @@ -1,5 +1,5 @@ /* f/rail.c -** +** ** This file is in the public domain. */ #include "all.h" @@ -97,9 +97,9 @@ u2_rl_leap(u2_ray ral_r, } } - /* Before: + /* Before: * 0 rut hat 1GB - * | | | | + * | | | | * |-------------------########-----------------------------| * | | | | * cap mat @@ -108,7 +108,7 @@ u2_rl_leap(u2_ray ral_r, * | | * |--------------------#######-----------------------------| * | / | | - * hat rut + * hat rut */ { u2_ray cap_r = u2_rail_cap_r(ral_r); @@ -122,7 +122,7 @@ u2_rl_leap(u2_ray ral_r, { u2_rail_cap_r(ral_r) = hat_r; u2_rail_hat_r(ral_r) = cap_r; - u2_rail_mat_r(ral_r) = hat_r; + u2_rail_mat_r(ral_r) = hat_r; u2_rail_rut_r(ral_r) = cap_r; u2_rail_hip_m(ral_r) = hop_m; } @@ -153,15 +153,15 @@ u2_rl_leap(u2_ray ral_r, void u2_rl_fall(u2_ray ral_r) { - /* Before: + /* Before: * 0 rut hat 1GB - * | | | | + * | | | | * |-------------------########-----------------------------| * | | | | * cap mat *//* After: * 0 mat cap 1GB - * | | | | + * | | | | * |-------------------###############----------------------| * | | | | * hat rut @@ -170,7 +170,7 @@ u2_rl_fall(u2_ray ral_r) u2_ray mat_r = u2_rail_mat_r(ral_r); u2_ray hat_r = u2_rail_hat_r(ral_r); u2_ray pik_r = mat_r; - + u2_rail_cap_r(ral_r) = hat_r; u2_rail_hat_r(ral_r) = mat_r; @@ -183,7 +183,7 @@ u2_rl_fall(u2_ray ral_r) /* u2_rl_leap_part(): ** ** Reverse and split rail, inserting partition of size `num/dem` -** plus `tip`. +** plus `tip`. ** ** Returns partition rail, `aux_r`. */ @@ -221,9 +221,9 @@ u2_rl_leap_part(u2_ray ral_r, } } - /* Before: + /* Before: * 0 rut hat - * | | | + * | | | * |-------------^-----##########################------$----| * | | | * cap mat @@ -300,7 +300,7 @@ u2_rl_fall_part(u2_ray ral_r, /* * Initially: * 0 rut hat - * | | | + * | | | * |-------------^-----##########################------$----| * | | | * cap mat @@ -314,7 +314,7 @@ u2_rl_fall_part(u2_ray ral_r, * Main rail, later: * * 0 rut hat - * | | | + * | | | * |--------------------------------^---####----$-----------| * | | | * cap mat @@ -329,7 +329,7 @@ u2_rl_fall_part(u2_ray ral_r, * Auxiliary rail, later: * * 0 rut hat - * | | | + * | | | * |-------------------^----###-----------------------------| * | | | * cap mat @@ -337,14 +337,14 @@ u2_rl_fall_part(u2_ray ral_r, * On return, assimilate style A (right, not supported): * * 0 rut hat - * | | | + * | | | * |-------------^------------###################------$----| * | | | * cap mat * On return, compose style B (wrong, not supported): * * 0 rut hat - * | | | + * | | | * |-------------^-------------------------------------$----| * | | | * cap mat @@ -363,7 +363,7 @@ u2_rl_fall_part(u2_ray ral_r, /* _rl_bloq_make(): ** -** Install a liquid block at `box_r`, with size `siz_w` and +** Install a liquid block at `box_r`, with size `siz_w` and ** use count `use_w`. */ static void @@ -421,11 +421,11 @@ _rl_free_select(c3_w siz_w) ** Attach the bloq at `box_r` to the appropriate free list. */ static void -_rl_bloq_attach(u2_ray ral_r, +_rl_bloq_attach(u2_ray ral_r, u2_ray box_r) { c3_w siz_w = u2_rail_box_siz(box_r); - c3_w sel_w = _rl_free_select(siz_w); + c3_w sel_w = _rl_free_select(siz_w); u2_ray sop_r = u2_rail_rut_r(ral_r); u2_ray fre_r = u2_soup_fre_r(sop_r, sel_w); @@ -448,7 +448,7 @@ _rl_bloq_detach(u2_ray ral_r, u2_ray box_r) { c3_w siz_w = u2_rail_box_siz(box_r); - c3_w sel_w = _rl_free_select(siz_w); + c3_w sel_w = _rl_free_select(siz_w); u2_ray sop_r = u2_rail_rut_r(ral_r); u2_ray pre_r = u2_rail_hut_pre(box_r); u2_ray nex_r = u2_rail_hut_nex(box_r); @@ -464,7 +464,7 @@ _rl_bloq_detach(u2_ray ral_r, } } -/* _rl_live_grab(): +/* _rl_live_grab(): */ #ifdef U2_PROFILE_MEMORY static void @@ -491,7 +491,7 @@ u2_rl_dump(u2_ray ral_r) c3_w i_w; c3_w tot_w; c3_w rag_w; - + printf("soup dump:\n"); tot_w = 0; @@ -507,7 +507,7 @@ u2_rl_dump(u2_ray ral_r) if ( siz_w < min_w ) { min_w = siz_w; - } + } if ( siz_w > max_w ) { max_w = siz_w; } @@ -519,14 +519,14 @@ u2_rl_dump(u2_ray ral_r) if ( num_w != 0 ) { printf(" list %d, num %d, min %d, max %d, kb %d.%d.%d\n", - i_w, num_w, min_w, max_w, + i_w, num_w, min_w, max_w, ((all_w * 4) >> 20), ((all_w * 4) >> 10) % 1024, ((all_w * 4) % 1024)); } } rag_w = HalfSize - - ( u2_ray_b(u2_rail_hat_r(ral_r)) + + ( u2_ray_b(u2_rail_hat_r(ral_r)) + u2_ray_b(u2_rail_cap_r(ral_r))); tot_w += rag_w; @@ -535,7 +535,7 @@ u2_rl_dump(u2_ray ral_r) ((rag_w * 4) >> 10) % 1024, ((rag_w * 4) % 1024)); - printf("soup: cap %x, hat %x, free %d.%d.%d\n", + printf("soup: cap %x, hat %x, free %d.%d.%d\n", u2_ray_b(u2_rail_hat_r(ral_r)), u2_ray_b(u2_rail_cap_r(ral_r)), ((tot_w * 4) >> 20), @@ -586,7 +586,7 @@ _rl_bloq_grab(u2_ray ral_r, u2_loop_signal_memory(); return 0; } - else { + else { u2_ray box_r; box_r = u2_rail_hat_r(ral_r); @@ -613,9 +613,9 @@ _rl_bloq_grab(u2_ray ral_r, if ( 0 == fre_r ) { if ( sel_w < (u2_soup_free_no - 1) ) { - sel_w += 1; + sel_w += 1; break; - } + } else { /* Nothing in top free list. Chip away at the hat. */ @@ -632,11 +632,11 @@ _rl_bloq_grab(u2_ray ral_r, // XX: integrate with integral wire. // // A bunch of testing is needed to make this actually work. - // return 0; + // return 0; c3_assert(0); #endif } - else { + else { box_r = u2_rail_hat_r(ral_r); u2_rail_hat_r(ral_r) += siz_w; @@ -652,7 +652,7 @@ _rl_bloq_grab(u2_ray ral_r, /* This free block is too small. Continue searching. */ pfr_r = u2_aftr(fre_r, u2_loom_rail_hut, nex_r); - } + } else { /* We have found a free block of adequate size. Remove it ** from the free list. @@ -663,10 +663,10 @@ _rl_bloq_grab(u2_ray ral_r, u2_ray pre_r = u2_rail_hut_pre(box_r); u2_ray nex_r = u2_rail_hut_nex(box_r); - c3_assert((0 == pre_r) || + c3_assert((0 == pre_r) || (u2_at_ray(pfr_r) == &u2_rail_hut_nex(pre_r))); *u2_at_ray(pfr_r) = nex_r; - + if ( 0 != nex_r ) { u2_rail_hut_pre(nex_r) = pre_r; } @@ -686,7 +686,7 @@ _rl_bloq_grab(u2_ray ral_r, else { c3_assert(u2_rail_box_use(box_r) == 0); u2_rail_box_use(box_r) = 1; -# ifdef U2_LEAK_DEBUG +# ifdef U2_LEAK_DEBUG *u2_at_ray(box_r + 2) = COD_w; # endif @@ -723,14 +723,14 @@ _rl_bloq_free(u2_ray ral_r, { c3_w siz_w = u2_rail_box_siz(box_r); u2_ray bod_r; - + for ( bod_r = (box_r + c3_wiseof(u2_loom_rail_box)); (bod_r + 1) < (box_r + siz_w); bod_r++ ) { *u2_at_ray(bod_r) = 0xdeadbeef; } - } + } _rl_live_grab(ral_r, (-1 * u2_rail_hut_siz(box_r))); @@ -868,7 +868,7 @@ u2_rl_gain(u2_ray ral_r, if ( c3__rock == hip_m ) { u2_ray rut_r = u2_rail_rut_r(ral_r); - + if ( som_r > rut_r ) { u2_ray box_r = (som_r - c3_wiseof(u2_loom_rail_box)); c3_w use_w = u2_rail_box_use(box_r); @@ -916,7 +916,7 @@ u2_rl_ok(u2_ray ral_r, if ( c3__rock == hip_m ) { u2_ray rut_r = u2_rail_rut_r(ral_r); - + if ( som_r >= rut_r ) { u2_ray box_r = (som_r - c3_wiseof(u2_loom_rail_box)); c3_w use_w = u2_rail_box_use(box_r); @@ -955,7 +955,7 @@ u2_rl_refs(u2_ray ral_r, if ( c3__rock == hip_m ) { u2_ray rut_r = u2_rail_rut_r(ral_r); - + if ( som_r >= rut_r ) { u2_ray box_r = (som_r - c3_wiseof(u2_loom_rail_box)); c3_w use_w = u2_rail_box_use(box_r); @@ -973,14 +973,14 @@ u2_rl_refs(u2_ray ral_r, ** Lose a reference to (som). Free it if refcount == 0. */ void -u2_rl_lose(u2_ray ral_r, +u2_rl_lose(u2_ray ral_r, u2_noun som) { if ( u2_none == som ) { return; } -top: +top: if ( u2_fly_is_dog(som) ) { u2_ray som_r = u2_dog_a(som); u2_ray hat_r = u2_rail_hat_r(ral_r); @@ -990,7 +990,7 @@ top: if ( c3__rock == hip_m ) { u2_ray rut_r = u2_rail_rut_r(ral_r); - + if ( som_r >= rut_r ) { u2_ray box_r = (som_r - c3_wiseof(u2_loom_rail_box)); c3_w use_w = u2_rail_box_use(box_r); @@ -1006,7 +1006,7 @@ top: _rl_bloq_free(ral_r, box_r); som = t_som; goto top; - } + } else { u2_rail_box_use(box_r) = 0; _rl_bloq_free(ral_r, box_r); @@ -1124,7 +1124,7 @@ u2_bean u2_rl_open(u2_ray ral_r, c3_w a_w) { - return + return ((a_w + u2_ray_b(u2_rail_hat_r(ral_r)) + u2_ray_b(u2_rail_cap_r(ral_r))) >= HalfSize) ? u2_no @@ -1199,7 +1199,7 @@ u2_rl_clear(u2_noun lef, */ if ( u2_dog_is_pom(lef) ) { u2_ray ray_lef = u2_dog_a(lef); - + /* Is this pom fixed? */ if ( nax_b[ray_lef - bat_r] ) { @@ -1220,7 +1220,7 @@ u2_rl_clear(u2_noun lef, /* Rewrite the pointer. */ *u2_at_pom_hed(lef) = (fes - (pif_w << 2)); - + /* Swizzle into it. */ _tamp_swizzle(fes, pif_w, bat_r, nax_b); @@ -1233,7 +1233,7 @@ u2_rl_clear(u2_noun lef, /* Rewrite the pointer. */ *u2_at_pom_tel(lef) = (hoz - (pif_w << 2)); - + /* Swizzle into it. */ _tamp_swizzle(hoz, pif_w, bat_r, nax_b); @@ -1264,7 +1264,7 @@ u2_rl_tamp(u2_ray ral_r, /* Check that there's actually a root. If not, tamp is trivial. */ if ( !u2_fly_is_dog(lef) || - (u2_ray_a(u2_dog_a(lef)) != u2_ray_a(net_r)) || + (u2_ray_a(u2_dog_a(lef)) != u2_ray_a(net_r)) || (u2_dog_a(lef) < bat_r) ) { u2_rail_cap_r(ral_r) = net_r; @@ -1378,7 +1378,7 @@ u2_rl_copy(u2_ray ral_r, *u2_at_dog_mug(nov) = mug_w; *u2_at_pom_hed(nov) = hed; *u2_at_pom_tel(nov) = tel; - + c3_assert(u2_no == u2_rl_junior(ral_r, nov)); } } @@ -1424,9 +1424,9 @@ u2_rl_wash(u2_rail ral_r, u2_noun nov = mug_w; *u2_at_dog_mug(fiz) = *u2_at_dog_mug(nov); - // printf(" fixed fiz %x; was %x; now %x\n", + // printf(" fixed fiz %x; was %x; now %x\n", // fiz, mug_w, *u2_at_dog_mug(fiz)); - + if ( u2_yes == u2_dust(fiz) ) { u2_rl_wash(ral_r, u2_h(fiz)); u2_rl_wash(ral_r, u2_t(fiz)); @@ -1484,7 +1484,7 @@ top: u2_ray box_r = (som_r - c3_wiseof(u2_loom_rail_box)); c3_w use_w = u2_rail_box_use(box_r); c3_ws use_ws = (c3_ws) use_w; - + c3_assert(use_ws != 0); if ( use_ws < 0 ) { @@ -1552,7 +1552,7 @@ c3_w u2_rl_gc_mark(u2_ray ral_r) { u2_ray sop_r = u2_rail_rut_r(ral_r); - + return u2_cs_mark(ral_r, u2_soup_lot_r(sop_r)); } @@ -1565,12 +1565,12 @@ u2_rl_drain(u2_ray ral_r) { if ( c3__rock == u2_rail_hip_m(ral_r) ) { u2_ray sop_r = u2_rail_rut_r(ral_r); - + u2_cs_lose(ral_r, u2_soup_lot_r(sop_r)); } } -/* u2_rl_gc_sweep(): +/* u2_rl_gc_sweep(): ** ** Sweep memory, freeing unused blocks. Match live, save leaked. */ @@ -1604,12 +1604,12 @@ u2_rl_gc_sweep(u2_ray ral_r, c3_w sav_w) if ( use_ws > 0 ) { # ifdef U2_LEAK_DEBUG c3_w cod_w = u2_rail_box_cod(box_r); - + if ( 0 == cod_w ) { - fprintf(stderr, "\rleak: box %x, siz %d, use %d\r\n", + fprintf(stderr, "\rleak: box %x, siz %d, use %d\r\n", box_r, siz_w, use_w); } else { - fprintf(stderr, "\rleak: %s: box %x, siz %d, use %d\r\n", + fprintf(stderr, "\rleak: %s: box %x, siz %d, use %d\r\n", u2_cr_string(cod_w), box_r, siz_w, use_w); } @@ -1617,7 +1617,7 @@ u2_rl_gc_sweep(u2_ray ral_r, c3_w sav_w) lek_w += siz_w; u2_rail_box_use(box_r) = 0; _rl_bloq_free(ral_r, box_r); - } + } else if ( use_ws < 0 ) { // printf("live: box %x, siz %d, use %d\n", box_r, siz_w, use_w); use_ws = (0 - use_ws); @@ -1681,7 +1681,7 @@ u2_rl_take(u2_ray ral_r, *u2_at_dog_mug(nov) = *u2_at_dog_mug(fiz); *u2_at_pom_hed(nov) = hed; *u2_at_pom_tel(nov) = tel; - + c3_assert(u2_no == u2_rl_junior(ral_r, nov)); return nov; } @@ -1772,7 +1772,7 @@ u2_rl_mint(u2_rail ral_r, u2_rl_lose(ral_r, nov); return _0; - } + } else if ( len_w == 1 ) { c3_w low_w = *u2_at_pug_buf(nov, 0); @@ -1899,7 +1899,7 @@ u2_rl_bytes(u2_ray ral_r, u2_loop_signal_memory(); return u2_none; } - else { + else { u2_ray nov_r; u2_noun nov; @@ -1935,7 +1935,7 @@ u2_rl_bytes(u2_ray ral_r, } } -/* u2_rl_cell(): +/* u2_rl_cell(): ** ** Produce the cell `[a b]`. */ @@ -1969,11 +1969,11 @@ u2_rl_cell(u2_ray ral_r, } else { if ( (som_n >= mat_n) && (som_n <= hat_n) ) { printf("junior y\n"); - printf("hat %d.%d == %d\n", + printf("hat %d.%d == %d\n", u2_ray_a(hat_r), u2_ray_b(hat_r), u2_ray_fnit(hat_r)); - printf("mat %d.%d == %d\n", + printf("mat %d.%d == %d\n", u2_ray_a(mat_r), u2_ray_b(mat_r), u2_ray_fnit(mat_r)); - printf("som %d.%d == %d\n", + printf("som %d.%d == %d\n", u2_ray_a(som_r), u2_ray_b(som_r), u2_ray_fnit(som_r)); } } @@ -2144,7 +2144,7 @@ u2_rl_molt(u2_rail ral_r, */ return _molt_apply(ral_r, som, len_w, pms_m); } - + /* u2_rl_molv(): ** ** As u2_rl_molt(), by argument pointer. @@ -2299,7 +2299,7 @@ u2_rl_vint(u2_rail ral_r, } else if ( u2_yes == u2du(a) ) { return u2_none; - } + } else { mpz_t a_mp; @@ -2345,7 +2345,7 @@ u2_rl_words(u2_ray ral_r, if ( u2_no == u2_rl_open(ral_r, (a_w + c3_wiseof(u2_loom_atom))) ) { return u2_none; } - else { + else { u2_ray nov_r; u2_noun nov; @@ -2377,7 +2377,7 @@ u2_weak // transfer u2_rl_find(u2_ray ral_r, u2_mote fun_m, u2_noun sam) // retain -{ +{ if ( c3__rock != u2_rail_hip_m(ral_r) ) { return u2_none; } else { diff --git a/f/shed.c b/f/shed.c index 57b2a31c7..f44749a36 100644 --- a/f/shed.c +++ b/f/shed.c @@ -72,7 +72,7 @@ u2_sh_mine(u2_ray wir_r, if ( 0 == (bas_r = u2_wire_bas_r(wir_r)) ) { return cor; } - else if ( (u2_none == u2_as_cell(cor, &pay, &bat)) || + else if ( (u2_none == u2_as_cell(cor, &pay, &bat)) || (u2_no == u2_dust(bat)) ) { return cor; @@ -98,7 +98,7 @@ u2_sh_mine(u2_ray wir_r, } else { u2_noun dac, bot, pet, xop, cyr; - + dac = bot = pet = xop = cyr = u2_none; while ( 1 ) { /* disc: dac @@ -113,7 +113,7 @@ u2_sh_mine(u2_ray wir_r, */ { if ( u2_no == u2_rl_junior(bas_r, bat) ) { - /* We need the jet battery to be in the shed, so that we + /* We need the jet battery to be in the shed, so that we ** have a fast algorithm for distinguishing jet batteries ** by ray address. */ @@ -123,7 +123,7 @@ u2_sh_mine(u2_ray wir_r, u2_ray_a(u2_dog_a(bot)), u2_ray_b(u2_dog_a(bot))); #endif - } + } else { bot = u2_rl_take(bas_r, bat); #if 0 @@ -143,11 +143,11 @@ u2_sh_mine(u2_ray wir_r, { if ( _0 == bud ) { pet = u2_nul; - } + } else { u2_atom p_bud = u2_t(bud); u2_noun car = u2_frag(p_bud, cor); - + if ( (u2_none == car) || (u2_no == u2_dust(car)) ) { break; } else { @@ -343,7 +343,7 @@ u2_sh_look(u2_wire wir_r, u2_noun cor, const c3_c* tam_c) { - u2_ray bas_r = u2_wire_bas_r(wir_r); + u2_ray bas_r = u2_wire_bas_r(wir_r); u2_noun bat = u2_t(cor); u2_noun fol; @@ -354,7 +354,7 @@ u2_sh_look(u2_wire wir_r, if ( u2_none == xip ) { return u2_none; - } + } else { u2_axis axe_w = _1; diff --git a/f/trac.c b/f/trac.c index dab0fdbbd..2ecbcb790 100644 --- a/f/trac.c +++ b/f/trac.c @@ -32,7 +32,7 @@ /** Static sampling data structures, for signal handling use. **/ # define U2_TRAC_SAMPLE_MAX 10000 - + u2_loom_knot _tx_knots[U2_TRAC_SAMPLE_MAX]; u2_loom_knot* _tx_top_k; u2_ray _tx_rac_r; @@ -120,7 +120,7 @@ _tx_samp_on(u2_ray rac_r) { c3_assert(_tx_on == 0); c3_assert(_tx_knot_cur == 0); - + _tx_on = 1; _tx_rac_r = rac_r; @@ -251,7 +251,7 @@ _tx_event(u2_wire wir_r, /* u2_tx_events(): produce event list, including counts. */ static u2_noun // produce -_tx_events(u2_wire wir_r, +_tx_events(u2_wire wir_r, u2_noun cot) // retain { u2_ray rac_r = u2_wire_rac_r(wir_r); @@ -263,28 +263,28 @@ _tx_events(u2_wire wir_r, cot = _tx_event(wir_r, "sys-tests", u2_trac_be(rac_r, c3_d, sys.tes_d), cot); cot = _tx_event(wir_r, "sys-nods", u2_trac_be(rac_r, c3_d, sys.nod_d), cot); - cot = _tx_event(wir_r, "sys-cache-finds", + cot = _tx_event(wir_r, "sys-cache-finds", u2_trac_be(rac_r, c3_d, sys.fin_d), cot); - cot = _tx_event(wir_r, "sys-cache-saves", + cot = _tx_event(wir_r, "sys-cache-saves", u2_trac_be(rac_r, c3_d, sys.pod_d), cot); cot = _tx_event(wir_r, "sys-stack", u2_trac_at(rac_r, sys.cas_x.max_w), cot); #if 0 - cot = _tx_event(wir_r, "sys-memory-used", + cot = _tx_event(wir_r, "sys-memory-used", u2_trac_be(rac_r, c3_w, sys.men_x.max_w), cot); cot = _tx_event(wir_r, "sys-memory-held", u2_trac_be(rac_r, c3_w, sys.men_x.med_w), cot); - cot = _tx_event(wir_r, "sys-basket", + cot = _tx_event(wir_r, "sys-basket", u2_trac_be(rac_r, c3_w, sys.bek_x.max_w), cot); - cot = _tx_event(wir_r, "sys-memory-active", - 4 * (u2_soup_liv_w(u2_rail_rut_r(wir_r)) - + cot = _tx_event(wir_r, "sys-memory-active", + 4 * (u2_soup_liv_w(u2_rail_rut_r(wir_r)) - u2_trac_at(rac_r, sys.lif_w)), cot); - cot = _tx_event(wir_r, "sys-memory-basket", - 4 * - (u2_soup_liv_w(u2_rail_rut_r(u2_wire_bas_r(wir_r))) - + cot = _tx_event(wir_r, "sys-memory-basket", + 4 * + (u2_soup_liv_w(u2_rail_rut_r(u2_wire_bas_r(wir_r))) - u2_trac_at(rac_r, sys.bos_w)), cot); #endif @@ -342,7 +342,7 @@ u2_tx_sys_bit(u2_ray wir_r, u2_bean val) u2_wrac_at(wir_r, wer.sys) = val; return bit; } - + /* u2_tx_glu_bit(): set glutem bit, returning old value. */ u2_bean @@ -353,7 +353,7 @@ u2_tx_glu_bit(u2_ray wir_r, u2_bean val) u2_wrac_at(wir_r, wer.glu) = val; return bit; } - + /* u2_tx_init(): initialize state. */ u2_ray @@ -391,17 +391,17 @@ u2_tx_open(u2_wire wir_r) u2_trac_be(rac_r, c3_d, sys.fin_d) = 0; u2_trac_be(rac_r, c3_d, sys.pod_d) = 0; - u2_trac_at(rac_r, sys.cas_x.med_w) = + u2_trac_at(rac_r, sys.cas_x.med_w) = u2_trac_at(rac_r, sys.cas_x.max_w) = 0; - u2_trac_at(rac_r, sys.men_x.med_w) = + u2_trac_at(rac_r, sys.men_x.med_w) = u2_trac_at(rac_r, sys.men_x.max_w) = 0; - u2_trac_at(rac_r, sys.bek_x.med_w) = + u2_trac_at(rac_r, sys.bek_x.med_w) = u2_trac_at(rac_r, sys.bek_x.max_w) = 0; u2_trac_at(rac_r, sys.lif_w) = u2_soup_liv_w(u2_rail_rut_r(wir_r)); - u2_trac_at(rac_r, sys.bos_w) = + u2_trac_at(rac_r, sys.bos_w) = u2_soup_liv_w(u2_rail_rut_r(u2_wire_bas_r(wir_r))); { @@ -418,7 +418,7 @@ u2_tx_open(u2_wire wir_r) } /* u2_tx_done(): produce a profile slab to render. Free internal state. -*/ +*/ u2_noun // produce u2_tx_done(u2_wire wir_r) { @@ -446,7 +446,7 @@ u2_tx_done(u2_wire wir_r) /* u2_tx_do_debug(): set debug bean. Return old value. */ -u2_bean +u2_bean u2_tx_do_debug(u2_ray wir_r, u2_bean lag) { u2_ray rac_r = u2_wire_rac_r(wir_r); @@ -458,7 +458,7 @@ u2_tx_do_debug(u2_ray wir_r, u2_bean lag) /* u2_tx_in_debug(): get debug bean. */ -u2_bean +u2_bean u2_tx_in_debug(u2_ray wir_r) { u2_ray rac_r = u2_wire_rac_r(wir_r); @@ -468,7 +468,7 @@ u2_tx_in_debug(u2_ray wir_r) /* u2_tx_do_profile(): set profile bean. Return old value. */ -u2_bean +u2_bean u2_tx_do_profile(u2_ray wir_r, u2_bean lag) { u2_ray rac_r = u2_wire_rac_r(wir_r); @@ -480,7 +480,7 @@ u2_tx_do_profile(u2_ray wir_r, u2_bean lag) /* u2_tx_in_profile(): get profile bean. */ -u2_bean +u2_bean u2_tx_in_profile(u2_ray wir_r) { u2_ray rac_r = u2_wire_rac_r(wir_r); @@ -489,7 +489,7 @@ u2_tx_in_profile(u2_ray wir_r) } static u2_bean -_tx_map_ok(u2_wire wir_r, +_tx_map_ok(u2_wire wir_r, u2_noun a) { if ( u2_nul == a ) { @@ -559,8 +559,8 @@ _tx_increment_soft(u2_wire wir_r, /* u2_tx_did_act(): record user actions. */ -void -u2_tx_did_act(u2_wire wir_r, +void +u2_tx_did_act(u2_wire wir_r, u2_noun did) // retain { u2_ray rac_r = u2_wire_rac_r(wir_r); @@ -578,7 +578,7 @@ u2_tx_did_act(u2_wire wir_r, ** u2_yes iff the task is not already in the stack. */ u2_bean -u2_tx_task_in(u2_wire wir_r, +u2_tx_task_in(u2_wire wir_r, u2_noun tak) // retain { // Temporarily disabled due to bail issues. @@ -691,7 +691,7 @@ _print_wall(u2_noun wal, } } #endif - + /* u2_tx_slog(): print debug syslog [0-3 tank] 0=debug 3=alarm */ void diff --git a/f/unix.c b/f/unix.c index 120abf730..385da5edd 100644 --- a/f/unix.c +++ b/f/unix.c @@ -29,7 +29,7 @@ _unix_term(u2_atom tat) } return u2_yes; } - else return u2_no; + else return u2_no; } static void _unix_dump(FILE*, u2_noun); @@ -98,7 +98,7 @@ _unix_scan_cell(u2_wire wir_r, return u2_bn_cell(wir_r, hed, tal); } - else { + else { c3_assert(c == ']'); return hed; } @@ -114,7 +114,7 @@ _unix_scan(u2_wire wir_r, if ( c == '[' ) { return _unix_scan_cell(wir_r, fil); - } + } else if ( c == '%' ) { c3_c buf[1025]; @@ -142,10 +142,10 @@ u2_ux_read(u2_ray wir_r, c3_w len_w; c3_c* nam_c; - if ( ext_c ) + if ( ext_c ) len_w = strlen(paf_c) + 1 + strlen(ext_c); else len_w = strlen(paf_c); - + nam_c = alloca(len_w + 1); if ( ext_c ) { snprintf(nam_c, len_w + 1, "%s.%s", paf_c, ext_c); @@ -171,7 +171,7 @@ u2_ux_read(u2_ray wir_r, } close(fid_i); - fil = u2_rl_bytes(wir_r, fln_w, (c3_y *)fil_c); + fil = u2_rl_bytes(wir_r, fln_w, (c3_y *)fil_c); free(fil_c); return fil; @@ -184,14 +184,14 @@ u2_weak u2_ux_read_deep(u2_wire wir_r, const c3_c* paf_c, const c3_c* ext_c) -{ +{ c3_w len_w; c3_c* nam_c; - if ( ext_c ) + if ( ext_c ) len_w = strlen(paf_c) + 1 + strlen(ext_c); else len_w = strlen(paf_c); - + nam_c = alloca(len_w + 1); if ( ext_c ) { snprintf(nam_c, len_w + 1, "%s.%s", paf_c, ext_c); @@ -221,10 +221,10 @@ u2_ux_write(u2_wire wir_r, c3_w len_w; c3_c* nam_c; - if ( ext_c ) + if ( ext_c ) len_w = strlen(paf_c) + 1 + strlen(ext_c); else len_w = strlen(paf_c); - + nam_c = alloca(len_w + 1); if ( ext_c ) { snprintf(nam_c, len_w + 1, "%s.%s", paf_c, ext_c); @@ -263,10 +263,10 @@ u2_ux_write_deep(u2_wire wir_r, c3_w len_w; c3_c* nam_c; - if ( ext_c ) + if ( ext_c ) len_w = strlen(paf_c) + 1 + strlen(ext_c); else len_w = strlen(paf_c); - + nam_c = alloca(len_w + 1); if ( ext_c ) { snprintf(nam_c, len_w + 1, "%s.%s", paf_c, ext_c); diff --git a/f/wire.c b/f/wire.c index b70fbbead..34cfafffa 100644 --- a/f/wire.c +++ b/f/wire.c @@ -1,5 +1,5 @@ /* f/wire.c -** +** ** This file is in the public domain. */ #include "all.h" @@ -47,14 +47,14 @@ u2_wr_init(c3_m hip_m, u2_wire_bas_r(wir_r) = bas_r; #if 0 - fprintf(stderr, "bas_r %d, hat %d, mat %d, cap %d, rut %d\n", + fprintf(stderr, "bas_r %d, hat %d, mat %d, cap %d, rut %d\n", bas_r >> LoomPageWords, u2_rail_hat_r(bas_r) >> LoomPageWords, u2_rail_mat_r(bas_r) >> LoomPageWords, u2_rail_cap_r(bas_r) >> LoomPageWords, u2_rail_rut_r(bas_r) >> LoomPageWords); - fprintf(stderr, "wir_r %d, hat %d, mat %d, cap %d, rut %d\n", + fprintf(stderr, "wir_r %d, hat %d, mat %d, cap %d, rut %d\n", wir_r >> LoomPageWords, u2_rail_hat_r(wir_r) >> LoomPageWords, u2_rail_mat_r(wir_r) >> LoomPageWords, @@ -121,7 +121,7 @@ _wr_open(c3_c* cpu_c, c3_c* fil_c, c3_c* suf_c, c3_w len_w) if ( -1 == fid_i ) { perror(ful_c); exit(1); } - if ( len_w && + if ( len_w && (-1 == ftruncate(fid_i, (len_w * (1 << (LoomPageWords + 2))))) ) { perror(ful_c); exit(1); diff --git a/include/v/vere.h b/include/v/vere.h index 59ab7ee50..1c3720d95 100644 --- a/include/v/vere.h +++ b/include/v/vere.h @@ -360,7 +360,10 @@ #if 0 uv_tty_t wax_u; // event handler state #else - uv_poll_t wax_u; + union { + uv_poll_t wax_u; + uv_pipe_t pop_u; + }; #endif struct termios bak_u; // cooked terminal state struct termios raw_u; // raw terminal state @@ -375,6 +378,7 @@ u2_ubuf* tou_u; // entry of output queue u2_ubuf* out_u; // exit of output queue # endif + u2_noun lin; // next line to blit u2_utat tat_u; // control state struct _u2_utty* nex_u; // next in host list } u2_utty; diff --git a/v/ames.c b/v/ames.c index 2531b5e0a..2f42df157 100644 --- a/v/ames.c +++ b/v/ames.c @@ -30,7 +30,7 @@ _ames_alloc(uv_handle_t* had_u, size_t len_i) { void* ptr_v = malloc(len_i); -// uL(fprintf(uH, "grab %p\n", ptr_v)); +// uL(fprintf(uH, "grab %p\n", ptr_v)); return uv_buf_init(ptr_v, len_i); } @@ -53,7 +53,7 @@ _ames_czar(c3_y imp_y, c3_s* por_s) if ( u2_yes == u2_Host.ops_u.loh ) { *por_s = 31337 + imp_y; return 0x7f000001; - } + } else { *por_s = 13337 + imp_y; @@ -105,7 +105,7 @@ _ames_czar(c3_y imp_y, c3_s* por_s) #endif break; } - rai_u = rai_u->ai_next; + rai_u = rai_u->ai_next; } } freeaddrinfo(air_u); @@ -209,15 +209,15 @@ u2_ames_ef_send(u2_noun lan, u2_noun pac) add_u.sin_addr.s_addr = htonl(pip_w); add_u.sin_port = htons(por_s); - if ( 0 != uv_udp_send(&ruq_u->snd_u, - &sam_u->wax_u, - &buf_u, 1, - add_u, + if ( 0 != uv_udp_send(&ruq_u->snd_u, + &sam_u->wax_u, + &buf_u, 1, + add_u, _ames_send_cb) ) { uL(fprintf(uH, "ames: send: %s\n", uv_strerror(uv_last_error(u2L)))); } // fprintf(stderr, "ames: send\r\n"); - } + } } } u2z(lan); u2z(pac); @@ -273,7 +273,7 @@ _ames_recv_cb(uv_udp_t* wax_u, /* u2_ames_io_init(): initialize ames I/O. */ -void +void u2_ames_io_init() { u2_ames* sam_u = &u2_Host.sam_u; @@ -292,11 +292,11 @@ u2_ames_io_init() exit(1); } num_y = u2_cr_byte(0, u2t(num)); - + _ames_czar(num_y, &por_s); // uL(fprintf(uH, "ames: czar: %s on %d\n", u2_Host.ops_u.imp_c, por_s)); u2z(num); - } + } if ( 0 != uv_udp_init(u2L, &u2_Host.sam_u.wax_u) ) { uL(fprintf(uH, "ames: init: %s\n", uv_strerror(uv_last_error(u2L)))); @@ -314,7 +314,7 @@ u2_ames_io_init() add_u.sin_port = htons(por_s); if ( uv_udp_bind(&sam_u->wax_u, add_u, 0) != 0 ) { - uL(fprintf(uH, "ames: bind: %s\n", + uL(fprintf(uH, "ames: bind: %s\n", uv_strerror(uv_last_error(u2L)))); c3_assert(0); } @@ -325,9 +325,9 @@ u2_ames_io_init() por_s = ntohs(add_u.sin_port); sam_u->por_s = por_s; - fprintf(stderr, "ames: on localhost, UDP %d.\n", por_s); + uL(fprintf(uH, "ames: on localhost, UDP %d.\n", por_s)); - uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); + uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); } // Timer too. @@ -338,7 +338,7 @@ u2_ames_io_init() /* u2_ames_io_exit(): terminate ames I/O. */ -void +void u2_ames_io_exit() { u2_ames* sam_u = &u2_Host.sam_u; @@ -353,8 +353,8 @@ u2_ames_io_poll() { u2_ames* sam_u = &u2_Host.sam_u; u2_noun wen = u2_reck_keep(u2A, u2nt(c3__gold, c3__ames, u2_nul)); - - if ( (u2_nul != wen) && + + if ( (u2_nul != wen) && (u2_yes == u2du(wen)) && (u2_yes == u2ud(u2t(wen))) ) { diff --git a/v/batz.c b/v/batz.c index 27d2eb321..e2104f2ac 100644 --- a/v/batz.c +++ b/v/batz.c @@ -26,7 +26,7 @@ /* u2_batz_io_init(): initialize batz timer. */ -void +void u2_batz_io_init(void) { u2_batz* beh_u = &u2_Host.beh_u; @@ -37,7 +37,7 @@ u2_batz_io_init(void) /* u2_batz_io_exit(): terminate timer. */ -void +void u2_batz_io_exit(void) { } @@ -64,8 +64,8 @@ u2_batz_io_poll(void) { u2_batz* beh_u = &u2_Host.beh_u; u2_noun wen = u2_reck_keep(u2A, u2nt(c3__gold, c3__batz, u2_nul)); - - if ( (u2_nul != wen) && + + if ( (u2_nul != wen) && (u2_yes == u2du(wen)) && (u2_yes == u2ud(u2t(wen))) ) { @@ -74,7 +74,7 @@ u2_batz_io_poll(void) gap_d += beh_u->run_w; if ( beh_u->run_w < 1024 ) { beh_u->run_w++; - } + } if ( u2_yes == beh_u->alm ) { uv_timer_stop(&beh_u->tim_u); diff --git a/v/fs.c b/v/fs.c index de531d1a3..7185961cf 100644 --- a/v/fs.c +++ b/v/fs.c @@ -58,7 +58,7 @@ u2_ve_date(c3_c* ext_c, u2_noun tah) u2_noun u2_ve_frep(u2_noun myp, u2_noun hat) { - // Total hack - switch to this form exclusively, + // Total hack - switch to this form exclusively, // then revise callers. { c3_c* dex_c = u2_cr_string(myp); @@ -78,7 +78,7 @@ u2_ve_frep(u2_noun myp, u2_noun hat) wen_w[1] = (wen_d >> 32ULL); free(dex_c); - return u2nt(u2_cr_met(3, fat), + return u2nt(u2_cr_met(3, fat), u2_ci_words(2, wen_w), fat); } diff --git a/v/http.c b/v/http.c index fe93b9193..2f06f5a44 100644 --- a/v/http.c +++ b/v/http.c @@ -43,7 +43,7 @@ _http_bod(c3_w len_w, const c3_y* hun_y) bod_u->len_w = len_w; memcpy(bod_u->hun_y, hun_y, len_w); - + bod_u->nex_u = 0; return bod_u; } @@ -100,7 +100,7 @@ _http_bods_free(u2_hbod* bod_u) /* _http_req_free(): free http request. */ -static void +static void _http_req_free(u2_hreq* req_u) { if ( req_u ) { @@ -136,7 +136,7 @@ _http_write_cb(uv_write_t* wri_u, c3_i sas_i) free(ruq_u->buf_y); free(ruq_u); } - + /* _http_respond_buf(): write back to http. */ static void @@ -146,16 +146,16 @@ _http_respond_buf(u2_hreq* req_u, uv_buf_t buf_u) ruq_u->buf_y = (c3_y*)buf_u.base; - if ( 0 != uv_write(&ruq_u->wri_u, + if ( 0 != uv_write(&ruq_u->wri_u, (uv_stream_t*)&(req_u->hon_u->wax_u), - &buf_u, 1, + &buf_u, 1, _http_write_cb) ) { uL(fprintf(uH, "respond: %s\n", uv_strerror(uv_last_error(u2L)))); _http_conn_dead(req_u->hon_u); } } - + /* _http_respond_body(): attach response body. */ static void @@ -289,7 +289,7 @@ _http_conn_free(uv_handle_t* han_t) */ static void _http_conn_dead(u2_hcon *hon_u) -{ +{ uv_read_stop((uv_stream_t*) &(hon_u->wax_u)); uv_close((uv_handle_t*) &(hon_u->wax_u), _http_conn_free); } @@ -363,7 +363,7 @@ _http_url(http_parser* par_u, const c3_c* buf_c, size_t siz_i) req_u->url_c = _http_more(req_u->url_c, buf_c, siz_i); return 0; } - + /* _http_header_field(): jhttp callback */ static c3_i @@ -372,7 +372,7 @@ _http_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i) u2_hreq *req_u = par_u->data; switch ( req_u->rat_e ) { - case u2_hreq_non: + case u2_hreq_non: case u2_hreq_val: { u2_hhed* hed_u = malloc(sizeof(*hed_u)); @@ -391,7 +391,7 @@ _http_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i) req_u->rat_e = u2_hreq_nam; return 0; } - + /* _http_header_value(): jhttp callback */ static c3_i @@ -436,13 +436,13 @@ _http_body(http_parser* par_u, const c3_c* buf_c, size_t siz_i) { { u2_hreq *req_u = par_u->data; - u2_hbod* bod_u; - + u2_hbod* bod_u; + bod_u = _http_bod(siz_i, (const c3_y*)buf_c); bod_u->nex_u = req_u->bod_u; req_u->bod_u = bod_u; - + return 0; } } @@ -463,12 +463,12 @@ _http_message_complete(http_parser* par_u) { if ( !hon_u->qer_u ) { c3_assert(!(hon_u->req_u)); - + hon_u->qer_u = hon_u->req_u = req_u; } else { hon_u->qer_u->nex_u = req_u; - } + } } // Dispatch event request. @@ -524,7 +524,7 @@ _http_req_new(u2_hcon* hon_u) /* _http_conn_read_cb(): server read callback. */ static void -_http_conn_read_cb(uv_stream_t* tcp_u, +_http_conn_read_cb(uv_stream_t* tcp_u, ssize_t siz_i, uv_buf_t buf_u) { @@ -545,8 +545,8 @@ _http_conn_read_cb(uv_stream_t* tcp_u, hon_u->ruc_u = _http_req_new(hon_u); } - if ( siz_i != http_parser_execute(hon_u->ruc_u->par_u, - &_http_settings, + if ( siz_i != http_parser_execute(hon_u->ruc_u->par_u, + &_http_settings, (c3_c*)buf_u.base, siz_i) ) { @@ -570,18 +570,18 @@ _http_conn_new(u2_http *htp_u) uv_tcp_init(u2L, &hon_u->wax_u); - if ( 0 != uv_accept((uv_stream_t*)&htp_u->wax_u, + if ( 0 != uv_accept((uv_stream_t*)&htp_u->wax_u, (uv_stream_t*)&hon_u->wax_u) ) { - uL(fprintf(uH, "http: accept: %s\n", + uL(fprintf(uH, "http: accept: %s\n", uv_strerror(uv_last_error(u2L)))); uv_close((uv_handle_t*)&hon_u->wax_u, 0); free(hon_u); } else { - uv_read_start((uv_stream_t*)&hon_u->wax_u, - _http_alloc, + uv_read_start((uv_stream_t*)&hon_u->wax_u, + _http_alloc, _http_conn_read_cb); hon_u->coq_l = htp_u->coq_l++; @@ -658,7 +658,7 @@ _http_list_to_heds(u2_noun lix) while ( 1 ) { if ( u2_nul == lix ) { break; - } + } else { u2_noun i_lix = u2h(lix); u2_noun pi_lix = u2h(i_lix); @@ -729,7 +729,7 @@ _http_octs_to_bod(u2_noun oct) bod_u->len_w = len_w; u2_cr_bytes(0, len_w, bod_u->hun_y, u2t(oct)); - + bod_u->nex_u = 0; u2z(oct); @@ -742,7 +742,7 @@ _http_octs_to_bod(u2_noun oct) static u2_noun _http_pox_to_noun(c3_w sev_l, c3_w coq_l, c3_w seq_l) { - return + return u2nt( c3__iron, c3__http, @@ -763,7 +763,7 @@ _http_request_to_noun(u2_hreq* req_u) default: fprintf(stderr, "strange request\r\n"); return u2_none; case u2_hmet_get: { med = c3__get; break; } case u2_hmet_post: { med = c3__post; break; } - } + } url = u2_ci_string(req_u->url_c); hed = _http_heds_to_list(req_u->hed_u); bod = req_u->bod_u ? u2nc(u2_nul, _http_bods_to_octs(req_u->bod_u)) : u2_nul; @@ -806,7 +806,7 @@ _http_request(u2_hreq* req_u) if ( u2_none != req ) { u2_noun pox = _http_pox_to_noun(req_u->hon_u->htp_u->sev_l, req_u->hon_u->coq_l, - req_u->seq_l); + req_u->seq_l); u2_reck_plan(u2_Host.arv_u, pox, u2nq(c3__this, u2_yes, 0, req)); } @@ -846,7 +846,7 @@ _http_flush(u2_hcon* hon_u) c3_assert(rub_u == req_u->bur_u); req_u->bur_u = 0; } - + free(rub_u); } } @@ -893,13 +893,13 @@ _http_creq_url(u2_noun hat) if ( u2_no == u2_cr_pqr(hat, &p_hat, &q_hat, &r_hat) ) { | u2_noun p_hat = u2h(hat); - u2_noun + u2_noun c3_ } /* _http_creq(): http request from noun. */ -static u2_creq* +static u2_creq* _http_creq_new(c3_l num_l, u2_noun req) { // u2_creq* ceq_u = malloc(sizeof(u2_creq)); @@ -937,7 +937,7 @@ _http_ccon_find(u2_bean sec, c3_s por_s, c3_c* hos_c) */ static void _http_ccon(c3_c* url_c) -{ +{ u2_bean sec, c3_s por_s, c3_c* hos_c; struct http_parser_url url_u; @@ -949,7 +949,7 @@ _http_ccon(c3_c* url_c) if ( !((1 << UF_SCHEMA) & url_u.field_set) ) { return 0; - } + } else if ( (url_u.field_data[UF_SCHEMA].len < 4) || strncmp("http", url_c + url_u.field_data[UF_SCHEMA].off, 4) ) { return 0; @@ -1000,7 +1000,7 @@ u2_http_ef_thus(c3_w num_w, #endif } -/* u2_http_ef_thou(): send %thou effect (incoming response) to http. +/* u2_http_ef_thou(): send %thou effect (incoming response) to http. */ void u2_http_ef_thou(c3_l coq_l, @@ -1023,7 +1023,7 @@ _http_listen_cb(uv_stream_t* str_u, c3_i sas_i) u2_http* htp_u = (u2_http*)str_u; if ( 0 != sas_i ) { - uL(fprintf(uH, "http: listen_cb: %s\n", + uL(fprintf(uH, "http: listen_cb: %s\n", uv_strerror(uv_last_error(u2L)))); } else { @@ -1053,7 +1053,7 @@ _http_start(u2_http* htp_u) uv_err_t las_u = uv_last_error(u2L); if ( UV_EADDRINUSE == las_u.code ) { - htp_u->por_w++; + htp_u->por_w++; continue; } else { @@ -1064,21 +1064,21 @@ _http_start(u2_http* htp_u) uv_err_t las_u = uv_last_error(u2L); if ( UV_EADDRINUSE == las_u.code ) { - htp_u->por_w++; + htp_u->por_w++; continue; } else { uL(fprintf(uH, "http: listen: %s\n", uv_strerror(las_u))); } } - uL(fprintf(uH, "http: live on %d\r\n", htp_u->por_w)); + uL(fprintf(uH, "http: live on %d\n", htp_u->por_w)); break; } } /* u2_http_io_init(): initialize http I/O. */ -void +void u2_http_io_init() { u2_http *htp_u = malloc(sizeof(*htp_u)); diff --git a/v/loop.c b/v/loop.c index 4884a5c1f..e6f885c7a 100644 --- a/v/loop.c +++ b/v/loop.c @@ -40,11 +40,11 @@ static jmp_buf Signal_buf; static uint8_t Sigstk[SIGSTKSZ]; typedef enum { - sig_none, - sig_overflow, - sig_interrupt, + sig_none, + sig_overflow, + sig_interrupt, sig_terminate, - sig_memory, + sig_memory, sig_assert, sig_timer } u2_kill; @@ -65,7 +65,7 @@ _lo_signal_handle_over(int emergency, stackoverflow_context_t scp) if ( 1 == emergency ) { write(2, "stack emergency\n", strlen("stack emergency" + 2)); abort(); - } else + } else #endif { Sigcause = sig_overflow; @@ -197,7 +197,7 @@ _lo_poll(void) #if 0 /* _lo_how(): print how. */ -static const c3_c* +static const c3_c* _lo_how(u2_noun how) { switch ( how ) { @@ -301,7 +301,7 @@ void u2_lo_sway(c3_l tab_l, u2_noun tax) { u2_noun mok = u2_dc("mook", 2, tax); - + u2_lo_punt(tab_l, u2k(u2t(mok))); u2z(mok); } @@ -380,13 +380,13 @@ _lo_soft(u2_reck* rec_u, c3_w sec_w, u2_funk fun_f, u2_noun arg) u2z(arg); u2z(hoe); u2z(mok); - } + } else { u2_noun pro = fun_f(rec_u, arg); _lo_signal_done(); u2_cm_done(); - + u2_rl_fall(u2_Wire); pro = u2_rl_take(u2_Wire, pro); u2_rl_flog(u2_Wire); @@ -411,7 +411,7 @@ _lo_hard(u2_reck* rec_u, u2_funk fun_f, u2_noun arg) u2_noun poo = u2k(u2t(pro)); u2z(pro); return poo; - } + } else { u2_lo_punt(2, u2k(u2t(pro))); u2z(pro); @@ -476,8 +476,8 @@ _lo_pack(u2_reck* rec_u, u2_noun ron) uL(fprintf(uH, "lo_save: seek failed\n")); c3_assert(0); } -#if 0 - uL(fprintf(uH, "log: write: at %d, %d: lar ent %d, len %d, mug %x\n", +#if 0 + uL(fprintf(uH, "log: write: at %d, %d: lar ent %d, len %d, mug %x\n", lug_u->len_w, tar_w, lar_u.ent_w, @@ -520,7 +520,7 @@ _lo_save(u2_reck* rec_u, u2_noun ovo) /* _lo_pike(): poke with floating core. */ -static u2_noun +static u2_noun _lo_pike(u2_reck* rec_u, u2_noun ovo, u2_noun cor) { u2_noun fun = u2_cn_nock(cor, u2k(u2_cx_at(42, cor))); @@ -622,18 +622,18 @@ _lo_lame(u2_reck* rec_u, u2_noun ovo, u2_noun why, u2_noun tan) } // u2_lo_show("data", u2k(u2t(u2t(ovo)))); - u2z(ovo); + u2z(ovo); gon = _lo_soft(rec_u, 0, u2_reck_poke, u2k(bov)); if ( u2_blip == u2h(gon) ) { _lo_sure(rec_u, bov, u2k(u2h(u2t(gon))), u2k(u2t(u2t(gon)))); - + u2z(gon); } else { u2z(gon); { - u2_noun vab = u2nc(u2k(u2h(bov)), + u2_noun vab = u2nc(u2k(u2h(bov)), u2nc(c3__warn, u2_ci_tape("crude crash!"))); u2_noun nog = _lo_soft(rec_u, 0, u2_reck_poke, u2k(vab)); @@ -655,12 +655,12 @@ static void _lo_punk(u2_reck* rec_u, u2_noun ovo); /* _lo_nick(): transform enveloped packets, [vir cor]. */ -static u2_noun +static u2_noun _lo_nick(u2_reck* rec_u, u2_noun vir, u2_noun cor) { if ( u2_nul == vir ) { return u2nt(u2_blip, vir, cor); - } + } else { u2_noun i_vir = u2h(vir); u2_noun pi_vir, qi_vir; @@ -716,7 +716,7 @@ _lo_nick(u2_reck* rec_u, u2_noun vir, u2_noun cor) static void _lo_punk(u2_reck* rec_u, u2_noun ovo) { - // c3_c* txt_c = u2_cr_string(u2h(u2t(ovo))); + // c3_c* txt_c = u2_cr_string(u2h(u2t(ovo))); c3_w sec_w; // static c3_w num_w; u2_noun gon; @@ -725,7 +725,7 @@ _lo_punk(u2_reck* rec_u, u2_noun ovo) // XX this is wrong - the timer should be on the original hose. // - if ( (c3__term == u2h(u2t(u2h(ovo)))) || + if ( (c3__term == u2h(u2t(u2h(ovo)))) || (c3__batz == u2h(u2t(u2h(ovo)))) ) { sec_w = 0; } else sec_w = 60; @@ -749,7 +749,7 @@ _lo_punk(u2_reck* rec_u, u2_noun ovo) u2_noun vir = u2k(u2h(u2t(gon))); u2_noun cor = u2k(u2t(u2t(gon))); u2_noun nug; - + u2z(gon); nug = _lo_nick(rec_u, vir, cor); @@ -759,11 +759,11 @@ _lo_punk(u2_reck* rec_u, u2_noun ovo) u2z(nug); _lo_lame(rec_u, ovo, why, tan); - } + } else { vir = u2k(u2h(u2t(nug))); cor = u2k(u2t(u2t(nug))); - + u2z(nug); _lo_sure(rec_u, ovo, vir, cor); } @@ -805,17 +805,17 @@ _lo_sing(u2_reck* rec_u, u2_noun ovo) u2_noun vir = u2k(u2h(u2t(gon))); u2_noun cor = u2k(u2t(u2t(gon))); u2_noun nug; - + u2z(gon); nug = _lo_nick(rec_u, vir, cor); if ( u2_blip != u2h(nug) ) { _lo_suck(rec_u, ovo, nug); - } + } else { vir = u2h(u2t(nug)); cor = u2k(u2t(u2t(nug))); - + while ( u2_nul != vir ) { u2_noun fex = u2h(vir); u2_noun fav = u2t(fex); @@ -872,7 +872,7 @@ _lo_work(u2_reck* rec_u) new = u2k(u2A->now); tms_w = (c3_w)u2_time_gap_ms(old, new); - if ( tms_w >= 20 ) + if ( tms_w >= 20 ) { uL(fprintf(uH, "hear: %d ms\n", tms_w)); } @@ -967,7 +967,7 @@ _lo_home(u2_reck* rec_u) // Copy urbit.pill. // { - snprintf(ful_c, 2048, "cp %s/urbit.pill %s", + snprintf(ful_c, 2048, "cp %s/urbit.pill %s", u2_Host.ops_u.hom_c, u2_Host.cpu_c); if ( 0 != system(ful_c) ) { uL(fprintf(uH, "could not %s\n", ful_c)); @@ -1002,14 +1002,14 @@ _lo_cask(u2_reck* rec_u, c3_c* dir_c, u2_bean nun) } else { c3_c* say_c = malloc(strlen(paw_c) + 2); - u2_noun say; + u2_noun say; say_c[0] = '~'; say_c[1] = 0; strncat(say_c, paw_c, strlen(paw_c) - 1); say = u2_do("slay", u2_ci_string(say_c)); - if ( (u2_nul == say) || + if ( (u2_nul == say) || (u2_blip != u2h(u2t(say))) || ('p' != u2h(u2t(u2t(say)))) ) { @@ -1076,7 +1076,7 @@ _lo_bask(c3_c* pop_c, u2_bean may) fpurge(stdin); fgets(ans_c, 2, stdin); - + if ( (ans_c[0] != 'y') && (ans_c[0] != 'n') ) { continue; } else { @@ -1163,9 +1163,9 @@ _lo_staf(u2_reck* rec_u, c3_l key_l) u2_noun pas; - if ( (u2_nul == say) || + if ( (u2_nul == say) || (u2_blip != u2h(u2t(say))) || - ('p' != u2h(u2t(u2t(say)))) ) + ('p' != u2h(u2t(u2t(say)))) ) { uL(fprintf(uH, "staf: %s is corrupt\n", ful_c)); u2z(say); @@ -1208,13 +1208,13 @@ _lo_zest(u2_reck* rec_u) // Create the ship directory. // _lo_home(rec_u); - + // Create the record file. { snprintf(ful_c, 2048, "%s/egz.hope", u2_Host.cpu_c); - if ( ((fid_i = open(ful_c, O_CREAT | O_WRONLY | O_EXCL, 0600)) < 0) || - (fstat(fid_i, &buf_b) < 0) ) + if ( ((fid_i = open(ful_c, O_CREAT | O_WRONLY | O_EXCL, 0600)) < 0) || + (fstat(fid_i, &buf_b) < 0) ) { uL(fprintf(uH, "can't create record (%s)\n", ful_c)); u2_lo_bail(rec_u); @@ -1252,7 +1252,7 @@ _lo_zest(u2_reck* rec_u) led_u.kno_w = rec_u->kno_w; if ( 0 == rec_u->key ) { - led_u.key_l = 0; + led_u.key_l = 0; } else { led_u.key_l = u2_mug(rec_u->key); @@ -1351,8 +1351,8 @@ _lo_rest(u2_reck* rec_u) { snprintf(ful_c, 2048, "%s/egz.hope", u2_Host.cpu_c); - if ( ((fid_i = open(ful_c, O_RDWR)) < 0) || - (fstat(fid_i, &buf_b) < 0) ) + if ( ((fid_i = open(ful_c, O_RDWR)) < 0) || + (fstat(fid_i, &buf_b) < 0) ) { uL(fprintf(uH, "rest: can't open record (%s)\n", ful_c)); u2_lo_bail(rec_u); @@ -1424,7 +1424,7 @@ _lo_rest(u2_reck* rec_u) rec_u->key = key; break; } - } + } } } @@ -1463,7 +1463,7 @@ _lo_rest(u2_reck* rec_u) } #if 0 - uL(fprintf(uH, "log: read: at %d, %d: lar ent %d, len %d, mug %x\n", + uL(fprintf(uH, "log: read: at %d, %d: lar ent %d, len %d, mug %x\n", (tar_w - lar_u.len_w), tar_w, lar_u.ent_w, @@ -1474,7 +1474,7 @@ _lo_rest(u2_reck* rec_u) if ( end_w == u2_Host.lug_u.len_w ) { ent_w = las_w = lar_u.ent_w; - } + } else { if ( lar_u.ent_w != (ent_w - 1) ) { uL(fprintf(uH, "record (%s) is corrupt (g)\n", ful_c)); @@ -1514,7 +1514,7 @@ _lo_rest(u2_reck* rec_u) if ( u2_no == u2du(dep) ) { uL(fprintf(uH, "record (%s) is corrupt (k)\n", ful_c)); u2_lo_bail(rec_u); - } + } else { ron = u2k(u2t(dep)); u2z(dep); @@ -1583,7 +1583,7 @@ _lo_rest(u2_reck* rec_u) } // Now, who the fsck are you? No, really. - { + { u2_noun who; c3_c* fil_c; c3_c* who_c; @@ -1605,7 +1605,7 @@ _lo_rest(u2_reck* rec_u) #endif // Rewrite the header. Will probably corrupt the record. - { + { u2_uled led_u; led_u.mag_l = u2_mug('f'); @@ -1614,7 +1614,7 @@ _lo_rest(u2_reck* rec_u) led_u.key_l = rec_u->key ? u2_mug(rec_u->key) : 0; led_u.kno_w = rec_u->kno_w; // may need actual translation! led_u.tno_l = 1; - + if ( (-1 == lseek(fid_i, 0, SEEK_SET)) || (sizeof(led_u) != write(fid_i, &led_u, sizeof(led_u))) ) { @@ -1631,7 +1631,7 @@ _lo_rest(u2_reck* rec_u) /* _lo_zen(): get OS entropy. */ -static u2_noun +static u2_noun _lo_zen(u2_reck* rec_u) { c3_w rad_w[8]; @@ -1695,7 +1695,7 @@ _lo_boot(void) static void _lo_bench_noop(c3_w num_w) { - c3_w i_w; + c3_w i_w; for ( i_w = 0; i_w < num_w; i_w++ ) { u2_reck_plan(u2A, u2nq(c3__gold, c3__term, 1, u2_nul), @@ -1795,11 +1795,11 @@ _lo_bench(const c3_c* lab_c, void (*fun)(c3_w), c3_w num_w) c3_w tms_w = (c3_w)u2_time_gap_ms(old, new); if ( tms_w > (10 * num_w) ) { - uL(fprintf(uH, "bench: %s*%d: %d ms, %d ms each.\n", + uL(fprintf(uH, "bench: %s*%d: %d ms, %d ms each.\n", lab_c, num_w, tms_w, (tms_w / num_w))); } else { - uL(fprintf(uH, "bench: %s*%d: %d ms, %d us each.\n", + uL(fprintf(uH, "bench: %s*%d: %d ms, %d us each.\n", lab_c, num_w, tms_w, ((tms_w * 1000) / num_w))); } } @@ -1836,7 +1836,7 @@ _lo_slow() void u2_lo_loop(u2_reck* rec_u) { - uv_loop_t* lup_u = uv_default_loop(); + uv_loop_t* lup_u = uv_default_loop(); u2_Host.lup_u = lup_u; @@ -1890,7 +1890,7 @@ _lo_mark_reck(u2_reck* rec_u) { u2_cart* egg_u; - + egg_w = 0; for ( egg_u = rec_u->ova.egg_u; egg_u; egg_u = egg_u->nex_u ) { egg_w += u2_cm_mark_noun(egg_u->egg); @@ -1930,7 +1930,7 @@ _lo_word(c3_w wod_w) top = u2_no; } if ( wod_w / (1000 * 1000) ) { - uL(fprintf(uH, ((top == u2_yes) ? "%u." : "%03u."), + uL(fprintf(uH, ((top == u2_yes) ? "%u." : "%03u."), wod_w / (1000 * 1000))); wod_w %= (1000 * 1000); top = u2_no; @@ -1961,7 +1961,7 @@ u2_lo_grab(c3_c* cap_c, u2_noun som, ...) siz_w += u2_cm_mark_noun(som); while ( u2_none != (tur = va_arg(vap, u2_noun)) ) { - siz_w += u2_cm_mark_noun(tur); + siz_w += u2_cm_mark_noun(tur); } } va_end(vap); diff --git a/v/main.c b/v/main.c index 781592184..7a3ed0786 100644 --- a/v/main.c +++ b/v/main.c @@ -30,7 +30,7 @@ */ extern u2_ho_driver j2_da(k_191); - /* Built-in battery drivers. Null `cos` terminates. + /* Built-in battery drivers. Null `cos` terminates. */ u2_ho_driver *HostDriverBase[] = { &j2_k_191_d, @@ -129,7 +129,7 @@ _main_getopt(c3_i argc, c3_c** argv) if ( argc != (optind + 1) ) { return u2_no; - } else { + } else { { c3_c* ash_c; @@ -226,9 +226,9 @@ main(c3_i argc, { u2_wr_check_init(u2_Host.ops_u.cpu_c); - if ( (u2_no == u2_Host.ops_u.nuu) && + if ( (u2_no == u2_Host.ops_u.nuu) && (u2_no == u2_Host.ops_u.rez) && - (u2_yes == u2_loom_load()) ) + (u2_yes == u2_loom_load()) ) { u2_Host.wir_r = u2_ray_of(0, 0); u2_Wire = u2_Host.wir_r; @@ -246,7 +246,7 @@ main(c3_i argc, u2_Host.kno_w = kno_w; u2_ho_push(); - } + } else { u2_loom_boot(); u2_Host.wir_r = u2_wr_init(c3__rock, u2_ray_of(0, 0), u2_ray_of(1, 0)); @@ -268,7 +268,7 @@ main(c3_i argc, printf("time: %s\n", dyt_c); free(dyt_c); } - } + } else { // Set outside bail trap. Should not be used, but you never know... // @@ -282,7 +282,7 @@ main(c3_i argc, kno_w = DefaultKernel; } else { kno_w = u2_Host.ops_u.kno_w; - } + } } // Load the system. diff --git a/v/reck.c b/v/reck.c index 07653b033..6d930df07 100644 --- a/v/reck.c +++ b/v/reck.c @@ -36,7 +36,7 @@ _reck_nock_poke(u2_reck* rec_u, u2_noun ovo) { u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(42, rec_u->roc))); u2_noun sam, pro; - + sam = u2nc(u2k(rec_u->now), ovo); #if 0 { @@ -88,14 +88,14 @@ _reck_nock_wish(u2_reck* rec_u, u2_noun txt) /* u2_reck_gate(): load a kernel function. */ -u2_noun +u2_noun u2_reck_gate(const c3_c* txt_c) { u2_noun txt = u2_ci_string(txt_c); u2_weak gat = u2_ckd_by_get(u2k(u2_Arv->yot), u2k(txt)); if ( u2_none == gat ) { - gat = _reck_nock_wish(u2_Arv, u2k(txt)); + gat = _reck_nock_wish(u2_Arv, u2k(txt)); u2_Arv->yot = u2_ckd_by_put(u2_Arv->yot, u2k(txt), u2k(gat)); } u2z(txt); @@ -104,7 +104,7 @@ u2_reck_gate(const c3_c* txt_c) /* u2_reck_do(): use a kernel function. */ -u2_noun +u2_noun u2_reck_do(const c3_c* txt_c, u2_noun arg) { return u2_cn_mung(u2_reck_gate(txt_c), arg); @@ -112,7 +112,7 @@ u2_reck_do(const c3_c* txt_c, u2_noun arg) /* u2_reck_wish(): noun from expression */ -u2_noun +u2_noun u2_reck_wish(u2_reck* rec_u, c3_c* str_c) { return _reck_nock_wish(rec_u, u2_ci_string(str_c)); @@ -129,7 +129,7 @@ _reck_scot(u2_reck* rec_u, u2_noun dim) #if 0 /* _reck_spoo(): noun path from c, kind of a hack. */ -static u2_noun +static u2_noun _reck_spoo(c3_c* pax_c) { if ( !*pax_c ) { @@ -139,14 +139,14 @@ _reck_spoo(c3_c* pax_c) if ( !ash_c ) { return u2nc(u2_ci_string(pax_c), u2_nul); - } + } else { u2_noun pan; *ash_c = 0; pan = u2_ci_string(pax_c); *ash_c = '/'; - + return u2nc(pan, _reck_spoo(ash_c + 1)); } } @@ -200,11 +200,11 @@ u2_reck_numb(u2_reck* rec_u) struct timeval tp; gettimeofday(&tp, 0); - rec_u->sev_l = 0x7fffffff & + rec_u->sev_l = 0x7fffffff & ( ((c3_w) tp.tv_sec) ^ u2_mug(0x7fffffff & ((c3_w) tp.tv_usec)) ^ u2_mug(getpid())); - u2z(rec_u->sen); + u2z(rec_u->sen); rec_u->sen = _reck_scot(rec_u, u2nc(c3__uv, rec_u->sev_l)); } @@ -213,7 +213,7 @@ u2_reck_numb(u2_reck* rec_u) */ static void _reck_time_bump(u2_reck* rec_u) -{ +{ c3_d bum_d = (1ULL << 48ULL); rec_u->now = u2_cka_add(rec_u->now, u2_ci_chubs(1, &bum_d)); @@ -230,7 +230,7 @@ u2_reck_peek(u2_reck* rec_u, u2_noun our, u2_noun hap) /* u2_reck_keep(): measure timer. */ -u2_noun +u2_noun u2_reck_keep(u2_reck* rec_u, u2_noun hap) { return _reck_nock_keep(rec_u, hap); @@ -251,7 +251,7 @@ _reck_init_veer(u2_reck* rec_u, u2_noun nam, u2_noun pax, u2_noun txt) u2z(hoe); exit(1); - } + } else { { u2_noun ovo, pro, rog; @@ -270,10 +270,10 @@ _reck_init_veer(u2_reck* rec_u, u2_noun nam, u2_noun pax, u2_noun txt) u2z(rec_u->roc); rec_u->roc = rog; } - } + } } -/* u2_reck_cold(): load full arvo with vanes, from new solid state. +/* u2_reck_cold(): load full arvo with vanes, from new solid state. */ void u2_reck_cold(u2_reck* rec_u, c3_w kno_w) @@ -388,7 +388,7 @@ u2_reck_init(u2_reck* rec_u, c3_w kno_w, u2_noun ken) if ( kno_w > 191 ) { c3_assert(!"old kernel not supported"); - } + } else { rec_u->ken = ken; rec_u->roc = u2_cn_nock(0, u2k(ken)); @@ -412,27 +412,27 @@ u2_reck_init(u2_reck* rec_u, c3_w kno_w, u2_noun ken) // Direct poke to install tang/vanes. Shd be in egz but isnt. // { - _reck_init_veer(rec_u, 0, + _reck_init_veer(rec_u, 0, u2nc(c3__zuse, u2_nul), _reck_load_arvo(rec_u, "zuse")); - _reck_init_veer(rec_u, 'a', - u2nc(c3__ames, u2_nul), + _reck_init_veer(rec_u, 'a', + u2nc(c3__ames, u2_nul), _reck_load_arvo(rec_u, "ames")); - _reck_init_veer(rec_u, 'b', + _reck_init_veer(rec_u, 'b', u2nc(c3__batz, u2_nul), _reck_load_arvo(rec_u, "batz")); - _reck_init_veer(rec_u, 'c', + _reck_init_veer(rec_u, 'c', u2nc(c3__clay, u2_nul), _reck_load_arvo(rec_u, "clay")); - _reck_init_veer(rec_u, 'd', + _reck_init_veer(rec_u, 'd', u2nc(c3__dill, u2_nul), _reck_load_arvo(rec_u, "dill")); - _reck_init_veer(rec_u, 'e', + _reck_init_veer(rec_u, 'e', u2nc(c3__eyre, u2_nul), _reck_load_arvo(rec_u, "eyre")); } @@ -455,7 +455,7 @@ u2_reck_init(u2_reck* rec_u, c3_w kno_w, u2_noun ken) /* _reck_mole(): parse simple atomic mole. */ -static u2_bean +static u2_bean _reck_mole(u2_reck* rec_u, u2_noun fot, u2_noun san, @@ -483,7 +483,7 @@ _reck_mole(u2_reck* rec_u, /* _reck_lily(): parse little atom. */ static u2_bean -_reck_lily(u2_reck* rec_u, u2_noun fot, u2_noun txt, c3_l* tid_l) +_reck_lily(u2_reck* rec_u, u2_noun fot, u2_noun txt, c3_l* tid_l) { c3_d ato_d; @@ -512,14 +512,14 @@ _reck_kick_term(u2_reck* rec_u, u2_noun pox, c3_l tid_l, u2_noun fav) } else switch ( u2h(fav) ) { default: u2z(pox); u2z(fav); return u2_no; - case c3__bbye: + case c3__bbye: { u2_reck_sync(rec_u); // u2_reck_plan(rec_u, pox, u2nc(c3__helo, u2_nul)); u2z(pox); u2z(fav); return u2_yes; - } break; - + } break; + case c3__blit: p_fav = u2t(fav); { u2_term_ef_blit(tid_l, u2k(p_fav)); @@ -527,7 +527,7 @@ _reck_kick_term(u2_reck* rec_u, u2_noun pox, c3_l tid_l, u2_noun fav) u2z(pox); u2z(fav); return u2_yes; } break; - case c3__logo: + case c3__logo: { u2_Host.liv = u2_no; @@ -558,7 +558,7 @@ _reck_kick_term(u2_reck* rec_u, u2_noun pox, c3_l tid_l, u2_noun fav) /* _reck_kick_http(): apply http effects. */ static u2_bean -_reck_kick_http(u2_reck* rec_u, +_reck_kick_http(u2_reck* rec_u, u2_noun pox, c3_l coq_l, c3_l seq_l, @@ -568,14 +568,14 @@ _reck_kick_http(u2_reck* rec_u, if ( u2_no == u2du(fav) ) { u2z(pox); u2z(fav); return u2_no; - } + } else switch ( u2h(fav) ) { default: u2z(pox); u2z(fav); return u2_no; case c3__thus: p_fav = u2h(u2t(fav)); q_fav = u2t(u2t(fav)); { u2_http_ef_thus(u2_cr_word(0, p_fav), u2k(q_fav)); - + return u2_yes; } case c3__thou: p_fav = u2t(fav); @@ -645,7 +645,7 @@ static u2_bean _reck_kick_spec(u2_reck* rec_u, u2_noun pox, u2_noun fav) { u2_noun i_pox, t_pox; - + if ( (u2_no == u2_cr_cell(pox, &i_pox, &t_pox)) || ((i_pox != c3__gold) && (i_pox != c3__iron) && (i_pox != c3__lead)) ) { @@ -694,7 +694,7 @@ _reck_kick_spec(u2_reck* rec_u, u2_noun pox, u2_noun fav) return _reck_kick_http(rec_u, pox, coq_l, seq_l, fav); } break; - case c3__clay: + case c3__clay: case c3__sync: { return _reck_kick_sync(rec_u, pox, fav); } break; @@ -703,7 +703,7 @@ _reck_kick_spec(u2_reck* rec_u, u2_noun pox, u2_noun fav) if ( (u2_nul != tt_pox) ) { u2z(pox); u2z(fav); return u2_no; } - else { + else { return _reck_kick_ames(rec_u, pox, fav); } } break; @@ -736,10 +736,10 @@ _reck_kick_norm(u2_reck* rec_u, u2_noun pox, u2_noun fav) { if ( u2_no == u2du(fav) ) { u2z(pox); u2z(fav); return u2_no; - } + } else switch ( u2h(fav) ) { default: u2z(pox); u2z(fav); return u2_no; - + case c3__exit: { uL(fprintf(uH, "<<>>\n")); @@ -781,14 +781,14 @@ u2_reck_kick(u2_reck* rec_u, u2_noun ovo) #if 0 (c3__talk == u2h(u2t(ovo))) || (c3__helo == u2h(u2t(ovo))) || - (c3__init == u2h(u2t(ovo))) ) + (c3__init == u2h(u2t(ovo))) ) #endif { - u2_reck_plan(rec_u, u2nt(c3__gold, c3__term, u2_nul), + u2_reck_plan(rec_u, u2nt(c3__gold, c3__term, u2_nul), u2nc(c3__flog, u2k(u2t(ovo)))); } else { - uL(fprintf(uH, "kick: lost %%%s on %s\n", + uL(fprintf(uH, "kick: lost %%%s on %s\n", u2_cr_string(u2h(u2t(ovo))), u2_cr_string(tox))); #if 0 @@ -836,11 +836,11 @@ u2_reck_boot(u2_reck* rec_u) u2z(hoe); exit(1); - } + } else { u2_reck_cold(rec_u, u2_Host.kno_w); u2_cm_done(); - + u2_cm_purge(); } } @@ -869,11 +869,11 @@ u2_reck_prick(u2_reck* rec_u, u2_noun our, u2_noun hap) u2z(hoe); return u2_nul; - } + } else { que = u2_reck_peek(rec_u, our, hap); u2_cm_done(); - + u2_cm_purge(); } return que; @@ -916,6 +916,6 @@ u2_reck_plow(u2_reck* rec_u, u2_noun ova) u2_reck_plan(rec_u, u2k(u2h(ovo)), u2k(u2t(ovo))); ovi = u2t(ovi); - } + } u2z(ova); } diff --git a/v/save.c b/v/save.c index bf9567a62..82e60091d 100644 --- a/v/save.c +++ b/v/save.c @@ -52,7 +52,7 @@ _save_time_cb(uv_timer_t* tim_u, c3_i sas_i) if ( 0 == (pid_w = fork()) ) { u2_loom_save(u2A->ent_w); exit(0); - } + } else { uL(fprintf(uH, "checkpoint: process %d\n", pid_w)); @@ -63,7 +63,7 @@ _save_time_cb(uv_timer_t* tim_u, c3_i sas_i) u2_loom_save(u2A->ent_w); sav_u->ent_w = u2A->ent_w; #endif - } + } } /* u2_save_ef_chld(): report save termination. @@ -90,7 +90,7 @@ u2_save_ef_chld(void) /* u2_save_io_init(): initialize autosave. */ -void +void u2_save_io_init(void) { u2_save* sav_u = &u2_Host.sav_u; @@ -101,12 +101,12 @@ u2_save_io_init(void) uv_timer_init(u2L, &sav_u->tim_u); uv_timer_start(&sav_u->tim_u, _save_time_cb, 15000, 15000); - uv_signal_start(&sav_u->sil_u, _save_sign_cb, SIGCHLD); + uv_signal_start(&sav_u->sil_u, _save_sign_cb, SIGCHLD); } /* u2_save_io_exit(): terminate save I/O. */ -void +void u2_save_io_exit(void) { } diff --git a/v/term.c b/v/term.c index b24d22ab3..3d950de89 100644 --- a/v/term.c +++ b/v/term.c @@ -28,6 +28,7 @@ static void _term_read_cb(uv_stream_t*, ssize_t, uv_buf_t); #if 1 static void _term_poll_cb(uv_poll_t*, c3_i, c3_i); #endif +static void _term_it_do_writes(u2_utty*); #if 0 /* _term_alloc(): libuv buffer allocator. @@ -41,28 +42,28 @@ _term_alloc(uv_handle_t* had_u, size_t len_i) /* u2_term_io_init(): initialize terminal. */ -void +void u2_term_io_init() { - if ( u2_no == u2_Host.ops_u.dem ) { - u2_utty* uty_u = malloc(sizeof(u2_utty)); - c3_i fid_i = 0; // stdin, yes we write to it... + u2_utty* uty_u = malloc(sizeof(u2_utty)); + if ( u2_yes == u2_Host.ops_u.dem ) { + uty_u->fid_i = 1; + uty_u->lin = u2_nul; + + uv_pipe_init(u2L, &(uty_u->pop_u), uty_u->fid_i); + uv_pipe_open(&(uty_u->pop_u), uty_u->fid_i); + } + else { // Initialize event processing. Rawdog it. // { - uty_u->fid_i = fid_i; + uty_u->fid_i = 0; // stdin, yes we write to it... -#if 0 - uv_tty_init(u2L, &(uty_u->wax_u), fid_i, 1); - uv_tty_set_mode(&(uty_u->wax_u), 1); - uv_read_start((uv_stream_t*)&uty_u->wax_u, _term_alloc, _term_read_cb); -#else - uv_poll_init(u2L, &(uty_u->wax_u), fid_i); - uv_poll_start(&(uty_u->wax_u), - (UV_READABLE | UV_WRITABLE), + uv_poll_init(u2L, &(uty_u->wax_u), uty_u->fid_i); + uv_poll_start(&(uty_u->wax_u), + UV_READABLE | UV_WRITABLE, _term_poll_cb); -#endif } // Configure horrible stateful terminfo api. @@ -127,23 +128,23 @@ u2_term_io_init() } uty_u->ufo_u.inn.max_w = 0; - if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcuu1_y)) > - uty_u->ufo_u.inn.max_w ) + if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcuu1_y)) > + uty_u->ufo_u.inn.max_w ) { uty_u->ufo_u.inn.max_w = len_w; } - if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcud1_y)) > - uty_u->ufo_u.inn.max_w ) + if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcud1_y)) > + uty_u->ufo_u.inn.max_w ) { uty_u->ufo_u.inn.max_w = len_w; } - if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcub1_y)) > - uty_u->ufo_u.inn.max_w ) + if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcub1_y)) > + uty_u->ufo_u.inn.max_w ) { uty_u->ufo_u.inn.max_w = len_w; } - if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcuf1_y)) > - uty_u->ufo_u.inn.max_w ) + if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcuf1_y)) > + uty_u->ufo_u.inn.max_w ) { uty_u->ufo_u.inn.max_w = len_w; } @@ -153,10 +154,10 @@ u2_term_io_init() // #if 1 { - if ( 0 != tcgetattr(fid_i, &uty_u->bak_u) ) { + if ( 0 != tcgetattr(uty_u->fid_i, &uty_u->bak_u) ) { c3_assert(!"init-tcgetattr"); } - if ( -1 == fcntl(fid_i, F_GETFL, &uty_u->cug_i) ) { + if ( -1 == fcntl(uty_u->fid_i, F_GETFL, &uty_u->cug_i) ) { c3_assert(!"init-fcntl"); } uty_u->cug_i &= ~O_NONBLOCK; // could fix? @@ -175,7 +176,7 @@ u2_term_io_init() uty_u->raw_u.c_oflag &= ~(OPOST); uty_u->raw_u.c_cc[VMIN] = 0; uty_u->raw_u.c_cc[VTIME] = 0; - } + } #endif // Initialize mirror and accumulator state. @@ -191,25 +192,21 @@ u2_term_io_init() uty_u->tat_u.fut.len_w = 0; uty_u->tat_u.fut.wid_w = 0; } + } - // This is terminal 1, linked in host. - // - { - uty_u->tid_l = 1; -#if 1 - uty_u->out_u = 0; - uty_u->tou_u = 0; -#endif + // This is terminal 1, linked in host. + // + { + uty_u->tid_l = 1; + uty_u->out_u = 0; + uty_u->tou_u = 0; - uty_u->nex_u = u2_Host.uty_u; - u2_Host.uty_u = uty_u; - u2_Host.tem_u = uty_u; - } + uty_u->nex_u = u2_Host.uty_u; + u2_Host.uty_u = uty_u; + u2_Host.tem_u = uty_u; + } - // Start reading. - // - -#if 1 + if ( u2_no == u2_Host.ops_u.dem ) { // Start raw input. // { @@ -220,35 +217,30 @@ u2_term_io_init() c3_assert(!"init-fcntl"); } } -#endif } } /* u2_term_io_exit(): clean up terminal. */ -void +void u2_term_io_exit(void) { -#if 0 - u2_utty* uty_u = u2_Host.uty_u; - - // Turn off raw mode. - // - uv_tty_set_mode(&uty_u->wax_u, 0); - -#else - u2_utty* uty_u; - - for ( uty_u = u2_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { - if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->bak_u) ) { - c3_assert(!"exit-tcsetattr"); - } - if ( -1 == fcntl(uty_u->fid_i, F_SETFL, uty_u->cug_i) ) { - c3_assert(!"exit-fcntl"); - } - write(uty_u->fid_i, "\r\n", 2); + if ( u2_yes == u2_Host.ops_u.dem ) { + uv_close((uv_handle_t*)&u2_Host.uty_u->pop_u, NULL); + } + else { + u2_utty* uty_u; + + for ( uty_u = u2_Host.uty_u; uty_u; uty_u = uty_u->nex_u ) { + if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->bak_u) ) { + c3_assert(!"exit-tcsetattr"); + } + if ( -1 == fcntl(uty_u->fid_i, F_SETFL, uty_u->cug_i) ) { + c3_assert(!"exit-fcntl"); + } + write(uty_u->fid_i, "\r\n", 2); + } } -#endif } void @@ -285,7 +277,7 @@ _term_it_buf(c3_w len_w, const c3_y* hun_y) buf_u->len_w = len_w; memcpy(buf_u->hun_y, hun_y, len_w); - + buf_u->nex_u = 0; return buf_u; } @@ -321,9 +313,9 @@ _term_it_write_buf(u2_utty* uty_u, uv_buf_t buf_u) ruq_u->buf_y = (c3_y*)buf_u.base; - if ( 0 != uv_write(&ruq_u->wri_u, + if ( 0 != uv_write(&ruq_u->wri_u, (uv_stream_t*)&(uty_u->wax_u), - &buf_u, 1, + &buf_u, 1, _term_write_cb) ) { uL(fprintf(uH, "terminal: %s\n", uv_strerror(uv_last_error(u2L)))); @@ -425,7 +417,7 @@ _term_it_show_wide(u2_utty* uty_u, c3_w len_w, c3_w* txt_w) static void _term_it_show_clear(u2_utty* uty_u) { - u2_utat* tat_u = &uty_u->tat_u; + u2_utat* tat_u = &uty_u->tat_u; if ( tat_u->siz.col_l ) { c3_w ful_w = tat_u->mir.cus_w / tat_u->siz.col_l; @@ -472,12 +464,22 @@ _term_it_show_cursor(u2_utty* uty_u, c3_w cur_w) uty_u->tat_u.mir.cus_w = cur_w; } -/* _term_it_show_line(): set current line, transferring pointer. +/* _term_it_show_line(): set current line */ static void -_term_it_show_line(u2_utty* uty_u, c3_w len_w, c3_w* lin_w) +_term_it_show_line(u2_utty* uty_u, u2_noun lin) { - _term_it_show_clear(uty_u); + c3_w len_w = u2_ckb_lent(u2k(lin)); + c3_w* lin_w = malloc(4 * len_w); + + { + c3_w i_w; + + for ( i_w = 0; u2_nul != lin; i_w++, lin = u2t(lin) ) { + lin_w[i_w] = u2_cr_word(0, u2h(lin)); + } + } + _term_it_show_wide(uty_u, len_w, lin_w); if ( lin_w != uty_u->tat_u.mir.lin_w ) { @@ -503,7 +505,11 @@ _term_it_refresh_line(u2_utty* uty_u) static void _term_it_show_more(u2_utty* uty_u) { - _term_it_write_str(uty_u, "\r\n"); + if ( u2_yes == u2_Host.ops_u.dem ) { + _term_it_write_str(uty_u, "\n"); + } else { + _term_it_write_str(uty_u, "\r\n"); + } uty_u->tat_u.mir.cus_w = 0; } @@ -583,7 +589,7 @@ _term_io_belt(u2_utty* uty_u, u2_noun blb) */ static void _term_io_suck_char(u2_utty* uty_u, c3_y cay_y) -{ +{ u2_utat* tat_u = &uty_u->tat_u; // uL(fprintf(uH, "suck-char %x\n", cay_y)); @@ -612,7 +618,7 @@ _term_io_suck_char(u2_utty* uty_u, c3_y cay_y) } else { tat_u->esc.ape = u2_no; - + _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); } } @@ -670,11 +676,51 @@ _term_io_suck_char(u2_utty* uty_u, c3_y cay_y) static void _term_ef_poll(u2_utty* uty_u) { - c3_i evt_i = UV_READABLE | ((0 == uty_u->out_u) ? 0 : UV_WRITABLE); + if ( u2_no == u2_Host.ops_u.dem ) { + c3_i evt_i = ( ((u2_yes == u2_Host.ops_u.dem) ? 0 : UV_READABLE) + | ((0 == uty_u->out_u) ? 0 : UV_WRITABLE)); - // fprintf(stderr, "ef_poll out_u %p\r\n", uty_u->out_u); + // fprintf(stderr, "ef_poll out_u %p\r\n", uty_u->out_u); - uv_poll_start(&(uty_u->wax_u), evt_i, _term_poll_cb); + uv_poll_start(&(uty_u->wax_u), evt_i, _term_poll_cb); + } +} + +/* _term_it_do_writes(): +*/ +static void +_term_it_do_writes(u2_utty* uty_u) +{ + while ( uty_u->out_u ) { + u2_ubuf* out_u = uty_u->out_u; + c3_i siz_i; + + if ( (siz_i = write(uty_u->fid_i, + uty_u->out_u->hun_y, + uty_u->out_u->len_w)) < 0 ) { +#if 0 + if ( EAGAIN == errno ) { + break; + } else { + c3_assert(!"term: write"); + } +#else + break; +#endif + } + if ( siz_i < out_u->len_w ) { + _term_it_clip(out_u, siz_i); + break; + } + else { + uty_u->out_u = uty_u->out_u->nex_u; + if ( 0 == uty_u->out_u ) { + c3_assert(out_u == uty_u->tou_u); + uty_u->tou_u = 0; + } + free(out_u); + } + } } /* _term_poll_cb(): polling with old libev code. @@ -685,7 +731,7 @@ _term_poll_cb(uv_poll_t* pol_u, c3_i sas_i, c3_i evt_i) u2_utty* uty_u = (void*)pol_u; #if 0 - fprintf(stderr, "poll_cb read %d, write %d\r\n", + fprintf(stderr, "poll_cb read %d, write %d\r\n", !!(UV_READABLE & evt_i), !!(UV_WRITABLE & evt_i)); #endif @@ -716,36 +762,7 @@ _term_poll_cb(uv_poll_t* pol_u, c3_i sas_i, c3_i evt_i) } } if ( UV_WRITABLE & evt_i ) { - while ( uty_u->out_u ) { - u2_ubuf* out_u = uty_u->out_u; - c3_i siz_i; - - if ( (siz_i = write(uty_u->fid_i, - uty_u->out_u->hun_y, - uty_u->out_u->len_w)) < 0 ) { -#if 0 - if ( EAGAIN == errno ) { - break; - } else { - c3_assert(!"term: write"); - } -#else - break; -#endif - } - if ( siz_i < out_u->len_w ) { - _term_it_clip(out_u, siz_i); - break; - } - else { - uty_u->out_u = uty_u->out_u->nex_u; - if ( 0 == uty_u->out_u ) { - c3_assert(out_u == uty_u->tou_u); - uty_u->tou_u = 0; - } - free(out_u); - } - } + _term_it_do_writes(uty_u); } u2_lo_shut(u2_yes); } @@ -756,7 +773,7 @@ _term_poll_cb(uv_poll_t* pol_u, c3_i sas_i, c3_i evt_i) /* _term_read_cb(): server read callback. */ static void -_term_read_cb(uv_stream_t* str_u, +_term_read_cb(uv_stream_t* str_u, ssize_t siz_i, uv_buf_t buf_u) { @@ -833,7 +850,7 @@ u2_term_get_blew(c3_l tid_l) #else { c3_i col_i, row_i; - + uv_tty_get_winsize(&uty_u->wax_u, &col_i, &row_i); col_l = col_i; row_l = row_i; @@ -862,7 +879,7 @@ u2_term_ef_boil(c3_l old_l, u2_noun tin = u2_dc("scot", c3__ud, tid_l); u2_noun pax = u2nc(c3__gold, u2nq(c3__term, u2k(oan), tin, u2_nul)); u2_noun hud = u2nc(c3__wipe, u2_nul); - + u2_reck_plan(u2A, pax, hud); } u2z(oan); @@ -883,7 +900,7 @@ u2_term_ef_boil(c3_l old_l, /* u2_term_ef_winc(): window change. Just console right now. */ void -u2_term_ef_winc(void) +u2_term_ef_winc(void) { u2_noun pax = u2nq(c3__gold, c3__term, '1', u2_nul); @@ -893,7 +910,7 @@ u2_term_ef_winc(void) /* u2_term_ef_ctlc(): send ^C on console. */ void -u2_term_ef_ctlc(void) +u2_term_ef_ctlc(void) { u2_noun pax = u2nq(c3__gold, c3__term, '1', u2_nul); @@ -912,7 +929,7 @@ u2_term_ef_boil(c3_l ono_l) u2_noun tin = u2_dc("scot", c3__ud, tid_l); u2_noun pax = u2nq(c3__gold, c3__term, tin, u2_nul); u2_noun hud = u2nc(c3__wipe, u2_nul); - + u2_reck_plan(u2A, pax, hud); } } @@ -968,39 +985,47 @@ _term_ef_blit(u2_utty* uty_u, switch ( u2h(blt) ) { default: break; case c3__bel: { - _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); - } break; + if ( u2_no == u2_Host.ops_u.dem ) { + _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); + } + } break; case c3__clr: { - _term_it_show_blank(uty_u); - _term_it_refresh_line(uty_u); + if ( u2_no == u2_Host.ops_u.dem ) { + _term_it_show_blank(uty_u); + _term_it_refresh_line(uty_u); + } } break; case c3__hop: { - _term_it_show_cursor(uty_u, u2t(blt)); + if ( u2_no == u2_Host.ops_u.dem ) { + _term_it_show_cursor(uty_u, u2t(blt)); + } } break; case c3__lin: { u2_noun lin = u2t(blt); - c3_w len_w = u2_ckb_lent(u2k(lin)); - c3_w* lin_w = malloc(4 * len_w); - - { - c3_w i_w; - - for ( i_w = 0; u2_nul != lin; i_w++, lin = u2t(lin) ) { - lin_w[i_w] = u2_cr_word(0, u2h(lin)); - } + if ( u2_no == u2_Host.ops_u.dem ) { + _term_it_show_clear(uty_u); + _term_it_show_line(uty_u, lin); + } else { + uty_u->lin = u2k(lin); } - _term_it_show_line(uty_u, len_w, lin_w); } break; case c3__mor: { - _term_it_show_more(uty_u); + if ( u2_no == u2_Host.ops_u.dem ) { + _term_it_show_more(uty_u); + } else { + _term_it_show_line(uty_u, uty_u->lin); + uty_u->lin = u2_nul; + _term_it_show_more(uty_u); + _term_it_do_writes(uty_u); + } } break; case c3__sav: { - _term_it_save(u2k(u2h(u2t(blt))), u2k(u2t(u2t(blt)))); + _term_it_save(u2k(u2h(u2t(blt))), u2k(u2t(u2t(blt)))); } break; } u2z(blt); @@ -1033,7 +1058,7 @@ u2_term_ef_blit(c3_l tid_l, u2z(bls); } _term_ef_poll(uty_u); -} +} /* u2_term_io_hija(): hijack console for fprintf, returning FILE*. */ @@ -1047,28 +1072,26 @@ u2_term_io_hija(void) // We *should* in fact, produce some kind of fake FILE* for // non-console terminals. If we use this interface enough... // - c3_assert(0); + c3_assert(0); } else { -#if 0 - uv_tty_set_mode(&uty_u->wax_u, 0); -#else - if ( 0 != tcsetattr(1, TCSADRAIN, &uty_u->bak_u) ) { - c3_assert(!"hija-tcsetattr"); + if ( u2_no == u2_Host.ops_u.dem ) { + if ( 0 != tcsetattr(1, TCSADRAIN, &uty_u->bak_u) ) { + c3_assert(!"hija-tcsetattr"); + } + if ( -1 == fcntl(1, F_SETFL, uty_u->cug_i) ) { + c3_assert(!"hija-fcntl"); + } + if ( 0 != tcsetattr(0, TCSADRAIN, &uty_u->bak_u) ) { + c3_assert(!"hija-tcsetattr"); + } + if ( -1 == fcntl(0, F_SETFL, uty_u->cug_i) ) { + c3_assert(!"hija-fcntl"); + } + write(uty_u->fid_i, "\r", 1); + write(uty_u->fid_i, uty_u->ufo_u.out.el_y, + strlen((c3_c*) uty_u->ufo_u.out.el_y)); } - if ( -1 == fcntl(1, F_SETFL, uty_u->cug_i) ) { - c3_assert(!"hija-fcntl"); - } - if ( 0 != tcsetattr(0, TCSADRAIN, &uty_u->bak_u) ) { - c3_assert(!"hija-tcsetattr"); - } - if ( -1 == fcntl(0, F_SETFL, uty_u->cug_i) ) { - c3_assert(!"hija-fcntl"); - } -#endif - write(uty_u->fid_i, "\r", 1); - write(uty_u->fid_i, uty_u->ufo_u.out.el_y, - strlen((c3_c*) uty_u->ufo_u.out.el_y)); return stdout; } } @@ -1087,26 +1110,27 @@ u2_term_io_loja(int x) // We *should* in fact, produce some kind of fake FILE* for // non-console terminals. If we use this interface enough... // - c3_assert(0); + c3_assert(0); } else { -#if 0 - uv_tty_set_mode(&uty_u->wax_u, 1); -#else - if ( 0 != tcsetattr(1, TCSADRAIN, &uty_u->raw_u) ) { - c3_assert(!"loja-tcsetattr"); + if ( u2_yes == u2_Host.ops_u.dem ) { + fflush(stdout); } - if ( -1 == fcntl(1, F_SETFL, uty_u->nob_i) ) { - c3_assert(!"loja-fcntl"); + else { + if ( 0 != tcsetattr(1, TCSADRAIN, &uty_u->raw_u) ) { + c3_assert(!"loja-tcsetattr"); + } + if ( -1 == fcntl(1, F_SETFL, uty_u->nob_i) ) { + c3_assert(!"loja-fcntl"); + } + if ( 0 != tcsetattr(0, TCSADRAIN, &uty_u->raw_u) ) { + c3_assert(!"loja-tcsetattr"); + } + if ( -1 == fcntl(0, F_SETFL, uty_u->nob_i) ) { + c3_assert(!"loja-fcntl"); + } + _term_it_refresh_line(uty_u); } - if ( 0 != tcsetattr(0, TCSADRAIN, &uty_u->raw_u) ) { - c3_assert(!"loja-tcsetattr"); - } - if ( -1 == fcntl(0, F_SETFL, uty_u->nob_i) ) { - c3_assert(!"loja-fcntl"); - } -#endif - _term_it_refresh_line(uty_u); } } } diff --git a/v/time.c b/v/time.c index 72a16bafd..38f1ffd56 100644 --- a/v/time.c +++ b/v/time.c @@ -21,7 +21,7 @@ #include "f/coal.h" #include "v/vere.h" -/* u2_time_sec_in(): urbit seconds from unix time. +/* u2_time_sec_in(): urbit seconds from unix time. ** ** Adjust for future leap secs! */ @@ -31,7 +31,7 @@ u2_time_sec_in(c3_w unx_w) return 0x8000000cce9e0d80ULL + (c3_d)unx_w; } -/* u2_time_sec_out(): unix time from urbit seconds. +/* u2_time_sec_out(): unix time from urbit seconds. ** ** Adjust for future leap secs! */ @@ -39,7 +39,7 @@ c3_w u2_time_sec_out(c3_d urs_d) { c3_d adj_d = (urs_d - 0x8000000cce9e0d80ULL); - + if ( adj_d > 0xffffffffULL ) { fprintf(stderr, "Agh! It's 2106! And no one's fixed this shite!\n"); exit(1); @@ -52,8 +52,8 @@ u2_time_sec_out(c3_d urs_d) c3_d u2_time_fsc_in(c3_w usc_w) { - c3_d usc_d = usc_w; - + c3_d usc_d = usc_w; + return ((usc_d * 65536ULL) / 1000000ULL) << 48ULL; } @@ -151,11 +151,11 @@ u2_time_gap_ms(u2_noun now, u2_noun wen) if ( u2_no == u2_cka_gth(u2k(wen), u2k(now)) ) { u2z(wen); u2z(now); return 0ULL; - } + } else { u2_noun dif = u2_cka_sub(wen, now); - c3_d fsc_d = u2_cr_chub(0, dif); - c3_d sec_d = u2_cr_chub(1, dif); + c3_d fsc_d = u2_cr_chub(0, dif); + c3_d sec_d = u2_cr_chub(1, dif); u2z(dif); return (sec_d * 1000ULL) + u2_time_msc_out(fsc_d); diff --git a/v/unix.c b/v/unix.c index 843b0e14d..80be91dcb 100644 --- a/v/unix.c +++ b/v/unix.c @@ -94,7 +94,7 @@ u2_unix_acquire(c3_c* pax_c) c3_w i_w; if ( -1 != kill(pid_w, SIGTERM) ) { - uL(fprintf(uH, "unix: stopping process %d, live in %s...\n", + uL(fprintf(uH, "unix: stopping process %d, live in %s...\n", pid_w, pax_c)); for ( i_w = 0; i_w < 16; i_w++ ) { @@ -130,7 +130,7 @@ u2_unix_acquire(c3_c* pax_c) #if defined(U2_OS_linux) fdatasync(fid_i); #elif defined(U2_OS_osx) - fcntl(fid_i, F_FULLFSYNC); + fcntl(fid_i, F_FULLFSYNC); #elif defined(U2_OS_bsd) fsync(fid_i); #else @@ -191,8 +191,8 @@ _unix_fs_event_cb(uv_fs_event_t* was_u, /* _unix_file_watch(): create file tracker (from filesystem) */ static void -_unix_file_watch(u2_ufil* fil_u, - u2_udir* dir_u, +_unix_file_watch(u2_ufil* fil_u, + u2_udir* dir_u, c3_c* pax_c, mpz_t mod_mp) { @@ -220,7 +220,7 @@ _unix_file_watch(u2_ufil* fil_u, /* _unix_file_form(): form a filename path downward. */ static c3_c* -_unix_file_form(u2_udir* dir_u, +_unix_file_form(u2_udir* dir_u, u2_noun pre, u2_bean ket, u2_noun ext) @@ -272,7 +272,7 @@ _unix_dir_forge(u2_udir* dir_u, u2_udir* par_u, u2_noun tet) { dir_u->yes = u2_yes; dir_u->dry = u2_no; - { + { c3_c* tet_c = u2_cr_string(tet); c3_w pax_w = strlen(par_u->pax_c); c3_w tet_w = strlen(tet_c); @@ -401,7 +401,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) { if ( u2_yes == dir_u->dry ) { return; - } + } else { // Update all wet subdirectories. // @@ -442,7 +442,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) else { struct stat buf_u; - if ( -1 == stat((*fil_u)->pax_c, &buf_u) || + if ( -1 == stat((*fil_u)->pax_c, &buf_u) || !(S_IFREG & buf_u.st_mode) ) { u2_ufil* ded_u = *fil_u; @@ -468,7 +468,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) if ( readdir_r(rid_u, &ent_u, &out_u) != 0 ) { // uL(fprintf(uH, "%s: %s\n", dir_u->pax_c, strerror(errno))); c3_assert(0); - } + } else if ( !out_u ) { break; } @@ -478,12 +478,12 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) else { c3_c* pax_c = _unix_down(dir_u->pax_c, out_u->d_name); struct stat buf_u; - + // uL(fprintf(uH, " in %s\n", pax_c)); if ( 0 != stat(pax_c, &buf_u) ) { free(pax_c); continue; - } + } else { if ( !S_ISDIR(buf_u.st_mode) ) { mpz_t mod_mp; @@ -524,7 +524,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u) dis_u = malloc(sizeof(u2_udir)); // uL(fprintf(uH, "found directory %s\n", pax_c)); - _unix_dir_watch(dis_u, dir_u, pax_c); + _unix_dir_watch(dis_u, dir_u, pax_c); _unix_dir_update(dis_u, red_u); dis_u->nex_u = dir_u->dis_u; @@ -553,7 +553,7 @@ _unix_load(c3_c* pax_c) if ( (fid_i < 0) || (fstat(fid_i, &buf_u) < 0) ) { uL(fprintf(uH, "%s: %s\n", pax_c, strerror(errno))); - c3_assert(0); + c3_assert(0); return 0; } fln_w = buf_u.st_size; @@ -568,7 +568,7 @@ _unix_load(c3_c* pax_c) return 0; } else { - u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); + u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); free(pad_y); return pad; @@ -634,7 +634,7 @@ _unix_dir_name(u2_udir* dir_u) /* _unix_file_name(): file name/extension. */ -static u2_noun +static u2_noun _unix_file_name(u2_ufil* fil_u) { c3_w pel_w = strlen(fil_u->par_u->pax_c); @@ -642,7 +642,7 @@ _unix_file_name(u2_ufil* fil_u) if ( !fil_u->dot_c ) { return u2_ci_string(pax_c); - } + } else { c3_c* ext_c = fil_u->dot_c + 1; @@ -654,7 +654,7 @@ _unix_file_name(u2_ufil* fil_u) /* _unix_dir_ankh(): resolve directory to new style ankh. */ -static u2_noun +static u2_noun _unix_dir_ankh(u2_udir* dir_u) { u2_udir* dis_u; @@ -691,7 +691,7 @@ _unix_dir_ankh(u2_udir* dir_u) ole = elo; } pam = u2_ckd_by_put(pam, wib, ole); - } + } else { u2_noun fid = u2h(wib); u2_noun har = u2t(wib); @@ -700,8 +700,8 @@ _unix_dir_ankh(u2_udir* dir_u) if ( u2_none == ole ) { ole = u2nt - (0, u2_nul, u2_ckd_by_put(u2_nul, - u2k(har), + (0, u2_nul, u2_ckd_by_put(u2_nul, + u2k(har), u2_do("cosh", u2nt(0, woz, u2_nul)))); ole = u2_do("cosh", ole); } @@ -735,9 +735,9 @@ _unix_dir_ankh(u2_udir* dir_u) /* _unix_desk_peek(): peek for ankh. */ static u2_noun -_unix_desk_peek(u2_noun who, - u2_noun hox, - u2_noun syd, +_unix_desk_peek(u2_noun who, + u2_noun hox, + u2_noun syd, u2_noun lok) { u2_noun cay; @@ -758,8 +758,8 @@ _unix_desk_peek(u2_noun who, */ static void _unix_desk_sync_into(u2_noun who, - u2_noun hox, - u2_noun syd, + u2_noun hox, + u2_noun syd, u2_udir* dir_u) { u2_noun xun, bur, doz, fav, pax; @@ -774,7 +774,7 @@ _unix_desk_sync_into(u2_noun who, fav = u2nq(c3__into, who, syd, u2nt(u2_yes, u2_nul, doz)); u2_reck_plan(u2A, pax, fav); - } + } else { u2z(who); u2z(syd); u2z(xun); u2z(bur); } @@ -802,10 +802,10 @@ _unix_ship_update(u2_uhot* hot_u) hox = u2_dc("scot", 'p', u2k(who)); } - for ( dis_u = dir_u->dis_u; dis_u; dis_u = dis_u->nex_u ) { - u2_noun syd = _unix_dir_name(dis_u); + for ( dis_u = dir_u->dis_u; dis_u; dis_u = dis_u->nex_u ) { + u2_noun syd = _unix_dir_name(dis_u); - // uL(fprintf(uH, "sync %s %s\n", u2_cr_string(hox), u2_cr_string(syd))); + // uL(fprintf(uH, "sync %s %s\n", u2_cr_string(hox), u2_cr_string(syd))); _unix_desk_sync_into(u2k(who), u2k(hox), syd, dis_u); } u2z(hox); @@ -873,8 +873,8 @@ _unix_pdir(u2_udir* par_u, u2_noun tet) c3_w tet_w = strlen(tet_c); u2_udir** dir_u; - dir_u = &(par_u->dis_u); - while ( 1 ) { + dir_u = &(par_u->dis_u); + while ( 1 ) { if ( !*dir_u || !strncmp(((*dir_u)->pax_c + pax_w + 1), tet_c, tet_w) ) { free(tet_c); return dir_u; } @@ -892,9 +892,9 @@ _unix_home(u2_noun who) mpz_t who_mp; u2_cr_mp(who_mp, who); - for ( hot_u = unx_u->hot_u; + for ( hot_u = unx_u->hot_u; hot_u && (0 != mpz_cmp(who_mp, hot_u->who_mp)); - hot_u = hot_u->nex_u ) + hot_u = hot_u->nex_u ) { // uL(fprintf(uH, "uh: %p, %s\n", hot_u, hot_u->dir_u.pax_c)); } @@ -924,9 +924,9 @@ _unix_desk_sync_tofu(u2_udir* dir_u, // uL(fprintf(uH, "tofu pox_c %s op %s\n", pox_c, u2_cr_string(u2h(mis)))); - fil_u = &(dir_u->fil_u); + fil_u = &(dir_u->fil_u); while ( 1 ) { // XX crude! - if ( !*fil_u || + if ( !*fil_u || !strcmp((*fil_u)->pax_c, pox_c) || !strcmp((*fil_u)->pax_c, pux_c) ) { @@ -934,7 +934,7 @@ _unix_desk_sync_tofu(u2_udir* dir_u, } else fil_u = &((*fil_u)->nex_u); } - + if ( *fil_u && (c3__del == u2h(mis)) ) { u2_ufil* ded_u = *fil_u; @@ -956,7 +956,7 @@ _unix_desk_sync_tofu(u2_udir* dir_u, god = _unix_desk_sync_udon(u2k(u2t(mis)), old); _unix_unlink((*fil_u)->pax_c); free((*fil_u)->pax_c); - } + } else { c3_assert(c3__ins == u2h(mis)); god = u2k(u2t(mis)); @@ -978,7 +978,7 @@ _unix_desk_sync_tofu(u2_udir* dir_u, mpz_clear((*fil_u)->mod_mp); u2_cr_mp((*fil_u)->mod_mp, u2A->now); - } + } else { mpz_t mod_mp; @@ -1003,14 +1003,14 @@ _unix_desk_sync_tako(u2_udir* dir_u, u2_noun pax, u2_noun mis) u2z(pax); u2z(mis); } else { - u2_noun i_pax = u2h(pax); + u2_noun i_pax = u2h(pax); u2_noun t_pax = u2t(pax); u2_noun it_pax = u2h(t_pax); u2_noun tt_pax = u2t(t_pax); if ( u2_nul == tt_pax ) { _unix_desk_sync_tofu(dir_u, u2k(i_pax), u2k(it_pax), mis); - } + } else { u2_udir** dis_u = _unix_pdir(dir_u, u2k(i_pax)); @@ -1043,10 +1043,10 @@ _unix_desk_sync_soba(u2_udir* dir_u, u2_noun doz) */ static void _unix_desk_sync_ergo(u2_noun who, - u2_noun hox, - u2_noun syd, + u2_noun hox, + u2_noun syd, u2_noun lok, - u2_uhot* hot_u) + u2_uhot* hot_u) { u2_udir** dir_u = _unix_pdir(&(hot_u->dir_u), syd); u2_noun xun; @@ -1088,8 +1088,8 @@ u2_unix_ef_init(u2_noun who) _unix_hot_gain(u2k(who), u2_yes); u2_reck_plan(u2A, u2nq(c3__gold, c3__sync, u2k(u2A->sen), u2_nul), - u2nq(c3__into, who, - u2_blip, + u2nq(c3__into, who, + u2_blip, u2nq(u2_yes, u2_nul, u2nc(0, 0), u2_nul))); } @@ -1119,7 +1119,7 @@ u2_unix_ef_look(void) { u2_unix* unx_u = &u2_Host.unx_u; u2_noun won; - u2_uhot* hot_u; + u2_uhot* hot_u; // find owners without directories { @@ -1128,7 +1128,7 @@ u2_unix_ef_look(void) mpz_t who_mp; u2_cr_mp(who_mp, who); - for ( hot_u = unx_u->hot_u; + for ( hot_u = unx_u->hot_u; hot_u && (0 != mpz_cmp(who_mp, hot_u->who_mp)); hot_u = hot_u->nex_u ); @@ -1159,7 +1159,7 @@ u2_unix_ef_look(void) if ( u2_nul == won ) { *het_u = hot_u->nex_u; - + // uL(fprintf(uH, "sync: lose %s\n", hot_u->dir_u.pax_c)); _unix_hot_lose(hot_u); @@ -1207,9 +1207,9 @@ _unix_sign_cb(uv_signal_t* sil_u, c3_i num_i) switch ( num_i ) { default: fprintf(stderr, "\r\nmysterious signal %d\r\n", num_i); break; - case SIGTERM: + case SIGTERM: fprintf(stderr, "\r\ncaught signal %d\r\n", num_i); - u2_Host.liv = u2_no; + u2_Host.liv = u2_no; break; case SIGINT: u2_term_ef_ctlc(); break; case SIGWINCH: u2_term_ef_winc(); break; @@ -1228,7 +1228,7 @@ u2_unix_ef_hold(void) u2_usig* sig_u; for ( sig_u = unx_u->sig_u; sig_u; sig_u = sig_u->nex_u ) { - uv_signal_stop(&sig_u->sil_u); + uv_signal_stop(&sig_u->sil_u); } } @@ -1241,13 +1241,13 @@ u2_unix_ef_move(void) u2_usig* sig_u; for ( sig_u = unx_u->sig_u; sig_u; sig_u = sig_u->nex_u ) { - uv_signal_start(&sig_u->sil_u, _unix_sign_cb, sig_u->num_i); + uv_signal_start(&sig_u->sil_u, _unix_sign_cb, sig_u->num_i); } } /* u2_unix_io_init(): initialize unix sync. */ -void +void u2_unix_io_init(void) { u2_unix* unx_u = &u2_Host.unx_u; @@ -1303,7 +1303,7 @@ u2_unix_io_init(void) /* u2_unix_io_exit(): terminate unix I/O. */ -void +void u2_unix_io_exit(void) { u2_unix_release(u2_Host.cpu_c); @@ -1324,8 +1324,8 @@ u2_unix_io_poll(void) { u2_unix* unx_u = &u2_Host.unx_u; u2_noun wen = u2_reck_keep(u2A, u2nt(c3__gold, c3__clay, u2_nul)); - - if ( (u2_nul != wen) && + + if ( (u2_nul != wen) && (u2_yes == u2du(wen)) && (u2_yes == u2ud(u2t(wen))) ) { diff --git a/v/walk.c b/v/walk.c index 8e90bdbcb..03814ff77 100644 --- a/v/walk.c +++ b/v/walk.c @@ -21,7 +21,7 @@ #include "all.h" #include "f/coal.h" #include "v/vere.h" - + /* |% ** ++ arch :: fs node ** $% [& p=@uvI q=*] :: file, hash/data @@ -69,7 +69,7 @@ u2_walk_safe(c3_c* pas_c) return 0; } else { - u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); + u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); free(pad_y); return pad; @@ -101,7 +101,7 @@ u2_walk_load(c3_c* pas_c) return u2_cm_bail(c3__fail); } else { - u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); + u2_noun pad = u2_ci_bytes(fln_w, (c3_y *)pad_y); free(pad_y); return pad; @@ -141,7 +141,7 @@ u2_walk_save(c3_c* pas_c, u2_noun tim, u2_atom pad) u2_time_out_tv(&tim_tv[0], u2k(tim)); u2_time_out_tv(&tim_tv[1], tim); - + utimes(pas_c, tim_tv); } } @@ -164,11 +164,11 @@ _walk_in(u2_reck* rec_u, const c3_c* dir_c, c3_w len_w) if ( readdir_r(dir_d, &ent_n, &out_n) != 0 ) { uL(fprintf(uH, "%s: %s\n", dir_c, strerror(errno))); break; - } + } else if ( !out_n ) { break; } - else if ( !strcmp(out_n->d_name, ".") || + else if ( !strcmp(out_n->d_name, ".") || !strcmp(out_n->d_name, "..") || ('~' == out_n->d_name[0]) || ('.' == out_n->d_name[0]) ) // XX restricts some spans @@ -180,7 +180,7 @@ _walk_in(u2_reck* rec_u, const c3_c* dir_c, c3_w len_w) c3_w lef_w = len_w + 1 + strlen(fil_c); c3_c* pat_c = malloc(lef_w + 1); struct stat buf_b; - + strncpy(pat_c, dir_c, lef_w); pat_c[len_w] = '/'; strncpy(pat_c + len_w + 1, fil_c, lef_w); @@ -209,7 +209,7 @@ _walk_in(u2_reck* rec_u, const c3_c* dir_c, c3_w len_w) } hax = u2_do("sham", u2k(dat)); if ( u2_none == get ) { get = u2_nul; } - + get = u2_ckd_by_put(get, ext, u2nt(u2_yes, hax, dat)); map = u2_ckd_by_put(map, nam, u2nc(u2_no, get)); } @@ -249,13 +249,13 @@ u2_walk(u2_reck* rec_u, const c3_c* dir_c, u2_noun old) c3_assert(0); } else { - return u2nc(u2_no, + return u2nc(u2_no, _walk_in(rec_u, dir_c, strlen(dir_c))); } } } -/* u2_path(): C unix path in computer for file or directory. +/* u2_path(): C unix path in computer for file or directory. */ c3_c* u2_path(u2_bean fyl, u2_noun pax)