}
static void si_movpos(ParseState *ps) {
- long pl;
- int r,s,f, n_posns;
+ int r,s,f;
s= ps_needsegment(ps); if (s<0) return;
r= ps_needword(ps); if (r) return;
- if (thiswordstrcmp(ps,"feat")) { badcmd(ps,"weird movpos"); return; }
+ if (thiswordstrcmp(ps,"position")) { badcmd(ps,"weird movpos"); return; }
r= ps_needword(ps); if (r) return;
- f= lstrpdbsearch_movfeat(ps->thisword, ps->lthisword,
- &ui_plan_data.segments[s]); if (f<0) return;
-
- n_posns= ui_plan_data.segments[s].movfeats[f].n_posns;
- if (ps->remain[0]=='?') goto unknown;
- r= ps_neednumber(ps,&pl,0,n_posns-1,"movfeat posn"); if (r) goto unknown;
- state[s].mfs[f].posn= pl;
- mx_redraw_seg(s);
- return;
+ if (!thiswordstrcmp(ps,"?")) {
+ int f;
+ for (f=0; f < ui_plan_data.segments[s].n_movfeats; f++)
+ state[s].mfs[f].posn= ui_plan_data.segments[s].movfeats[f].n_posns;
+ mx_redraw_seg(s);
+ return;
+ }
-unknown:
- state[s].mfs[f].posn= n_posns;
- mx_redraw_seg(s);
+ const char *feat= ps->thisword;
+ const char *endword= ps->thisword + ps->lthisword;
+ while (feat < endword) {
+ int featl;
+ for (featl=0;
+ featl < ps->lthisword && CTYPE(isalpha, feat[featl]);
+ featl++);
+
+ char *ep;
+ errno=0; unsigned long pos= strtoul(feat+featl,&ep,10);
+
+ if (!featl || errno || ep==feat+featl || ep > endword) {
+ badcmd(ps,"bad movfeatpos `%.*s'", (int)(endword - feat), feat);
+ return;
+ }
+
+ f= lstrpdbsearch_movfeat(feat, featl, &ui_plan_data.segments[s]);
+ if (f<0) continue;
+
+ if (pos >= ui_plan_data.segments[s].movfeats[f].n_posns)
+ { badcmd(ps,"out of range movfeat %.*s%lu", featl,feat, pos); }
+
+ state[s].mfs[f].posn= pos;
+ mx_redraw_seg(s);
+
+ feat= ep;
+ }
}
static void si_on(ParseState *ps) {
static const MuxEventInfo muxeventinfos[]= {
{ "?detect", "", si_detect },
{ "?picio out polarity", "", si_polarity },
- { "?movpos", "_*_feat", si_movpos },
+ { "?movpos", "_*_position", si_movpos },
{ "?picio out on", "", si_on },
{ "?picio out off", "", si_off },
{ "?train", "_*_has", si_train },