From: j8takagi Date: Wed, 10 Feb 2010 22:37:04 +0000 (+0900) Subject: アセンブル時のエラー表示について、方法を変更し、コード修正 X-Git-Tag: v0.1~51 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04a3118439bbcea335da98764406256d10be78f5;p=YACASL2.git アセンブル時のエラー表示について、方法を変更し、コード修正 --- diff --git a/src/assemble.c b/src/assemble.c index 36edd2b..b9fbed7 100644 --- a/src/assemble.c +++ b/src/assemble.c @@ -395,6 +395,10 @@ bool assembleline(const CMDLINE *cmdl, PASS pass) 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) @@ -422,7 +426,7 @@ bool assemble(const char *file, PASS pass) 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) { @@ -439,7 +443,8 @@ bool assemble(const char *file, PASS pass) } } 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); diff --git a/test/integration/casl2/cmd_err0/0.txt b/test/integration/casl2/cmd_err0/0.txt index 711c1da..fd2ff24 100644 --- a/test/integration/casl2/cmd_err0/0.txt +++ b/test/integration/casl2/cmd_err0/0.txt @@ -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:4: LEA GR1,GR2 - +../../../../as/ERR/cmd_err0.casl: 4: LEA GR1,GR2 diff --git a/test/integration/casl2/cmd_err1/0.txt b/test/integration/casl2/cmd_err1/0.txt index 0c5569a..56921a4 100644 --- a/test/integration/casl2/cmd_err1/0.txt +++ b/test/integration/casl2/cmd_err1/0.txt @@ -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:2: BEGIN LEA GR1,A - +../../../../as/ERR/cmd_err1.casl: 2:BEGIN LEA GR1,A diff --git a/test/integration/casl2/ds_err/0.txt b/test/integration/casl2/ds_err/0.txt index 908ba09..211dc12 100644 --- a/test/integration/casl2/ds_err/0.txt +++ b/test/integration/casl2/ds_err/0.txt @@ -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:4: A DS - +../../../../as/ERR/ds_err.casl: 4:A DS diff --git a/test/integration/casl2/labeldup_err/0.txt b/test/integration/casl2/labeldup_err/0.txt index ea2931f..9725887 100644 --- a/test/integration/casl2/labeldup_err/0.txt +++ b/test/integration/casl2/labeldup_err/0.txt @@ -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:6: A DC 1 - +../../../../as/ERR/labeldup_err.casl: 6:A DC 1 diff --git a/test/integration/casl2/literalstr_err/0.txt b/test/integration/casl2/literalstr_err/0.txt index 755d174..d84ce53 100644 --- a/test/integration/casl2/literalstr_err/0.txt +++ b/test/integration/casl2/literalstr_err/0.txt @@ -2,5 +2,4 @@ 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' diff --git a/test/integration/casl2/opdspc_err/0.txt b/test/integration/casl2/opdspc_err/0.txt index e1a99b5..fca7140 100644 --- a/test/integration/casl2/opdspc_err/0.txt +++ b/test/integration/casl2/opdspc_err/0.txt @@ -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:2: BEGIN LD GR1, A - +../../../../as/ERR/opdspc_err.casl: 2:BEGIN LD GR1, A diff --git a/test/integration/casl2/quoteend_err/0.txt b/test/integration/casl2/quoteend_err/0.txt index 8c19446..53e03fe 100644 --- a/test/integration/casl2/quoteend_err/0.txt +++ b/test/integration/casl2/quoteend_err/0.txt @@ -2,5 +2,4 @@ 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!