shrub/gen164/6/ut_tock.c

105 lines
2.5 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/tock.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* internals
*/
2014-09-04 01:33:18 +04:00
static u2_noun
2014-08-21 01:18:34 +04:00
_tock_in(
2014-09-04 01:33:18 +04:00
u2_noun van,
u2_noun sut,
u2_noun peh,
u2_noun mur,
u2_noun men)
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
if ( u2_no == u2du(men) ) {
return u2nc(u2_nul, u2_nul);
}
2013-09-29 00:21:18 +04:00
else {
2014-08-21 01:18:34 +04:00
u2_noun i_men = u2h(men);
u2_noun pi_men = u2h(i_men);
u2_noun qi_men = u2t(i_men);
u2_noun t_men = u2t(men);
2014-09-03 07:36:29 +04:00
u2_noun geq = u2_cqfu_tack(van, pi_men, peh, mur);
2014-08-21 01:18:34 +04:00
u2_noun p_geq = u2h(geq);
u2_noun q_geq = u2t(geq);
u2_noun mox = _tock_in(van, sut, peh, mur, t_men);
u2_noun p_mox = u2h(mox);
u2_noun q_mox = u2t(mox);
2013-09-29 00:21:18 +04:00
u2_noun ret;
2014-08-21 01:18:34 +04:00
ret = u2nc(
( (u2_nul == p_mox)
2014-08-21 01:18:34 +04:00
? u2nc(u2_nul, u2k(p_geq))
: (u2_no == u2_cr_sing(p_geq, u2t(p_mox)))
? u2_cm_bail(c3__exit)
: u2k(p_mox) ),
u2nc(u2nc(u2k(q_geq),
u2k(qi_men)),
u2k(q_mox)));
u2z(mox);
u2z(geq);
2013-09-29 00:21:18 +04:00
return ret;
}
}
2013-09-29 00:21:18 +04:00
/* functions
*/
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 09:46:55 +04:00
_cqfu_tock(
2014-09-04 01:33:18 +04:00
u2_noun van,
u2_noun sut,
u2_noun peh,
u2_noun mur,
u2_noun men)
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
u2_noun wib = _tock_in(van, sut, peh, mur, men);
u2_noun p_wib = u2h(wib);
u2_noun q_wib = u2t(wib);
2013-09-29 00:21:18 +04:00
if ( u2_nul == p_wib ) {
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__exit);
2013-09-29 00:21:18 +04:00
} else {
2014-08-21 01:18:34 +04:00
u2_noun ret = u2nc(u2k(u2t(p_wib)),
u2k(q_wib));
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
u2z(wib);
2013-09-29 00:21:18 +04:00
return ret;
}
}
/* boilerplate
*/
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 09:46:55 +04:00
u2_cwfu_tock(
2014-09-04 01:33:18 +04:00
u2_noun cor)
2013-09-29 00:21:18 +04:00
{
u2_noun van, sut, peh, mur, men;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &peh,
2013-09-29 00:21:18 +04:00
u2_cv_sam_6, &mur,
u2_cv_sam_7, &men,
u2_cv_con, &van,
2013-09-29 00:21:18 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-09-03 09:46:55 +04:00
return _cqfu_tock(van, sut, peh, mur, men);
2013-09-29 00:21:18 +04:00
}
}
2014-09-04 01:33:18 +04:00
u2_noun
u2_cqfu_tock(u2_noun van,
u2_noun sut,
u2_noun peh,
u2_noun mur,
u2_noun men)
2013-09-29 00:21:18 +04:00
{
2014-09-03 09:46:55 +04:00
return _cqfu_tock(van, sut, peh, mur, men);
2013-09-29 00:21:18 +04:00
}