アセンブル時のエラー表示について、方法を変更し、コード修正
authorj8takagi <j8takagi@nifty.com>
Wed, 10 Feb 2010 22:37:04 +0000 (07:37 +0900)
committerj8takagi <j8takagi@nifty.com>
Wed, 10 Feb 2010 22:37:04 +0000 (07:37 +0900)
src/assemble.c
test/integration/casl2/cmd_err0/0.txt
test/integration/casl2/cmd_err1/0.txt
test/integration/casl2/ds_err/0.txt
test/integration/casl2/labeldup_err/0.txt
test/integration/casl2/literalstr_err/0.txt
test/integration/casl2/opdspc_err/0.txt
test/integration/casl2/quoteend_err/0.txt

index 36edd2b..b9fbed7 100644 (file)
@@ -395,6 +395,10 @@ bool assembleline(const CMDLINE *cmdl, PASS pass)
     return status;
 }
 
     return status;
 }
 
+void printline(FILE *stream, const char *filename, int lineno, char *line) {
+    fprintf(stream, "%s:%5d:%s", filename, lineno, line);
+}
+
 /* 指定された名前のファイルをアセンブル */
 /* 2回実行される */
 bool assemble(const char *file, PASS pass)
 /* 指定された名前のファイルをアセンブル */
 /* 2回実行される */
 bool assemble(const char *file, PASS pass)
@@ -422,7 +426,7 @@ bool assemble(const char *file, PASS pass)
         if((pass == FIRST && (&asmode)->src == true) ||
            (pass == SECOND && (&asmode)->asdetail == true))
         {
         if((pass == FIRST && (&asmode)->src == true) ||
            (pass == SECOND && (&asmode)->asdetail == true))
         {
-            fprintf(stdout, "%s:%5d:%s", file, lineno, line);
+            printline(stdout, file, lineno, line);
         }
         if((cmdl = linetok(line)) != NULL) {
             if(pass == FIRST && cmdl->label != NULL) {
         }
         if((cmdl = linetok(line)) != NULL) {
             if(pass == FIRST && cmdl->label != NULL) {
@@ -439,7 +443,8 @@ bool assemble(const char *file, PASS pass)
         }
     }
     if(cerrno > 0) {
         }
     }
     if(cerrno > 0) {
-        fprintf(stderr, "Assemble error - %d: %s\n %s:%d: %s\n", cerrno, cerrmsg, file, lineno, line);
+        fprintf(stderr, "Assemble error - %d: %s\n", cerrno, cerrmsg);
+        printline(stderr, file, lineno, line);
         status = false;
     }
     fclose(fp);
         status = false;
     }
     fclose(fp);
index 711c1da..fd2ff24 100644 (file)
@@ -6,5 +6,4 @@ Assemble ../../../../as/ERR/cmd_err0.casl (0)
 ../../../../as/ERR/cmd_err0.casl:    3:        LAD     GR2,2
 ../../../../as/ERR/cmd_err0.casl:    4:        LEA     GR1,GR2
 Assemble error - 109: LEA: not command of operand "r1,r2"
 ../../../../as/ERR/cmd_err0.casl:    3:        LAD     GR2,2
 ../../../../as/ERR/cmd_err0.casl:    4:        LEA     GR1,GR2
 Assemble error - 109: LEA: not command of operand "r1,r2"
- ../../../../as/ERR/cmd_err0.casl:4:         LEA     GR1,GR2
-
+../../../../as/ERR/cmd_err0.casl:    4:        LEA     GR1,GR2
index 0c5569a..56921a4 100644 (file)
@@ -4,5 +4,4 @@ Assemble ../../../../as/ERR/cmd_err1.casl (0)
 ../../../../as/ERR/cmd_err1.casl:    1:MAIN    START   BEGIN
 ../../../../as/ERR/cmd_err1.casl:    2:BEGIN   LEA     GR1,A
 Assemble error - 110: LEA: not command of operand "r,adr[,x]"
 ../../../../as/ERR/cmd_err1.casl:    1:MAIN    START   BEGIN
 ../../../../as/ERR/cmd_err1.casl:    2:BEGIN   LEA     GR1,A
 Assemble error - 110: LEA: not command of operand "r,adr[,x]"
- ../../../../as/ERR/cmd_err1.casl:2: BEGIN   LEA     GR1,A
-
+../../../../as/ERR/cmd_err1.casl:    2:BEGIN   LEA     GR1,A
index 908ba09..211dc12 100644 (file)
@@ -6,5 +6,4 @@ Assemble ../../../../as/ERR/ds_err.casl (0)
 ../../../../as/ERR/ds_err.casl:    3:        ST      GR0,A
 ../../../../as/ERR/ds_err.casl:    4:A       DS
 Assemble error - 106: operand count mismatch
 ../../../../as/ERR/ds_err.casl:    3:        ST      GR0,A
 ../../../../as/ERR/ds_err.casl:    4:A       DS
 Assemble error - 106: operand count mismatch
- ../../../../as/ERR/ds_err.casl:4: A       DS
-
+../../../../as/ERR/ds_err.casl:    4:A       DS
index ea2931f..9725887 100644 (file)
@@ -8,5 +8,4 @@ Assemble ../../../../as/ERR/labeldup_err.casl (0)
 ../../../../as/ERR/labeldup_err.casl:    5:A       DC      3
 ../../../../as/ERR/labeldup_err.casl:    6:A       DC      1
 Assemble error - 101: A: label already defined
 ../../../../as/ERR/labeldup_err.casl:    5:A       DC      3
 ../../../../as/ERR/labeldup_err.casl:    6:A       DC      1
 Assemble error - 101: A: label already defined
- ../../../../as/ERR/labeldup_err.casl:6: A       DC      1
-
+../../../../as/ERR/labeldup_err.casl:    6:A       DC      1
index 755d174..d84ce53 100644 (file)
@@ -2,5 +2,4 @@
 
 Assemble ../../../../as/ERR/literalstr_err.casl (0)
 Assemble error - 124: 'abcdeABCDE': more than one character in literal
 
 Assemble ../../../../as/ERR/literalstr_err.casl (0)
 Assemble error - 124: 'abcdeABCDE': more than one character in literal
- ../../../../as/ERR/literalstr_err.casl:2:         LAD     GR1,='abcdeABCDE'
-
+../../../../as/ERR/literalstr_err.casl:    2:        LAD     GR1,='abcdeABCDE'
index e1a99b5..fca7140 100644 (file)
@@ -4,5 +4,4 @@ Assemble ../../../../as/ERR/opdspc_err.casl (0)
 ../../../../as/ERR/opdspc_err.casl:    1:MAIN    START   BEGIN
 ../../../../as/ERR/opdspc_err.casl:    2:BEGIN   LD      GR1, A
 Assemble error - 121: cannot get operand token
 ../../../../as/ERR/opdspc_err.casl:    1:MAIN    START   BEGIN
 ../../../../as/ERR/opdspc_err.casl:    2:BEGIN   LD      GR1, A
 Assemble error - 121: cannot get operand token
- ../../../../as/ERR/opdspc_err.casl:2: BEGIN   LD      GR1, A
-
+../../../../as/ERR/opdspc_err.casl:    2:BEGIN   LD      GR1, A
index 8c19446..53e03fe 100644 (file)
@@ -2,5 +2,4 @@
 
 Assemble ../../../../as/ERR/quoteend_err.casl (0)
 Assemble error - 123: 'Hello, World!: unclosed quote
 
 Assemble ../../../../as/ERR/quoteend_err.casl (0)
 Assemble error - 123: 'Hello, World!: unclosed quote
- ../../../../as/ERR/quoteend_err.casl:4: BUF      DC     'Hello, World!
-
+../../../../as/ERR/quoteend_err.casl:    4:BUF      DC     'Hello, World!