From 7b6d89e7273b49e335af425cbb1ecb2258bf15df Mon Sep 17 00:00:00 2001
From: j8takagi <j8takagi@nifty.com>
Date: Mon, 25 Apr 2011 07:59:57 +0900
Subject: [PATCH] =?utf8?q?=E3=83=88=E3=83=BC=E3=82=AF=E3=83=B3=E3=81=AE?=
 =?utf8?q?=E3=82=A2=E3=82=BB=E3=83=B3=E3=83=96=E3=83=AB=E3=82=92=E3=83=AA?=
 =?utf8?q?=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

---
 src/assemble.c | 53 +++++++++++++++++++-------------------------------
 src/casl2.c    |  6 +++---
 src/exec.c     |  6 +++---
 3 files changed, 26 insertions(+), 39 deletions(-)

diff --git a/src/assemble.c b/src/assemble.c
index aff5380..d8d8bc6 100644
--- a/src/assemble.c
+++ b/src/assemble.c
@@ -112,7 +112,7 @@ WORD getliteral(const char *str, PASS pass)
 
 /**
  * アセンブラ命令をメモリに書込
- * 実行に成功した場合はtrue、それ以外の場合はfalseを返す
+ * アセンブラ命令の場合はtrue、それ以外の場合はfalseを返す
  */
 bool assemblecmd(const CMDLINE *cmdl, PASS pass)
 {
@@ -130,7 +130,7 @@ bool assemblecmd(const CMDLINE *cmdl, PASS pass)
         if(strcmp(cmdl->cmd, ascmd[i].cmd) == 0) {
             if(cmdl->opd->opdc < ascmd[i].opdc_min || cmdl->opd->opdc > ascmd[i].opdc_max) {
                 setcerr(106, NULL);    /* operand count mismatch */
-                return false;
+                return true;
             }
             cmdid = ascmd[i].cmdid;
             break;
@@ -142,7 +142,7 @@ bool assemblecmd(const CMDLINE *cmdl, PASS pass)
     case START:
         if(cmdl->label == NULL) {
             setcerr(107, NULL);    /* no label in START */
-            return false;
+            return true;
         }
         /* プログラム名の設定 */
         asptr->prog = strdup_chk(cmdl->label, "asptr.prog");
@@ -183,13 +183,13 @@ bool assemblecmd(const CMDLINE *cmdl, PASS pass)
     default:
         return false;
     }
-    return (cerr->num == 0) ? true : false;
+    return true;
 }
 
 /**
  *  macrocmd
- *  マクロ命令をメモリに書込
- *  書込に成功した場合はtrue、それ以外の場合はfalseを返す
+ * マクロ命令をメモリに書込
+ * マクロ命令の場合はtrue、それ以外の場合はfalseを返す
  */
 bool macrocmd(const CMDLINE *cmdl, PASS pass)
 {
@@ -209,7 +209,7 @@ bool macrocmd(const CMDLINE *cmdl, PASS pass)
                cmdl->opd->opdc > macrocmd[i].opdc_max)
             {
                 setcerr(106, NULL);    /* operand count mismatch */
-                return false;
+                return true;
             }
             cmdid = macrocmd[i].cmdid;
             break;
@@ -219,19 +219,20 @@ bool macrocmd(const CMDLINE *cmdl, PASS pass)
     {
     case IN:
         writeIN(cmdl->opd->opdv[0], cmdl->opd->opdv[1], pass);
-        return true;
+        break;
     case OUT:
         writeOUT(cmdl->opd->opdv[0], cmdl->opd->opdv[1], pass);
-        return true;
+        break;
     case RPUSH:
         writeRPUSH(pass);
-        return true;
+        break;
     case RPOP:
         writeRPOP(pass);
-        return true;
+        break;
     default:
         return false;
     }
+    return true;
 }
 
 /**
@@ -502,32 +503,18 @@ void writeDC(const char *str, PASS pass)
  */
 bool assembletok(const CMDLINE *cmdl, PASS pass)
 {
-    bool status = false;
-
     /* 命令がない場合 */
     if(cmdl->cmd == NULL){
-        ;
-    }
-    /* アセンブラ命令の処理 */
-    else if(cerr->num == 0 && assemblecmd(cmdl, pass) == true) {
-        ;
-    }
-    /* マクロ命令の書込 */
-    else if(cerr->num == 0 && macrocmd(cmdl, pass) == true) {
-        ;
-    }
-    /* 機械語命令の書込 */
-    else if(cerr->num == 0 && cometcmd(cmdl, pass) == true) {
-        ;
-    }
-    else if(cerr->num == 0) {
-        setcerr(113, cmdl->cmd);    /* operand too many in COMET II command */
+        return true;
     }
-    /* エラーが発生していないか確認 */
-    if(cerr->num == 0) {
-        status = true;
+    /* アセンブラ命令またはマクロ命令の書込 */
+    if(assemblecmd(cmdl, pass) == false && macrocmd(cmdl, pass) == false) {
+        /* COMET II命令の書込 */
+        if(cometcmd(cmdl, pass) == false && cerr->num == 0) {
+            setcerr(113, cmdl->cmd);    /* operand too many in COMET II command */
+        }
     }
-    return status;
+    return (cerr->num == 0) ? true : false;
 }
 
 /**
diff --git a/src/casl2.c b/src/casl2.c
index cf44e68..c40a0a7 100644
--- a/src/casl2.c
+++ b/src/casl2.c
@@ -104,7 +104,7 @@ asfin:
  */
 int main(int argc, char *argv[])
 {
-    int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS, opt, i, status;
+    int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS, opt, i, stat;
     char *af[argc];
     char *objfile = NULL;
     const char *usage =
@@ -190,7 +190,7 @@ int main(int argc, char *argv[])
     }
 casl2fin:
     shutdown();                                    /* 仮想マシンCOMET IIのシャットダウン */
-    status = (cerr->num == 0) ? 0 : -1;
+    stat = (cerr->num == 0) ? 0 : -1;
     freecerr();                                    /* エラーの解放 */
-    return status;
+    return stat;
 }
diff --git a/src/exec.c b/src/exec.c
index d8df852..1bc891e 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -54,7 +54,7 @@ void addcerrlist_exec()
 bool loadassemble(const char *file)
 {
     FILE *fp;
-    bool status = true;
+    bool stat = true;
 
     assert(file != NULL);
     if((fp = fopen(file, "r")) == NULL) {
@@ -66,10 +66,10 @@ bool loadassemble(const char *file)
     if(execptr->end == sys->memsize) {
         setcerr(210, file);    /* load - memory overflow */
         fprintf(stderr, "Load error - %d: %s\n", cerr->num, cerr->msg);
-        status = false;
+        stat = false;
     }
     fclose(fp);
-    return status;
+    return stat;
 }
 
 /**
-- 
2.18.0