diff --git a/xa/Makefile b/xa/Makefile index 78ca224..92a1610 100644 --- a/xa/Makefile +++ b/xa/Makefile @@ -2,7 +2,7 @@ # CC = gcc LD = gcc -CFLAGS = -O2 -W -Wall -pedantic -ansi +CFLAGS = -O2 -W -Wall -pedantic -std=c99 -g LDFLAGS = -lc # for DOS? diff --git a/xa/src/xap.c b/xa/src/xap.c index da8e3c3..a261a5d 100644 --- a/xa/src/xap.c +++ b/xa/src/xap.c @@ -214,13 +214,20 @@ int pp_endif(char *t) /* stub for handling CPP directives */ int pp_cpp(char *t) { - if(sscanf(t, " %d \"%s\"", &filep->fline, filep->fname) == 2) { + char *fname = NULL; + if(sscanf(t, " %d \"%ms\"", &filep->fline, &fname) == 2) { /* massage it into our parameters and drop last quote */ char *u = ""; filep->fline--; - if((u = (char *)strrchr(filep->fname, '"'))) + if((u = (char *)strrchr(fname, '"'))) *u = '\0'; + + // overwrite the original filename + // this may create a memory leak, but we do not know + // whether the file name has already been used in the cross + // reference list. So we just accept that... + filep->fname = fname; return (0); } else { return(E_SYNTAX); diff --git a/xa/tests/cpp/over.asm b/xa/tests/cpp/over.asm index c8cc252..96598e4 100644 --- a/xa/tests/cpp/over.asm +++ b/xa/tests/cpp/over.asm @@ -1,32 +1,22 @@ # 1 "over.c" - - - - - - - - - - - - - lda #1 - jmp buggy - rts +# 1 "" +# 1 "/usr/include/stdc-predef.h" 1 3 4 +# 1 "" 2 +# 1 "over.c" +# 13 "over.c" + lda #1 + jmp buggy + rts # 1 "over.h" 1 -fuzz lda #5 - sta $0400 - bne fuzz - rts +fuzz lda #5 + sta $0400 + bne fuzz + rts - lda @$c0c0c0 -# 17 "over.c" 2 - - - + lda @$c0c0c0 +# 18 "over.c" 2