urbit/j/6/slot.c

56 lines
1.1 KiB
C
Raw Normal View History

2014-05-31 00:57:49 +04:00
/* j/6/slot.c
**
** This file is in the public domain.
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
2014-05-31 00:57:49 +04:00
/* functions
*/
2014-09-06 00:13:24 +04:00
u3_noun
u3_cqf_slot(u3_atom axe, u3_noun vax)
2014-05-31 00:57:49 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun fag = u3_cr_at(axe, u3t(vax));
2014-05-31 00:57:49 +04:00
fprintf(stderr, "slot axe %d\r\n", axe);
2014-09-06 00:13:24 +04:00
if ( u3_none == fag ) {
return u3_cm_bail(c3__exit);
2014-05-31 00:57:49 +04:00
}
else {
2014-09-06 00:13:24 +04:00
u3_noun typ = u3_cqfu_peek(
2014-05-31 00:57:49 +04:00
}
2014-09-06 00:13:24 +04:00
c3_w i_w, met_w = c3_min(u3_cr_met(3, axe), u3_cr_met(3, vax));
2014-05-31 00:57:49 +04:00
2014-09-06 00:13:24 +04:00
if ( u3_no == _slot_fiz(axe, vax) ) {
return u3_no;
2014-05-31 00:57:49 +04:00
}
for ( i_w = 0; i_w < met_w; i_w++ ) {
2014-09-06 00:13:24 +04:00
c3_y axe_y = u3_cr_byte(i_w, axe);
c3_y vax_y = u3_cr_byte(i_w, vax);
2014-05-31 00:57:49 +04:00
if ( (axe_y >= 'A') && (axe_y <= 'Z') ) axe_y = 0;
if ( (vax_y >= 'A') && (vax_y <= 'Z') ) vax_y = 0;
if ( axe_y && vax_y && (axe_y != vax_y) ) {
2014-09-06 00:13:24 +04:00
return u3_no;
2014-05-31 00:57:49 +04:00
}
}
2014-09-06 00:13:24 +04:00
return u3_yes;
2014-05-31 00:57:49 +04:00
}
2014-09-06 00:13:24 +04:00
u3_noun
u3_cwe_slot(u3_noun cor)
2014-05-31 00:57:49 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun axe, vax;
2014-05-31 00:57:49 +04:00
2014-09-06 00:13:24 +04:00
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &axe, u3_cv_sam_3, &vax, 0)) ||
(u3_no == u3ud(axe)) ||
(u3_no == u3du(vax)) )
2014-05-31 00:57:49 +04:00
{
2014-09-06 00:13:24 +04:00
return u3_cm_bail(c3__fail);
2014-05-31 00:57:49 +04:00
} else {
2014-09-06 00:13:24 +04:00
return u3_cqf_slot(axe, vax);
2014-05-31 00:57:49 +04:00
}
}