From 42e7d48c8225a3ee7572bc6fda874672542a22cc Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 17 Dec 2014 21:00:38 -0800 Subject: [PATCH] SCP: Fixes Cannot show radix, etc. for a device that has no modifiers and SET and SHOW responses for invalid entry are inconsistent. from Dave Bryan 001. PROBLEM: Cannot show radix, etc. for a device that has no modifiers. OBSERVATION: The default data radix for a device may be set with the SET OCT|DEC|HEX command. However, if the device does not have a modifier table, SHOW RADIX is rejected with "No settable parameters". The same problem occurs for SHOW DEBUG and SHOW NAMES. For a device that provides debug printouts, SHOW MOD will list "DEBUG, NODEBUG" among the modifiers, and the SHOW DEBUG command will display the current debug status. However, if the device does not contain a modifier table, SHOW MOD and SHOW DEBUG will report "No settable parameters", even though SET DEBUG is accepted and works as expected. For such a device, SHOW MOD will show "DEBUG, NODEBUG" as acceptable modifiers. 002. PROBLEM: SET and SHOW responses for invalid entry are inconsistent. OBSERVATION: Entering SET where is not defined in the device's modifier table displays "Non-existent parameter." Entering SHOW with the same parameters displays "Invalid argument." Similarly, entering SET DEBUG for a device that does not have debugging capability displays "Command not allowed." Entering SHOW with the same parameters displays nothing. In both cases, the messages displayed should be the same for the same error. --- scp.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scp.c b/scp.c index efe26c46..41b794d7 100644 --- a/scp.c +++ b/scp.c @@ -3999,15 +3999,13 @@ if (*cptr == 0) { /* now eol? */ show_device (ofile, dptr, 0): show_unit (ofile, dptr, uptr, -1); } -if (dptr->modifiers == NULL) /* any modifiers? */ - return SCPE_NOPARAM; GET_SWITCHES (cptr); /* get more switches */ while (*cptr != 0) { /* do all mods */ cptr = get_glyph (cptr, gbuf, ','); /* get modifier */ if ((cvptr = strchr (gbuf, '='))) /* = value? */ *cvptr++ = 0; - for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) { + for (mptr = dptr->modifiers; mptr && (mptr->mask != 0); mptr++) { if (((mptr->mask & MTAB_XTD)? /* right level? */ ((mptr->mask & lvl) == lvl): (MTAB_VUN & lvl)) && ((mptr->disp && mptr->pstring && /* named disp? */ @@ -4023,10 +4021,18 @@ while (*cptr != 0) { /* do all mods */ break; } /* end if */ } /* end for */ - if (mptr->mask == 0) { /* no match? */ - if (shtb && (shptr = find_shtab (shtb, gbuf))) /* global match? */ - shptr->action (ofile, dptr, uptr, shptr->arg, cptr); - else return SCPE_ARG; + if (!mptr || (mptr->mask == 0)) { /* no match? */ + if (shtb && (shptr = find_shtab (shtb, gbuf))) {/* global match? */ + t_stat r; + + r = shptr->action (ofile, dptr, uptr, shptr->arg, cptr); + if (r != SCPE_OK) + return r; + } + else if (!dptr->modifiers) /* no modifiers? */ + return SCPE_NOPARAM; + else + return SCPE_NXPAR; } /* end if */ } /* end while */ return SCPE_OK;