From 89d0fdd7b4c6ac0ee6fb834c06d65a34d5458440 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Thu, 18 Jun 2026 18:35:54 +0900 Subject: [PATCH] =?utf8?q?comet2=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?utf8?q?=E3=81=A7=E3=80=81=E8=A4=87=E6=95=B0=E3=83=95=E3=82=A1=E3=82=A4?= =?utf8?q?=E3=83=AB=E6=8C=87=E5=AE=9A=E6=99=82=E3=81=AB2=E3=81=A4=E7=9B=AE?= =?utf8?q?=E4=BB=A5=E9=99=8D=E3=81=AF=E7=84=A1=E8=A6=96=E3=81=95=E3=82=8C?= =?utf8?q?=E3=82=8BInfo=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B?= =?utf8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/comet2.c | 6 +++++- test/system/comet2_opt/opt_2ndarg/0.txt | 2 ++ test/system/comet2_opt/opt_2ndarg/Makefile | 2 ++ test/system/comet2_opt/opt_2ndarg/cmd | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/system/comet2_opt/opt_2ndarg/0.txt create mode 100644 test/system/comet2_opt/opt_2ndarg/Makefile create mode 100755 test/system/comet2_opt/opt_2ndarg/cmd diff --git a/src/comet2.c b/src/comet2.c index b3f59a9..e381780 100644 --- a/src/comet2.c +++ b/src/comet2.c @@ -88,7 +88,11 @@ int main(int argc, char *argv[]) } comet2_init(memsize, clocks); /* COMET II仮想マシンの初期化 */ execptr->start = 0; - execptr->end = loadassemble(argv[optind], execptr->start); + execptr->end = loadassemble(argv[optind++], execptr->start); + if(optind < argc) { + warn_ignore_arg(argc - optind, argv + optind); + } + /* 残りの引数(オプション以外の引数)があるかチェック */ if(execptr->end > 0 && cerr->num == 0) { exec(); /* プログラム実行 */ } diff --git a/test/system/comet2_opt/opt_2ndarg/0.txt b/test/system/comet2_opt/opt_2ndarg/0.txt new file mode 100644 index 0000000..d81dd9d --- /dev/null +++ b/test/system/comet2_opt/opt_2ndarg/0.txt @@ -0,0 +1,2 @@ +Hello, World! +Info: arguments '../../../../as/sample/test.o ../../../../as/sample/test.o' are ignored. diff --git a/test/system/comet2_opt/opt_2ndarg/Makefile b/test/system/comet2_opt/opt_2ndarg/Makefile new file mode 100644 index 0000000..b6dac59 --- /dev/null +++ b/test/system/comet2_opt/opt_2ndarg/Makefile @@ -0,0 +1,2 @@ +include ../Define.mk +include ../Test.mk diff --git a/test/system/comet2_opt/opt_2ndarg/cmd b/test/system/comet2_opt/opt_2ndarg/cmd new file mode 100755 index 0000000..37090b5 --- /dev/null +++ b/test/system/comet2_opt/opt_2ndarg/cmd @@ -0,0 +1 @@ +../../../../comet2 ../../../../as/sample/hello.o ../../../../as/sample/test.o ../../../../as/sample/test.o -- 2.47.3