SCP: Fixed SET and SHOW command parsing to more generally allow value operations against the default device (CPU) both with and without value oriented modifiers

This commit is contained in:
Mark Pizzolato 2014-10-28 08:39:14 -07:00
parent a9e82dd2f9
commit 6368a217fb

26
scp.c
View file

@ -3653,7 +3653,7 @@ C1TAB *ctbr = NULL, *glbr;
GET_SWITCHES (cptr); /* get switches */ GET_SWITCHES (cptr); /* get switches */
if (*cptr == 0) /* must be more */ if (*cptr == 0) /* must be more */
return SCPE_2FARG; return SCPE_2FARG;
cptr = get_glyph (cptr, gbuf, 0); /* get glob/dev/unit */ cptr = get_glyph (svptr = cptr, gbuf, 0); /* get glob/dev/unit */
if ((dptr = find_dev (gbuf))) { /* device match? */ if ((dptr = find_dev (gbuf))) { /* device match? */
uptr = dptr->units; /* first unit */ uptr = dptr->units; /* first unit */
@ -3673,16 +3673,19 @@ else if ((gcmdp = find_ctab (set_glob_tab, gbuf))) { /* global? */
return gcmdp->action (gcmdp->arg, cptr); /* do the rest */ return gcmdp->action (gcmdp->arg, cptr); /* do the rest */
} }
else { else {
if (sim_dflt_dev->modifiers) if (sim_dflt_dev->modifiers) {
if ((cvptr = strchr (gbuf, '='))) /* = value? */
*cvptr++ = 0;
for (mptr = sim_dflt_dev->modifiers; mptr->mask != 0; mptr++) { for (mptr = sim_dflt_dev->modifiers; mptr->mask != 0; mptr++) {
if (mptr->mstring && (MATCH_CMD (gbuf, mptr->mstring) == 0)) { if (mptr->mstring && (MATCH_CMD (gbuf, mptr->mstring) == 0)) {
dptr = sim_dflt_dev; dptr = sim_dflt_dev;
cptr -= strlen (gbuf) + 1; cptr = svptr;
while (isspace(*cptr)) while (isspace(*cptr))
++cptr; ++cptr;
break; break;
} }
} }
}
if (!dptr) if (!dptr)
return SCPE_NXDEV; /* no match */ return SCPE_NXDEV; /* no match */
lvl = MTAB_VDV; /* device match */ lvl = MTAB_VDV; /* device match */
@ -3764,6 +3767,8 @@ return SCPE_OK; /* done all */
CTAB *find_ctab (CTAB *tab, const char *gbuf) CTAB *find_ctab (CTAB *tab, const char *gbuf)
{ {
if (!tab)
return NULL;
for (; tab->name != NULL; tab++) { for (; tab->name != NULL; tab++) {
if (MATCH_CMD (gbuf, tab->name) == 0) if (MATCH_CMD (gbuf, tab->name) == 0)
return tab; return tab;
@ -3773,6 +3778,8 @@ return NULL;
C1TAB *find_c1tab (C1TAB *tab, const char *gbuf) C1TAB *find_c1tab (C1TAB *tab, const char *gbuf)
{ {
if (!tab)
return NULL;
for (; tab->name != NULL; tab++) { for (; tab->name != NULL; tab++) {
if (MATCH_CMD (gbuf, tab->name) == 0) if (MATCH_CMD (gbuf, tab->name) == 0)
return tab; return tab;
@ -3899,7 +3906,7 @@ return r;
t_stat show_cmd_fi (FILE *ofile, int32 flag, char *cptr) t_stat show_cmd_fi (FILE *ofile, int32 flag, char *cptr)
{ {
uint32 lvl = 0xFFFFFFFF; uint32 lvl = 0xFFFFFFFF;
char gbuf[CBUFSIZE], *cvptr; char gbuf[CBUFSIZE], *cvptr, *svptr;
DEVICE *dptr; DEVICE *dptr;
UNIT *uptr; UNIT *uptr;
MTAB *mptr; MTAB *mptr;
@ -3908,7 +3915,7 @@ SHTAB *shtb = NULL, *shptr;
GET_SWITCHES (cptr); /* get switches */ GET_SWITCHES (cptr); /* get switches */
if (*cptr == 0) /* must be more */ if (*cptr == 0) /* must be more */
return SCPE_2FARG; return SCPE_2FARG;
cptr = get_glyph (cptr, gbuf, 0); /* get next glyph */ cptr = get_glyph (svptr = cptr, gbuf, 0); /* get next glyph */
if ((dptr = find_dev (gbuf))) { /* device match? */ if ((dptr = find_dev (gbuf))) { /* device match? */
uptr = dptr->units; /* first unit */ uptr = dptr->units; /* first unit */
@ -3930,19 +3937,22 @@ else if ((shptr = find_shtab (show_glob_tab, gbuf))) { /* global? */
return shptr->action (ofile, NULL, NULL, shptr->arg, cptr); return shptr->action (ofile, NULL, NULL, shptr->arg, cptr);
} }
else { else {
if (sim_dflt_dev->modifiers) if (sim_dflt_dev->modifiers) {
if ((cvptr = strchr (gbuf, '='))) /* = value? */
*cvptr++ = 0;
for (mptr = sim_dflt_dev->modifiers; mptr->mask != 0; mptr++) { for (mptr = sim_dflt_dev->modifiers; mptr->mask != 0; mptr++) {
if ((((mptr->mask & MTAB_VDV) == MTAB_VDV) && if ((((mptr->mask & MTAB_VDV) == MTAB_VDV) &&
(mptr->pstring && (MATCH_CMD (gbuf, mptr->pstring) == 0))) || (mptr->pstring && (MATCH_CMD (gbuf, mptr->pstring) == 0))) ||
(!(mptr->mask & MTAB_VDV) && (mptr->mstring && (MATCH_CMD (gbuf, mptr->mstring) == 0)))) { (!(mptr->mask & MTAB_VDV) && (mptr->mstring && (MATCH_CMD (gbuf, mptr->mstring) == 0)))) {
dptr = sim_dflt_dev; dptr = sim_dflt_dev;
lvl = MTAB_VDV; /* device match */ lvl = MTAB_VDV; /* device match */
cptr -= strlen (gbuf) + 1; cptr = svptr;
while (isspace(*cptr)) while (isspace(*cptr))
++cptr; ++cptr;
break; break;
} }
} }
}
if (!dptr) if (!dptr)
return SCPE_NXDEV; /* no match */ return SCPE_NXDEV; /* no match */
} }
@ -3987,6 +3997,8 @@ return SCPE_OK;
SHTAB *find_shtab (SHTAB *tab, const char *gbuf) SHTAB *find_shtab (SHTAB *tab, const char *gbuf)
{ {
if (!tab)
return NULL;
for (; tab->name != NULL; tab++) { for (; tab->name != NULL; tab++) {
if (MATCH_CMD (gbuf, tab->name) == 0) if (MATCH_CMD (gbuf, tab->name) == 0)
return tab; return tab;