From 22dc7e0f6bc6f0a7ebe6c0b998db13d7e6c7cbbc Mon Sep 17 00:00:00 2001 From: j8takagi Date: Tue, 2 Mar 2010 10:11:11 +0900 Subject: [PATCH] =?utf8?q?casl2=E3=80=81comet2=E3=82=B3=E3=83=9E=E3=83=B3?= =?utf8?q?=E3=83=89=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=84=E4=BD=BF?= =?utf8?q?=E3=81=84=E6=96=B9=E8=A1=A8=E7=A4=BA=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/casl2.c | 2 +- src/comet2.c | 19 ++++++++++++++----- test/integration/casl2/opt_h/0.txt | 2 +- test/integration/comet2/err_208/0.txt | 2 ++ test/integration/comet2/err_208/Makefile | 8 ++++++++ test/integration/comet2/err_208/a.o | Bin 0 -> 4 bytes 6 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 test/integration/comet2/err_208/0.txt create mode 100644 test/integration/comet2/err_208/Makefile create mode 100644 test/integration/comet2/err_208/a.o diff --git a/src/casl2.c b/src/casl2.c index 5ae4825..944ed40 100644 --- a/src/casl2.c +++ b/src/casl2.c @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) WORD beginptr[argc]; char *objfile = NULL; const char *usage = - "Usage: %s [-slLaAtTdh] [-oO] [-M ] [-C ] FILE ...\n"; + "Usage: %s [-slLaAtTdh] [-oO] [-M ] [-C ] FILE ...\n"; while((opt = getopt_long(argc, argv, "tTdslLao::O::AM:C:h", longopts, NULL)) != -1) { switch(opt) { diff --git a/src/comet2.c b/src/comet2.c index be09f10..bb07c5f 100644 --- a/src/comet2.c +++ b/src/comet2.c @@ -18,6 +18,7 @@ static struct option longopts[] = { /* comet2のエラー定義 */ CERRARRAY cerr_comet2[] = { { 201, "Load object file - full of COMET II memory" }, + { 208, "object file is not specified" }, }; bool addcerrlist_comet2() { @@ -27,6 +28,7 @@ bool addcerrlist_comet2() /* 指定されたファイルからアセンブル結果を読込 */ bool loadassemble(char *file) { FILE *fp; + bool status = true; if((fp = fopen(file, "r")) == NULL) { perror(file); @@ -35,17 +37,17 @@ bool loadassemble(char *file) { if((endptr = startptr + fread(memory, sizeof(WORD), memsize-startptr, fp)) == memsize) { setcerr(201, NULL); /* Load object file - full of COMET II memory */ fprintf(stderr, "Execute error - %d: %s\n", cerrno, cerrmsg); - return false; + status = false; } fclose(fp); - return true; + return status; } /* comet2コマンド */ int main(int argc, char *argv[]) { int opt; - const char *usage = "Usage: %s [-tTdh] [-M ] [-C ] FILE\n"; + const char *usage = "Usage: %s [-tTdh] [-M ] [-C ] FILE\n"; addcerrlist_comet2(); while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) { @@ -74,14 +76,21 @@ int main(int argc, char *argv[]) exit(-1); } } + if(argv[optind] == NULL) { + setcerr(208, NULL); /* object file is not specified */ + fprintf(stderr, "comet2 error - %d: %s\n", cerrno, cerrmsg); + goto comet2err; + } reset(); startptr = 0; if(loadassemble(argv[optind]) == true) { exec(); /* プログラム実行 */ } if(cerrno > 0) { - freecerr(); - exit(-1); + goto comet2err; } return 0; +comet2err: + freecerr(); + exit(-1); } diff --git a/test/integration/casl2/opt_h/0.txt b/test/integration/casl2/opt_h/0.txt index bf48477..bf6a3cc 100644 --- a/test/integration/casl2/opt_h/0.txt +++ b/test/integration/casl2/opt_h/0.txt @@ -1,2 +1,2 @@ ../../../../casl2 -saltdh ../../../../as/sum_10.casl -Usage: ../../../../casl2 [-slLaAtTdh] [-oO] [-M ] [-C ] FILE ... +Usage: ../../../../casl2 [-slLaAtTdh] [-oO] [-M ] [-C ] FILE ... diff --git a/test/integration/comet2/err_208/0.txt b/test/integration/comet2/err_208/0.txt new file mode 100644 index 0000000..6daf3f3 --- /dev/null +++ b/test/integration/comet2/err_208/0.txt @@ -0,0 +1,2 @@ +../../../../comet2 -M8 +comet2 error - 208: object file is not specified diff --git a/test/integration/comet2/err_208/Makefile b/test/integration/comet2/err_208/Makefile new file mode 100644 index 0000000..d36146b --- /dev/null +++ b/test/integration/comet2/err_208/Makefile @@ -0,0 +1,8 @@ +include ../CMD.mk # YACASL2DIR, CASL2, COMET2 +ASDIR = $(YACASL2DIR)/as +CASL2LIBDIR = $(YACASL2DIR)/as/casl2lib +ASFILE = $(YACASL2DIR)/as/err/err_207.casl +ASCMD = $(CASL2) -O $(YACASL2DIR)/as/err/err_207.casl +COMET2FLAG = -M8 +EXECCMD = $(COMET2) $(COMET2FLAG) +include ../TEST.mk diff --git a/test/integration/comet2/err_208/a.o b/test/integration/comet2/err_208/a.o new file mode 100644 index 0000000000000000000000000000000000000000..b03d6df574fd4fdd82bd1f04663e1b40badf071e GIT binary patch literal 4 LcmWeAWM~8c0vG`U literal 0 HcmV?d00001 -- 2.18.0