simplifies dawn status noun, improves error messages

This commit is contained in:
Joe Bryan 2018-10-12 13:45:20 -04:00
parent 4b6c697814
commit f939b63cca
2 changed files with 44 additions and 3 deletions

View File

@ -354,9 +354,11 @@
# define c3__dxkt c3_s4('d','x','k','t')
# define c3__dub c3_s3('d','u','b')
# define c3__duct c3_s4('d','u','c','t')
# define c3__duke c3_s4('d','u','k','e')
# define c3__dumb c3_s4('d','u','m','b')
# define c3__dump c3_s4('d','u','m','p')
# define c3__dust c3_s4('d','u','s','t')
# define c3__earl c3_s4('e','a','r','l')
# define c3__east c3_s4('e','a','s','t')
# define c3__echo c3_s4('e','c','h','o')
# define c3__edge c3_s4('e','d','g','e')
@ -586,6 +588,7 @@
# define c3__kern c3_s4('k','e','r','n')
# define c3__kgo c3_s3('k','g','o')
# define c3__kick c3_s4('k','i','c','k')
# define c3__king c3_s4('k','i','n','g')
# define c3__kit c3_s3('k','i','t')
# define c3__knit c3_s4('k','n','i','t')
# define c3__kno c3_s3('k','n','o')
@ -803,6 +806,7 @@
# define c3__part c3_s4('p','a','r','t')
# define c3__pass c3_s4('p','a','s','s')
# define c3__past c3_s4('p','a','s','t')
# define c3__pawn c3_s4('p','a','w','n')
# define c3__peek c3_s4('p','e','e','k')
# define c3__peep c3_s4('p','e','e','p')
# define c3__peft c3_s4('p','e','f','t')

View File

@ -1287,6 +1287,8 @@ _sist_dawn(u3_noun des)
c3_c* how_c = u3r_string(u3k(how));
fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n",
u3_Host.ops_u.who_c, how_c);
u3z(how);
free(how_c);
u3_lo_bail();
}
@ -1306,19 +1308,54 @@ _sist_dawn(u3_noun des)
// u3_noun liv = _sist_get_json(parent, /some/url)
u3_noun liv = u3_nul;
// XX revisit
// (each [seed (unit ship)] [rank @tas])
// (each sponsor=(unit ship) error=@tas)
u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv));
if ( c3n == u3h(sas) ) {
u3_noun rac = u3do("clan:title", u3k(who));
u3_noun how = u3dc("scot", 'p', u3k(who));
c3_c* how_c = u3r_string(u3k(how));
c3_c* rac_c;
switch (rac) {
default: c3_assert(0);
case c3__czar: {
rac_c = "galaxy";
break;
}
case c3__king: {
rac_c = "star";
break;
}
case c3__duke: {
rac_c = "planet";
break;
}
case c3__earl: {
rac_c = "moon";
break;
}
case c3__pawn: {
rac_c = "comet";
break;
}
}
fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c);
// XX deconstruct sas, print helpful error messages
u3m_p("pre-boot error", u3t(sas));
u3z(rac);
u3z(how);
free(how_c);
u3_lo_bail();
}
// (unit ship): sponsor
// produced by +veri:dawn to avoid coupling to +hull structure
pon = u3k(u3t(u3t(sas)));
pon = u3k(u3t(sas));
u3z(oct); u3z(luh); u3z(hul); u3z(liv); u3z(sas);
}