]> j8takagi.net Git Repository - YACASL2.git/commitdiff
エラー時の動作を修正
authorj8takagi <j8takagi@nifty.com>
Sat, 13 Feb 2010 17:18:43 +0000 (02:18 +0900)
committerj8takagi <j8takagi@nifty.com>
Sat, 13 Feb 2010 17:18:43 +0000 (02:18 +0900)
include/cerr.h
src/casl2.c
src/cerr.c
src/comet2.c
src/token.c

index 878fd859ddff64eab2e0413e396af008bd2b9d2b..828d03e848c6664f6505c5f5a5ca950ffca341da 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef YACASL2_CERR_H_INCLUDED
 #define YACASL2_CERR_H_INCLUDED
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
@@ -25,11 +26,12 @@ typedef struct {
 extern CERRARRAY cerr[];
 
 enum {
-    MSGSIZE = 60,
+    CERRSTRSIZE = 10,    /* エラーメッセージ中に挿入できる文字列のサイズ */
+    CERRMSGSIZE = 70,    /* エラーメッセージのサイズ */
 };
 
 /* エラー番号とエラーメッセージを設定 */
-void setcerr(int num, const char *val);
+void setcerr(int num, const char *str);
 
 /* エラー番号からメッセージを返す */
 char *getcerrmsg(int num);
index 457dde74e4d2b8de99afef2f7b341dc4b6036f73..c3a555015a77009bb2c56ded13fe22fd7e18d61f 100644 (file)
@@ -30,19 +30,19 @@ CERRARRAY cerr[] = {
     { 103, "label not found" },
     { 104, "label length is too long" },
     { 105, "no command in the line" },
-    { 106, "operand count mismatch" },
+    { 106, "operand mismatch in assemble command" },
     { 107, "no label in START" },
     { 108, "not command of operand \"r\"" },
     { 109, "not command of operand \"r1,r2\"" },
     { 110, "not command of operand \"r,adr[,x]\"" },
     { 111, "not command of operand \"adr[,x]\"" },
     { 112, "not command of no operand" },
-    { 113, "command not defined" },
+    { 113, "operand too many in machine command" },
     { 114, "not integer" },
     { 115, "not hex" },
     { 116, "out of hex range" },
-    { 117, "operand is too many" },
-    { 118, "operand length is too long" },
+    { 117, "operand too many in DC" },
+    { 118, "operand length too long" },
     { 119, "out of COMET II memory" },
     { 120, "GR0 in operand x" },
     { 121, "cannot get operand token" },
@@ -76,7 +76,7 @@ const char *objfile_name(const char *str)
 {
     const char *default_name = "a.o";
 
-    if(optarg == NULL) {
+    if(str == NULL) {
         return default_name;
     } else {
         return str;
index be3e58bf313738a80789669352ee956515c66c51..1aeb8c42c29ba3ab3b0813ebec91ae4f5f6c1f8f 100644 (file)
@@ -5,16 +5,14 @@ int cerrno = 0;
 char *cerrmsg;
 
 /* エラー番号とエラーメッセージを設定する */
-void setcerr(int num, const char *val)
+void setcerr(int num, const char *str)
 {
     assert(cerr != NULL && num > 0);
 
     cerrno = num;
-    cerrmsg = malloc(MSGSIZE + 1);
-    if(val != NULL) {
-        strcpy(cerrmsg, val);
-        strcat(cerrmsg, ": ");
-        strcat(cerrmsg, getcerrmsg(cerrno));
+    cerrmsg = malloc(CERRMSGSIZE + 1);
+    if(str != NULL && strlen(str) < 10) {
+        sprintf(cerrmsg, "%s: %s", str, getcerrmsg(cerrno));
     } else {
         strcpy(cerrmsg, getcerrmsg(cerrno));
     }
index ba26cf68475ace7c184772c920349a281fe94e06..a3fc2a061f294b802cbb4e86f40f6567ad473705 100644 (file)
@@ -17,7 +17,7 @@ static struct option longopts[] = {
 
 /* エラー番号とエラーメッセージ */
 CERRARRAY cerr[] = {
-    { 201, "execute - out of COMET II memory" },
+    { 201, "Load object file - full of COMET II memory" },
     { 202, "SVC input - out of Input memory" },
     { 203, "SVC output - out of COMET II memory" },
     { 204, "Program Register (PR) - out of COMET II memory" },
index 3ea2073ffa10102040a557eea3c6f7f102d84701..ec86ac5be48e7028a49cafc5588d973fb2eab350 100644 (file)
@@ -17,7 +17,7 @@ OPD *opdtok(const char *str)
     do {
         /* オペランド数が多すぎる場合はエラー */
         if(opd->opdc >= OPDSIZE) {
-            setcerr(117, str);    /* operand is too many */
+            setcerr(117, NULL);    /* operand is too many */
             break;
         }
         /* 先頭が「=」の場合の処理 */