mirror of
https://github.com/yasm/yasm
synced 2026-08-26 22:26:05 -04:00
tasm (tweaked nasm) preproc fixes:
- comments stripped before tokenization caused strings containing ';' to generate warnings (unterminated string) and incorrect output. - assume directive parsing did not properly handle ';' as end of line Also add tests for the above. Reported by: Rugxulo <rugxulo@gmail.com> svn path=/trunk/yasm/; revision=2197
This commit is contained in:
parent
88ffc99804
commit
bccb81d575
9 changed files with 46 additions and 12 deletions
|
|
@ -1,9 +1,11 @@
|
|||
# $Id$
|
||||
|
||||
EXTRA_DIST += modules/preprocs/tasm/Makefile.inc
|
||||
EXTRA_DIST += modules/preprocs/nasm/Makefile.inc
|
||||
EXTRA_DIST += modules/preprocs/raw/Makefile.inc
|
||||
EXTRA_DIST += modules/preprocs/cpp/Makefile.inc
|
||||
|
||||
include modules/preprocs/tasm/Makefile.inc
|
||||
include modules/preprocs/nasm/Makefile.inc
|
||||
include modules/preprocs/raw/Makefile.inc
|
||||
include modules/preprocs/cpp/Makefile.inc
|
||||
|
|
|
|||
|
|
@ -538,13 +538,10 @@ check_tasm_directive(char *line)
|
|||
char *p, *oldline, oldchar, *q, oldchar2;
|
||||
TMEndItem *end;
|
||||
|
||||
if ((p = strchr(line, ';')))
|
||||
*p = '\0';
|
||||
|
||||
p = line;
|
||||
|
||||
/* Skip whitespace */
|
||||
while (isspace(*p) && *p != 0)
|
||||
while (isspace(*p) && *p != 0 && *p != ';')
|
||||
p++;
|
||||
|
||||
/* Ignore nasm directives */
|
||||
|
|
@ -553,7 +550,7 @@ check_tasm_directive(char *line)
|
|||
|
||||
/* Binary search for the directive name */
|
||||
len = 0;
|
||||
while (!isspace(p[len]) && p[len] != 0)
|
||||
while (!isspace(p[len]) && p[len] != 0 && p[len] != ';')
|
||||
len++;
|
||||
if (!len)
|
||||
return line;
|
||||
|
|
@ -871,10 +868,10 @@ check_tasm_directive(char *line)
|
|||
/* Skip whitespaces */
|
||||
while (isspace(*q) && *q)
|
||||
q++;
|
||||
while (*q) {
|
||||
while (*q && *q != ';') {
|
||||
p = q;
|
||||
for (; *q && *q != ':' && !isspace(*q); q++);
|
||||
if (!*q)
|
||||
for (; *q && *q != ';' && *q != ':' && !isspace(*q); q++);
|
||||
if (!*q || *q == ';')
|
||||
break;
|
||||
/* segment register name */
|
||||
for (assume = TAssumes; assume->segreg; assume++)
|
||||
|
|
@ -888,20 +885,22 @@ check_tasm_directive(char *line)
|
|||
assume->segreg = nasm_strndup(p, q-p);
|
||||
assume[1].segreg = NULL;
|
||||
}
|
||||
for (; *q && *q != ':' && isspace(*q); q++);
|
||||
for (; *q && *q != ';' && *q != ':' && isspace(*q); q++);
|
||||
if (*q != ':')
|
||||
error(ERR_FATAL, "expected `:' instead of `%c'", *q);
|
||||
for (q++; *q && isspace(*q); q++);
|
||||
|
||||
/* segment name */
|
||||
p = q;
|
||||
for (; *q && *q != ',' && !isspace(*q); q++);
|
||||
for (; *q && *q != ';' && *q != ',' && !isspace(*q); q++);
|
||||
assume->segment = nasm_strndup(p, q-p);
|
||||
for (; *q && isspace(*q); q++);
|
||||
if (*q && *q != ',')
|
||||
if (*q && *q != ';' && *q != ',')
|
||||
error(ERR_FATAL, "expected `,' instead of `%c'", *q);
|
||||
|
||||
for (q++; *q && isspace(*q); q++);
|
||||
if (*q && *q != ';')
|
||||
q++;
|
||||
for (; *q && isspace(*q); q++);
|
||||
}
|
||||
TAssumes[i].segreg = NULL;
|
||||
TAssumes = nasm_realloc(TAssumes, (i+1)*sizeof(*TAssumes));
|
||||
|
|
|
|||
5
modules/preprocs/tasm/Makefile.inc
Normal file
5
modules/preprocs/tasm/Makefile.inc
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# $Id$
|
||||
|
||||
EXTRA_DIST += modules/preprocs/tasm/tests/Makefile.inc
|
||||
|
||||
include modules/preprocs/tasm/tests/Makefile.inc
|
||||
9
modules/preprocs/tasm/tests/Makefile.inc
Normal file
9
modules/preprocs/tasm/tests/Makefile.inc
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# $Id$
|
||||
|
||||
TESTS += modules/preprocs/tasm/tests/tasmpp_test.sh
|
||||
|
||||
EXTRA_DIST += modules/preprocs/tasm/tests/tasmpp_test.sh
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/tasm-assume-comment.asm
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/tasm-assume-comment.hex
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/tasm-comment-instr.asm
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/tasm-comment-instr.hex
|
||||
3
modules/preprocs/tasm/tests/tasm-assume-comment.asm
Normal file
3
modules/preprocs/tasm/tests/tasm-assume-comment.asm
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
assume cs:code,ds:code,es:code ; tiny model (CS=DS=ES)
|
||||
assume ds:code,es:code; close comment
|
||||
assume fs:code,gs:code
|
||||
0
modules/preprocs/tasm/tests/tasm-assume-comment.hex
Normal file
0
modules/preprocs/tasm/tests/tasm-assume-comment.hex
Normal file
1
modules/preprocs/tasm/tests/tasm-comment-instr.asm
Normal file
1
modules/preprocs/tasm/tests/tasm-comment-instr.asm
Normal file
|
|
@ -0,0 +1 @@
|
|||
ansi_normal db 0x27,'[0;40;37m$'
|
||||
11
modules/preprocs/tasm/tests/tasm-comment-instr.hex
Normal file
11
modules/preprocs/tasm/tests/tasm-comment-instr.hex
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
27
|
||||
5b
|
||||
30
|
||||
3b
|
||||
34
|
||||
30
|
||||
3b
|
||||
33
|
||||
37
|
||||
6d
|
||||
24
|
||||
4
modules/preprocs/tasm/tests/tasmpp_test.sh
Executable file
4
modules/preprocs/tasm/tests/tasmpp_test.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#! /bin/sh
|
||||
# $Id$
|
||||
${srcdir}/out_test.sh tasmpp_test modules/preprocs/tasm/tests "tasm preproc" "-f bin -p tasm" ""
|
||||
exit $?
|
||||
Loading…
Add table
Add a link
Reference in a new issue