From: j8takagi Date: Mon, 6 Jul 2026 09:33:20 +0000 (+0900) Subject: monitor終了時、exitするのではなく、execに戻るよう内部動作を修正 X-Git-Tag: v0.6p10~3 X-Git-Url: https://www.j8takagi.net/gitweb?a=commitdiff_plain;h=88469358f2ff2944f934dee9314a62e3fa6320d8;p=yacasl2.git monitor終了時、exitするのではなく、execに戻るよう内部動作を修正 - exitの場合、casl2 -mのmonitor終了時にメモリーリーク発生するため - monitor終了時、execmode.monitorとexecmode.stepをfalseにする - exec側の処理 -- execmode.monitorがfalseでexecptr->startがfalseかexecptr->endがtrueuの場合は即時終了 -- それ以外の場合は、execmode.monitorがfalseのままCOMET IIを実行 --- diff --git a/include/monitor.h b/include/monitor.h index 603505e..10b179c 100644 --- a/include/monitor.h +++ b/include/monitor.h @@ -131,9 +131,8 @@ void freebps(); /** * @brief モニター終了時の処理をする * - * @return エラーがない場合は0、エラーがある場合は1 */ -int monquit(); +void monquit(); /** * @brief COMET IIモニターを起動する diff --git a/src/exec.c b/src/exec.c index dc2b2dc..5ff6120 100644 --- a/src/exec.c +++ b/src/exec.c @@ -704,6 +704,9 @@ void exec() fprintf(stdout, "%s", monmsg); } monitor(); + if(execmode.monitor == false && (execptr->start == false || execptr->stop == true)) { + break; + } } /* プログラムレジスタをチェック */ if(sys->cpu->pr >= sys->memsize) { diff --git a/src/monitor.c b/src/monitor.c index 5dd7d95..fa03bea 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -367,20 +367,11 @@ void free_moncmdline(MONCMDLINE *moncmdl) } } -int monquit() +void monquit() { - int stat = 0; - - comet2_shutdown(); + execmode.monitor = false; + execmode.step = false; freebps(); - free_cmdtable(HASH_CMDTYPE); - free_cmdtable(HASH_CODE); - - if(cerr->num > 0) { - stat = 1; - } - freecerr(); - return stat; } void monitor() @@ -396,7 +387,8 @@ void monitor() /* EOFの処理 */ if(buf == NULL) { FREE(last_buf); - exit(monquit()); + monquit(); + break; } /* 空行(Enterだけ)の場合は、前回のコマンドをリピート */ if(buf[0] == '\0') { @@ -427,7 +419,8 @@ void monitor() if(cmdtype == MONQUIT) { FREE(buf); FREE(last_buf); - exit(monquit()); + monquit(); + break; } } while(cmdtype == MONREPEAT); FREE(buf); diff --git a/src/struct.c b/src/struct.c index a5d2c2c..435b70c 100644 --- a/src/struct.c +++ b/src/struct.c @@ -273,7 +273,7 @@ bool code_gr_valid(WORD code) WORD gr = 0; if(cmdtype == R_ADR_X || cmdtype == R1_R2 || cmdtype == R_) { gr = (code & 0x00F0) >> 4; - if(gr < 0 || GRSIZE <= gr) { + if(gr >= GRSIZE) { res = false; } }