urbit/gen164/6/fitz.c

72 lines
1.5 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/fitz.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* functions
*/
static u2_bean
2014-08-21 01:18:34 +04:00
_fitz_fiz(
u2_noun yaz,
2013-09-29 00:21:18 +04:00
u2_noun wix)
{
2014-08-21 01:18:34 +04:00
c3_w yaz_w = u2_cr_met(3, yaz);
c3_w wix_w = u2_cr_met(3, wix);
2013-09-29 00:21:18 +04:00
c3_y yaz_y, wix_y;
2014-08-21 01:18:34 +04:00
yaz_y = (0 == yaz_w) ? 0 : u2_cr_byte((yaz_w - 1), yaz);
2013-09-29 00:21:18 +04:00
if ( (yaz_y < 'A') || (yaz_y > 'Z') ) yaz_y = 0;
2014-08-21 01:18:34 +04:00
wix_y = (0 == wix_w) ? 0 : u2_cr_byte((wix_w - 1), wix);
2013-09-29 00:21:18 +04:00
if ( (wix_y < 'A') || (wix_y > 'Z') ) wix_y = 0;
if ( yaz_y && wix_y ) {
if ( !wix_y || (wix_y > yaz_y) ) {
return u2_no;
}
}
return u2_yes;
}
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 07:36:29 +04:00
u2_cqf_fitz(
2014-09-04 01:33:18 +04:00
u2_noun yaz,
u2_noun wix)
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
c3_w i_w, met_w = c3_min(u2_cr_met(3, yaz), u2_cr_met(3, wix));
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
if ( u2_no == _fitz_fiz(yaz, wix) ) {
2013-09-29 00:21:18 +04:00
return u2_no;
}
for ( i_w = 0; i_w < met_w; i_w++ ) {
2014-08-21 01:18:34 +04:00
c3_y yaz_y = u2_cr_byte(i_w, yaz);
c3_y wix_y = u2_cr_byte(i_w, wix);
2013-09-29 00:21:18 +04:00
if ( (yaz_y >= 'A') && (yaz_y <= 'Z') ) yaz_y = 0;
if ( (wix_y >= 'A') && (wix_y <= 'Z') ) wix_y = 0;
if ( yaz_y && wix_y && (yaz_y != wix_y) ) {
return u2_no;
}
}
return u2_yes;
}
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 09:46:55 +04:00
u2_cwf_fitz(
2014-09-04 01:33:18 +04:00
u2_noun cor)
2013-09-29 00:21:18 +04:00
{
u2_noun yaz, wix;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &yaz, u2_cv_sam_3, &wix, 0)) ||
2013-09-29 00:21:18 +04:00
(u2_no == u2ud(yaz)) ||
(u2_no == u2ud(wix)) )
{
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 07:36:29 +04:00
return u2_cqf_fitz(yaz, wix);
2013-09-29 00:21:18 +04:00
}
}