casl2、comet2コマンドのエラーや使い方表示を変更
authorj8takagi <j8takagi@nifty.com>
Tue, 2 Mar 2010 01:11:11 +0000 (10:11 +0900)
committerj8takagi <j8takagi@nifty.com>
Tue, 2 Mar 2010 01:11:11 +0000 (10:11 +0900)
src/casl2.c
src/comet2.c
test/integration/casl2/opt_h/0.txt
test/integration/comet2/err_208/0.txt [new file with mode: 0644]
test/integration/comet2/err_208/Makefile [new file with mode: 0644]
test/integration/comet2/err_208/a.o [new file with mode: 0644]

index 5ae4825..944ed40 100644 (file)
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
     WORD beginptr[argc];
     char *objfile = NULL;
     const char *usage =
-        "Usage: %s [-slLaAtTdh] [-oO<OUTFILE>] [-M <memorysize>] [-C <clocks>] FILE ...\n";
+        "Usage: %s [-slLaAtTdh] [-oO<OBJECTFILE>] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE ...\n";
 
     while((opt = getopt_long(argc, argv, "tTdslLao::O::AM:C:h", longopts, NULL)) != -1) {
         switch(opt) {
index be09f10..bb07c5f 100644 (file)
@@ -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 <memorysize>] [-C <clocks>] FILE\n";
+    const char *usage = "Usage: %s [-tTdh] [-M <MEMORYSIZE>] [-C <CLOCKS>] 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);
 }
index bf48477..bf6a3cc 100644 (file)
@@ -1,2 +1,2 @@
 ../../../../casl2 -saltdh ../../../../as/sum_10.casl
-Usage: ../../../../casl2 [-slLaAtTdh] [-oO<OUTFILE>] [-M <memorysize>] [-C <clocks>] FILE ...
+Usage: ../../../../casl2 [-slLaAtTdh] [-oO<OBJECTFILE>] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE ...
diff --git a/test/integration/comet2/err_208/0.txt b/test/integration/comet2/err_208/0.txt
new file mode 100644 (file)
index 0000000..6daf3f3
--- /dev/null
@@ -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 (file)
index 0000000..d36146b
--- /dev/null
@@ -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 (file)
index 0000000..b03d6df
Binary files /dev/null and b/test/integration/comet2/err_208/a.o differ