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:
Peter Johnson 2009-04-17 03:25:08 +00:00
parent 88ffc99804
commit bccb81d575
9 changed files with 46 additions and 12 deletions

View file

@ -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

View file

@ -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));

View file

@ -0,0 +1,5 @@
# $Id$
EXTRA_DIST += modules/preprocs/tasm/tests/Makefile.inc
include modules/preprocs/tasm/tests/Makefile.inc

View 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

View 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

View file

@ -0,0 +1 @@
ansi_normal db 0x27,'[0;40;37m$'

View file

@ -0,0 +1,11 @@
27
5b
30
3b
34
30
3b
33
37
6d
24

View 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 $?