shrub/j/5/lore.c

60 lines
1.1 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/5/lore.c
**
** This file is in the public domain.
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
u3_noun
u3_cqe_lore(u3_atom lub)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
c3_w len_w = u3_cr_met(3, lub);
2013-09-29 00:21:18 +04:00
c3_w pos_w = 0;
2014-09-06 00:13:24 +04:00
u3_noun tez = u3_nul;
2013-09-29 00:21:18 +04:00
while ( 1 ) {
c3_w meg_w;
if ( pos_w >= len_w ) {
2014-09-06 00:13:24 +04:00
return u3_ckb_flop(tez);
2013-09-29 00:21:18 +04:00
} else {
meg_w = 0;
2014-05-29 00:19:49 +04:00
c3_y byt_y;
2013-09-29 00:21:18 +04:00
while ( 1 ) {
2014-09-06 00:13:24 +04:00
byt_y = u3_cr_byte(pos_w + meg_w, lub);
2013-09-29 00:21:18 +04:00
if ( (10 == byt_y) || (0 == byt_y) ) {
break;
} else meg_w++;
}
2014-05-29 00:19:49 +04:00
if ((byt_y == 0) && ((pos_w + meg_w + 1) < len_w)) {
2014-09-06 00:13:24 +04:00
return u3_cm_bail(c3__exit);
2014-05-29 00:19:49 +04:00
}
2013-09-29 00:21:18 +04:00
{
2014-05-29 00:19:49 +04:00
c3_y* byts_y = alloca(meg_w);
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
u3_cr_bytes(pos_w, meg_w, byts_y, lub);
tez = u3nc(u3_ci_bytes(meg_w, byts_y), tez);
2013-09-29 00:21:18 +04:00
pos_w += (meg_w + 1);
}
}
}
}
2014-09-06 00:13:24 +04:00
u3_noun
u3_cwe_lore(u3_noun cor)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun lub;
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
if ( (u3_none == (lub = u3_cr_at(u3_cv_sam, cor))) ||
(u3_no == u3ud(lub)) )
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
return u3_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-09-06 00:13:24 +04:00
return u3_cqe_lore(lub);
2013-09-29 00:21:18 +04:00
}
}