From a339dae65182691e2203a9ed03191af4a1239de3 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 10 Apr 2012 05:38:12 -0700 Subject: [PATCH] Extensive Control Flow Enhancements: Added Message Suppression flag for status values, including providing a -Q option to the RETURN command to return with a message suppressed status Added Do command file default extension of .sim (from Dave Bryan) Added -O option to DO command file invocation which causes the caller's ON state and actions to be inherited in the newly called DO command file Added Command Line expansion to include a %* which expands to the whole set of arguments (%1 ... %9) Relaxed Command Line argument substitution (delimited by %'s) which cause environment variable lookups to first lookup the literal name provided and if that fails, lookup the name upcased. Added a SIM_VERIFY special Command Line expansion variable which expands to "-V" when command echoing is active Added a SIM_MESSAGE special Command Line expansion variable which expands to "-Q" when error message display is suppressed Added Command Aliasing, which causes the initial token on a command line to be looked up in the environment variable table, and if it exists to substitute the expansion for the initial token. Changed environment variable defining (with SET ENV variable=value) to always upcase the variable name. Added SHIFT command which shifts the numbered argument variables %1 ... %9 to the left by one (%1 becomes what was %2, etc.) Added CALL command which will call a routine (label) in the currently executing command file Added SET VERIFY and SET NOVERIFY commands which enable or disable DO command echoing Added SET MESSAGE and SET NOMESSAGE commands which globally enable or disable the display of status messages when commands (or Do Commands) return with unsuccessful status Added SET ON INHERIT and SET ON NOINHERIT to globally enable inheritance of ON state and actions when DO commands are invoked Added PROCEED and IGNORE commands which are do nothing but return success. These can be used in specific ON actions to possibly ignore particular return status values Added DO command file line number to error messages which are displayed while processing DO command files Expanded the DO command nesting level to 20 to potentially allow for more nesting due to the extensive use of CALL commands are used --- scp.c | 379 +++++++++++++++++++++++++++++++++++++++++++++-------- scp.h | 3 + sim_defs.h | 5 +- 3 files changed, 328 insertions(+), 59 deletions(-) diff --git a/scp.c b/scp.c index 779345c2..ace333cc 100644 --- a/scp.c +++ b/scp.c @@ -99,6 +99,7 @@ 27-Sep-04 RMS Fixed comma-separation options in set (David Bryan) 09-Sep-04 RMS Added -p option for RESET 13-Aug-04 RMS Qualified RESTORE detach with SIM_SW_REST + 17-Jul-04 JDB DO cmd file open failure retries with ".sim" appended 17-Jul-04 RMS Added ECHO command (Dave Bryan) 12-Jul-04 RMS Fixed problem ATTACHing to read only files (John Dundas) @@ -238,7 +239,7 @@ #define SSH_SH 1 /* show */ #define SSH_CL 2 /* clear */ -#define MAX_DO_NEST_LVL 10 /* DO cmd nesting level */ +#define MAX_DO_NEST_LVL 20 /* DO cmd nesting level */ #define SRBSIZ 1024 /* save/restore buffer */ #define SIM_BRK_INILNT 4096 /* bpt tbl length */ #define SIM_BRK_ALLTYP 0xFFFFFFFF @@ -400,8 +401,12 @@ t_stat dep_addr (int32 flag, char *cptr, t_addr addr, DEVICE *dptr, UNIT *uptr, int32 dfltinc); t_stat step_svc (UNIT *ptr); void sub_args (char *instr, char *tmpbuf, int32 maxstr, char *do_arg[]); +t_stat shift_args (char *do_arg[], size_t arg_count); t_stat set_on (int32 flag, char *cptr); +t_stat set_verify (int32 flag, char *cptr); +t_stat set_message (int32 flag, char *cptr); t_stat set_asynch (int32 flag, char *cptr); +t_stat do_cmd_label (int32 flag, char *cptr, char *label); /* Global data */ @@ -438,11 +443,15 @@ FILEREF *sim_log_ref = NULL; /* log file file referen FILE *sim_deb = NULL; /* debug file */ FILEREF *sim_deb_ref = NULL; /* debug file file reference */ static FILE *sim_gotofile; /* the currently open do file */ +static int32 sim_goto_line; /* the current line number in the currently open do file */ static int32 sim_do_echo = 0; /* the echo status of the currently open do file */ +static int32 sim_show_message = 1; /* the message display status of the currently open do file */ +static int32 sim_on_inherit = 0; /* the inherit status of on state and conditions when executing do files */ int32 sim_do_depth = 0; static int32 sim_on_check[MAX_DO_NEST_LVL+1]; static char *sim_on_actions[MAX_DO_NEST_LVL+1][SCPE_MAX_ERR+1]; +static char sim_do_filename[MAX_DO_NEST_LVL+1][CBUFSIZE]; static t_stat sim_last_cmd_stat; /* Command Status */ @@ -604,7 +613,9 @@ static CTAB cmd_table[] = { "set console DEL specify console delete char\n" "set console PCHAR specify console printable chars\n" "set console TELNET=port specify console telnet port\n" - "set console TELNET=LOG specify console telnet logging\n" + "set console TELNET=LOG=log_file\n" + " specify console telnet logging to the\n" + " specified destination {LOG,STDOUT,DEBUG or filename)\n" "set console TELNET=NOLOG disables console telnet logging\n" "set console TELNET=BUFFERED[=bufsize]\n" " specify console telnet buffering\n" @@ -613,10 +624,19 @@ static CTAB cmd_table[] = { "set console TELNET=UNBUFFERED\n" " disables console telnet buffering\n" "set console NOTELNET disable console telnet\n" - "set console LOG enable console logging\n" + "set console LOG=log_file enable console logging to the\n" + " specified destination {STDOUT,DEBUG or filename)\n" "set console NOLOG disable console logging\n" - "set console DEBUG enable console debugging\n" + "set console DEBUG=dbg_file\n" + " enable console debugging to the\n" + " specified destination {LOG,STDOUT or filename)\n" "set console NODEBUG disable console debugging\n" + "set log log_file specify the log destination\n" + " (STDOUT,DEBUG or filename)\n" + "set nolog disables any currently active logging\n" + "set debug debug_file specify the debug destination\n" + " (STDOUT,LOG or filename)\n" + "set nodebug disables any currently active debug output\n" "set break set breakpoints\n" "set nobreak clear breakpoints\n" "set throttle {x{M|K|%}}|{x/t}\n" @@ -625,6 +645,14 @@ static CTAB cmd_table[] = { "set asynch enable asynchronous I/O\n" "set noasynch disable asynchronous I/O\n" "set environment name=val set environment variable\n" + "set on enables error checking after command execution\n" + "set noon disables error checking after command execution\n" + "set on inherit enables inheritance of ON state and actions into do command files\n" + "set on noinherit disables inheritance of ON state and actions into do command files\n" + "set verify re-enables display of command file processed commands\n" + "set noverify disables display of command file processed commands\n" + "set message re-enables display of command file error messages\n" + "set nomessage disables display of command file error messages\n" "set OCT|DEC|HEX set device display radix\n" "set ENABLED enable device\n" "set DISABLED disable device\n" @@ -634,8 +662,6 @@ static CTAB cmd_table[] = { "set ENABLED enable unit\n" "set DISABLED disable unit\n" "set arg{,arg...} set unit parameters (see show modifiers)\n" - "set on enables error checking after command execution\n" - "set noon disables error checking after command execution\n" }, { "SHOW", &show_cmd, 0, "sh{ow} br{eak} show breakpoints\n" @@ -659,15 +685,25 @@ static CTAB cmd_table[] = { "sh{ow} {arg,...} show unit parameters\n" "sh{ow} on show on condition actions\n" }, { "DO", &do_cmd, 1, - "do {arg,arg...} process command file\n" }, + "do {-V} {-O} {-E} {arg,arg...}\b" + " process command file\n" }, { "GOTO", &goto_cmd, 1, "goto