int ps_word(ParseState *ps) {
const char *space;
- if (!ps->remain) return -1;
+ if (!ps->remain) { ps->lthisword=0; return -1; }
space= strchr(ps->remain, ' ');
ps->thisword= ps->remain;
if (space) {
const void *any_needword_lookup(ParseState *ps, const void *infs, int ninfsmax,
size_t sz, const char *what) {
+ int ec;
const void *r;
- if (!ps_needword(ps)) return 0;
+
+ ec= ps_needword(ps); if (ec) return 0;
r= any_lookup(ps,infs,ninfsmax,sz);
if (!r) {
badcmd(ps,"unknown %s %.*s",what, ps->lthisword,ps->thisword);
static const CmdInfo *ci;
int vbadcmd(ParseState *ps, const char *fmt, va_list al) {
- oprintf(UPO,"ack %s BadCmd : ", ci->name);
+ oprintf(UPO,"ack %s BadCmd : ", ci?ci->name:"?");
ovprintf(UPO,fmt,al);
+ oprintf(UPO,"\n");
return EC_BadCmd;
}
static void command_doline(ParseState *ps, CommandInput *cmdi_arg) {
int r;
-
+
+ ci= 0;
ci= some_needword_lookup(ps, toplevel_cmds, "command");
+ if (!ci) return;
+ oprintf(UPO, "executing %s\n", ci->name);
r= ci->fn(ps,ci);
switch (r) {
case 0: oprintf(UPO, "ack %s ok\n", ci->name); break;
u.usecurrentposn= 1;
u.fdetc.getmovpos= pred_getmovpos;
- u.tailc.getmovpos= pred_getmovpos;
+ u.fdetc.u= &u;
trackloc_set_exactinto(&u.fdet, &u.fdetc, foredet, foredet->tr_backwards,
tra->maxinto);
+
u.tail= u.fdet;
+
+ u.tailc.getmovpos= pred_getmovpos;
+ u.tailc.u= &u;
+
ec= trackloc_reverse_exact(&u.tail, &u.tailc); assert(!ec);
/* find the train's tail and mark it present */
+ tra->uncertainty + MARGIN_TAIL;
u.tailc.nextseg= initpresent_nextseg;
u.tailc.trackend= pred_trackend_panic;
- u.tailc.u= &u;
ec= initpresent_nextseg(&u.tail,&u.tailc,0,0); assert(!ec);
ec= trackloc_advance(&u.tail,&u.tailc); assert(!ec);
u.fdetc.nextseg= fdet_nextseg;
u.fdetc.getmovpos= pred_getmovpos;
u.fdetc.trackend= pred_trackend;
- u.fdetc.u= &u;
u.tailc.nextseg= tail_nextseg;
const SegPosCombInfo *pci;
int r;
+ t->seg= seg;
+ t->backwards= backwards;
+ t->remain= 0;
+
r= trackloc_getlink(t,c,&pci,0,-1);
if (r) return r;
assert(pci);
- t->seg= seg;
- t->backwards= backwards;
t->remain= pci->dist - into;
return 0;
}