1
0
mirror of https://github.com/simh/simh.git synced 2026-03-23 01:16:00 +00:00

Added a mechanism for commands to optionally handle their message printing via a separate dispatch in the command table. This is currently used by run_cmd to handle unsuppressed status returns.

This commit is contained in:
Mark Pizzolato
2012-04-25 04:04:48 -07:00
parent e153e0f483
commit 6def9ed6a8
2 changed files with 38 additions and 18 deletions

54
scp.c
View File

@@ -419,7 +419,7 @@ t_stat set_quiet (int32 flag, char *cptr);
t_stat set_asynch (int32 flag, char *cptr);
t_stat do_cmd_label (int32 flag, char *cptr, char *label);
void int_handler (int signal);
void run_cmd_message (const char *unechod_cmdline, t_stat r);
/* Global data */
@@ -588,15 +588,15 @@ static CTAB cmd_table[] = {
{ "EVALUATE", &eval_cmd, 0,
"ev{aluate} <expr> evaluate symbolic expression\n" },
{ "RUN", &run_cmd, RU_RUN,
"ru{n} {new PC} reset and start simulation\n" },
"ru{n} {new PC} reset and start simulation\n", &run_cmd_message },
{ "GO", &run_cmd, RU_GO,
"go {new PC} start simulation\n" },
"go {new PC} start simulation\n", &run_cmd_message },
{ "STEP", &run_cmd, RU_STEP,
"s{tep} {n} simulate n instructions\n" },
"s{tep} {n} simulate n instructions\n", &run_cmd_message },
{ "CONT", &run_cmd, RU_CONT,
"c{ont} continue simulation\n" },
"c{ont} continue simulation\n", &run_cmd_message },
{ "BOOT", &run_cmd, RU_BOOT,
"b{oot} <unit> bootstrap unit\n" },
"b{oot} <unit> bootstrap unit\n", &run_cmd_message },
{ "BREAK", &brk_cmd, SSH_ST,
"br{eak} <list> set breakpoints\n" },
{ "NOBREAK", &brk_cmd, SSH_CL,
@@ -895,9 +895,13 @@ while (stat != SCPE_EXIT) { /* in case exit */
stat = SCPE_BARE_STATUS(stat); /* remove possible flag */
sim_last_cmd_stat = stat; /* save command error status */
if ((stat >= SCPE_BASE) && (!stat_nomessage)) { /* error? */
printf ("%s\n", sim_error_text (stat));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (stat));
if (cmdp->message)
cmdp->message (NULL, stat);
else {
printf ("%s\n", sim_error_text (stat));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (stat));
}
}
if (sim_vm_post != NULL)
(*sim_vm_post) (TRUE);
@@ -1205,7 +1209,8 @@ do {
if ((stat >= SCPE_BASE) && (stat != SCPE_EXIT) && /* error from cmd? */
(stat != SCPE_STEP)) {
if (!echo && !sim_quiet && /* report if not echoing */
!stat_nomessage) { /* and not suppressing messages */
!stat_nomessage && /* and not suppressing messages */
!cmdp->message) { /* and not handling them specially */
printf("%s> %s\n", do_position(), ocptr);
if (sim_log)
fprintf (sim_log, "%s> %s\n", do_position(), ocptr);
@@ -1213,9 +1218,14 @@ do {
}
if ((flag <= 0) && /* report error if in cmdline/init file */
(stat >= SCPE_BASE) && !stat_nomessage) {
printf ("%s\n", sim_error_text (stat));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (stat));
if (cmdp->message) { /* special message handler */
cmdp->message ((!echo && !sim_quiet) ? ocptr : NULL, stat);
}
else {
printf ("%s\n", sim_error_text (stat));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (stat));
}
}
if (staying &&
(sim_on_check[sim_do_depth]) &&
@@ -3605,15 +3615,23 @@ if (sim_clock_queue != NULL) { /* update sim time */
else {
UPDATE_SIM_TIME (noqueue_time);
}
return r;
}
void
run_cmd_message (const char *unechoed_cmdline, t_stat r)
{
#if defined (VMS)
printf ("\n");
#endif
if (!(r & SCPE_NOMESSAGE)) {
fprint_stopped (stdout, r); /* print msg */
if (sim_log) /* log if enabled */
fprint_stopped (sim_log, r);
if (unechoed_cmdline) {
printf("%s> %s\n", do_position(), unechoed_cmdline);
if (sim_log)
fprintf (sim_log, "%s> %s\n", do_position(), unechoed_cmdline);
}
return r | SCPE_NOMESSAGE;
fprint_stopped (stdout, r); /* print msg */
if (sim_log) /* log if enabled */
fprint_stopped (sim_log, r);
}
/* Common setup for RUN or BOOT */

View File

@@ -436,6 +436,8 @@ struct sim_ctab {
/* action routine */
int32 arg; /* argument */
char *help; /* help string */
void (*message)(const char *unechoed_cmdline, t_stat stat);
/* message printing routine */
};
struct sim_c1tab {