mirror of
https://github.com/fachat/xa65.git
synced 2025-04-08 18:37:12 +00:00
merged xa-2.3.14 into listing
This commit is contained in:
commit
20503e34a7
14
xa/ChangeLog
14
xa/ChangeLog
@ -383,6 +383,20 @@ xa-2.3.13
|
||||
|
||||
-- Cameron Kaiser <ckaiser@floodgap.com> 25 March 2022
|
||||
|
||||
xa-2.3.14
|
||||
|
||||
* Fix a segfault when a recursive macro has a smaller arity than the
|
||||
macro it references (thanks Emil Johansson for the report).
|
||||
* Fix for recursive comments, which was a regression from 2.3.13 (note:
|
||||
this may be reexamined for 2.4), and some improvements to the comment
|
||||
parser to fix more edge cases. (Andre)
|
||||
* Now you can just do 'make test TESTS=test,test,test' instead of running
|
||||
./tests/harness with specific options. ('make test' by itself of course
|
||||
still works fine to run the whole suite.)
|
||||
* Testsuite expanded.
|
||||
|
||||
-- Cameron Kaiser <ckaiser@floodgap.com> 7 February 2023
|
||||
|
||||
xa-2.x.x
|
||||
|
||||
* Listing feature
|
||||
|
13
xa/Makefile
13
xa/Makefile
@ -4,7 +4,8 @@ CC = gcc
|
||||
LD = gcc
|
||||
# for testing. not to be used; build failures in misc/.
|
||||
#CFLAGS = -O2 -W -Wall -pedantic -ansi
|
||||
CFLAGS = -O2
|
||||
#CFLAGS = -O2 -g
|
||||
CFLAGS = -O2
|
||||
LDFLAGS = -lc
|
||||
|
||||
# for DOS?
|
||||
@ -26,6 +27,8 @@ DOCDIR = $(DESTDIR)/share/doc
|
||||
MKDIR = mkdir -p
|
||||
INSTALL = install
|
||||
|
||||
TESTS=ALL
|
||||
|
||||
all: killxa xa uncpk
|
||||
|
||||
killxa:
|
||||
@ -53,7 +56,7 @@ clean:
|
||||
(cd src && ${MAKE} clean)
|
||||
(cd loader && ${MAKE} clean)
|
||||
(cd misc && ${MAKE} mrproper)
|
||||
rm -f xa *.exe *.o65 *.s
|
||||
rm -f xa *.exe *.o65 *.s core
|
||||
|
||||
install: xa uncpk
|
||||
$(MKDIR) $(BINDIR)
|
||||
@ -63,7 +66,9 @@ install: xa uncpk
|
||||
#$(MKDIR) $(DOCDIR)/xa65
|
||||
|
||||
dist: clean
|
||||
cd .. ; tar cvf xa-2.3.13.tar xa-2.3.13 ; gzip xa-2.3.13.tar
|
||||
cd .. ; tar cvf xa-2.3.14.tar xa-2.3.14 ; gzip xa-2.3.14.tar
|
||||
|
||||
test: xa uncpk
|
||||
cd tests && ./harness -make="$(MAKE)" -cc="$(CC)" -cflags="$(CFLAGS)"
|
||||
cd tests && ./harness \
|
||||
-tests="$(TESTS)" \
|
||||
-make="$(MAKE)" -cc="$(CC)" -cflags="$(CFLAGS)"
|
||||
|
@ -51,7 +51,7 @@ Show version of program.
|
||||
This manual page was written by David Weinehall <tao@acc.umu.se>
|
||||
and Cameron Kaiser <ckaiser@floodgap.com>.
|
||||
Original xa package (C)1989-1997 Andre Fachat. Additional changes
|
||||
(C)1989-2006 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
(C)1989-2023 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
Cameron Kaiser. The current maintainer is Cameron Kaiser.
|
||||
|
||||
.SH WEBSITE
|
||||
|
@ -53,7 +53,7 @@ Show version of program.
|
||||
This manual page was written by David Weinehall <tao@acc.umu.se>
|
||||
and Cameron Kaiser <ckaiser@floodgap.com>.
|
||||
Original xa package (C)1989-1997 Andre Fachat. Additional changes
|
||||
(C)1989-2006 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
(C)1989-2023 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
Cameron Kaiser. The current maintainer is Cameron Kaiser.
|
||||
|
||||
.SH WEBSITE
|
||||
|
@ -30,7 +30,7 @@ Show version of program.
|
||||
.SH AUTHOR
|
||||
This manual page was written by David Weinehall <tao@acc.umu.se>.
|
||||
Original xa package (C)1989-1997 Andre Fachat. Additional changes
|
||||
(C)1989-2006 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
(C)1989-2023 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
Cameron Kaiser. The current maintainer is Cameron Kaiser.
|
||||
|
||||
.SH WEBSITE
|
||||
|
@ -62,7 +62,7 @@ Show version of program.
|
||||
This manual page was written by David Weinehall <tao@acc.umu.se>
|
||||
and Cameron Kaiser <ckaiser@floodgap.com>.
|
||||
Original xa package (C)1989-1997 Andre Fachat. Additional changes
|
||||
(C)1989-2006 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
(C)1989-2023 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
Cameron Kaiser. The current maintainer is Cameron Kaiser.
|
||||
|
||||
.SH WEBSITE
|
||||
|
@ -70,7 +70,7 @@ List contents of archive
|
||||
This manual page was written by David Weinehall <tao@acc.umu.se>
|
||||
and Cameron Kaiser <ckaiser@floodgap.com>.
|
||||
Original xa package (C)1989-1997 Andre Fachat. Additional changes
|
||||
(C)1989-2006 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
(C)1989-2023 Andre Fachat, Jolse Maginnis, David Weinehall and
|
||||
Cameron Kaiser. The current maintainer is Cameron Kaiser.
|
||||
|
||||
.SH WEBSITE
|
||||
|
@ -1041,7 +1041,7 @@ This manual page was written by David Weinehall <tao@acc.umu.se>,
|
||||
Andre Fachat <fachat@web.de>
|
||||
and Cameron Kaiser <ckaiser@floodgap.com>.
|
||||
Original xa package (C)1989-1997 Andre Fachat. Additional changes
|
||||
(C)1989-2021 Andre Fachat, Jolse Maginnis, David Weinehall,
|
||||
(C)1989-2023 Andre Fachat, Jolse Maginnis, David Weinehall,
|
||||
Cameron Kaiser. The official maintainer is Cameron Kaiser.
|
||||
|
||||
.SH 30 YEARS OF XA
|
||||
|
@ -56,9 +56,9 @@
|
||||
#define ANZWARN 13
|
||||
|
||||
#define programname "xa"
|
||||
#define progversion "v2.3.13+af"
|
||||
#define progversion "v2.3.14+af"
|
||||
#define authors "Written by Andre Fachat, Jolse Maginnis, David Weinehall and Cameron Kaiser"
|
||||
#define copyright "Copyright (C) 1989-2022 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser."
|
||||
#define copyright "Copyright (C) 1989-2023 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser."
|
||||
|
||||
/* exported globals */
|
||||
int ncmos, cmosfl, w65816, n65816;
|
||||
|
204
xa/src/xap.c
204
xa/src/xap.c
@ -61,7 +61,6 @@ static int pp_undef(char*);
|
||||
#define ANZBEF 13
|
||||
#define VALBEF 6
|
||||
|
||||
static int ungeteof = 0;
|
||||
static int quotebs = 0;
|
||||
static int inquote = 0;
|
||||
|
||||
@ -632,6 +631,12 @@ static int pp_replace_part(char *to, char *t, int n, int sl, int recursive, int
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// catch an error situation
|
||||
if (liste[rlist+i].replace == NULL) {
|
||||
errout(E_ANZPAR);
|
||||
return E_ANZPAR;
|
||||
}
|
||||
|
||||
// copy over the replacement string into free memory (using mx as pointer)
|
||||
(void)strcpy(mx, nfto);
|
||||
// replace the pointer to the (now obsolete) old replacement with the one we just created
|
||||
@ -1078,39 +1083,6 @@ int pgetline(char *t)
|
||||
errout(E_OPENPP);
|
||||
}
|
||||
|
||||
/* handle the double-slash comment (like in C++) */
|
||||
/* get p past any quoted strings */
|
||||
p = strchr(in_line, '/');
|
||||
if (p != NULL) {
|
||||
q = strchr(in_line, '"');
|
||||
for(;;) {
|
||||
/* no more quotes to skip, or slashes before quotes */
|
||||
if (q == NULL || (p < q)) {
|
||||
if (p[1] == '/') {
|
||||
/* truncate line, done with loop */
|
||||
*p = 0;
|
||||
break;
|
||||
} else {
|
||||
/* wasn't //, but could be later */
|
||||
p++;
|
||||
}
|
||||
} else {
|
||||
/* quote before slash, so skip string */
|
||||
q++;
|
||||
while (*q != 0 && *q != '"') {
|
||||
if (*q == '\\') q++;
|
||||
if (*q != 0) q++;
|
||||
}
|
||||
if (*q == 0) break; /* oops */
|
||||
q++;
|
||||
p = q;
|
||||
}
|
||||
|
||||
p = strchr(p, '/');
|
||||
if (p == NULL) break; /* never mind */
|
||||
if (q != NULL) q = strchr(q, '"');
|
||||
}
|
||||
}
|
||||
|
||||
if(!er || loopfl) {
|
||||
in_line[0]='\0';
|
||||
@ -1143,79 +1115,123 @@ int pgetline(char *t)
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* this is the most disgusting code I have ever written, but Andre drove me
|
||||
to it because I can't think of any other way to fix the
|
||||
last line bug ... a very irritated Cameron */
|
||||
|
||||
/* however, it also solved the problem of open #ifdefs not bugging out */
|
||||
|
||||
/* #define DEBUG_EGETC */
|
||||
int egetc(FILE *fp) {
|
||||
int c;
|
||||
|
||||
c = getc(fp);
|
||||
if (c == EOF) {
|
||||
if (ungeteof) {
|
||||
#ifdef DEBUG_EGETC
|
||||
fprintf(stderr, "eof claimed\n");
|
||||
#endif
|
||||
return c;
|
||||
} else {
|
||||
#ifdef DEBUG_EGETC
|
||||
fprintf(stderr, "got eof!!\n");
|
||||
#endif
|
||||
ungeteof = 1;
|
||||
return '\n';
|
||||
}
|
||||
}
|
||||
ungeteof = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
/* smart getc that can skip C comment blocks */
|
||||
int rgetc(FILE *fp)
|
||||
{
|
||||
static int c,cc,d,fl;
|
||||
cc=0;
|
||||
fl=0;
|
||||
int incomment;
|
||||
int c;
|
||||
static int d;
|
||||
static int d_isvalid = 0;
|
||||
static int last = 0;
|
||||
|
||||
incomment=0;
|
||||
|
||||
do
|
||||
{
|
||||
while((c=egetc(fp))==13); /* remove ^M for unices */
|
||||
restart:
|
||||
|
||||
/* flag if we're in a quoted string */
|
||||
if(c=='"' && !quotebs) inquote ^= 1;
|
||||
#if(0)
|
||||
/* implement backslashed quotes for 2.4 */
|
||||
if(c=='\\') quotebs=1; else quotebs=0;
|
||||
#endif
|
||||
/* we had a look-ahead to see if two-char sequence was received? */
|
||||
if (d_isvalid) {
|
||||
c = d;
|
||||
d_isvalid = 0;
|
||||
} else {
|
||||
c = getc(fp);
|
||||
}
|
||||
while(c==13) {
|
||||
c = getc(fp);
|
||||
}; /* remove ^M for unices */
|
||||
|
||||
if(!inquote && fl && (c=='*'))
|
||||
{
|
||||
if((d=egetc(fp))!='/')
|
||||
ungetc(d,fp);
|
||||
else
|
||||
{
|
||||
fl--;
|
||||
while((c=egetc(fp))==13);
|
||||
}
|
||||
}
|
||||
/* a newlinebreaks any quote */
|
||||
if (c == '\n') {
|
||||
inquote = 0;
|
||||
|
||||
/* in comment block */
|
||||
if(c=='\n')
|
||||
{
|
||||
flist[fsp].fline++;
|
||||
nlf=1;
|
||||
} else
|
||||
flist[fsp].fline++;
|
||||
nlf=1;
|
||||
}
|
||||
|
||||
/* check for start of comment anyway, to allow for nestesd comments */
|
||||
if(!inquote && c=='/')
|
||||
{
|
||||
if((d=egetc(fp))!='*')
|
||||
ungetc(d,fp);
|
||||
else
|
||||
fl++;
|
||||
d = getc(fp);
|
||||
|
||||
// C++ double slash comment
|
||||
if (d == '/') {
|
||||
do {
|
||||
c = getc(fp);
|
||||
} while (c != '\n' && c != EOF);
|
||||
} else
|
||||
if (d == '*') {
|
||||
/* start block comment */
|
||||
incomment++;
|
||||
/* convene normal processing */
|
||||
goto restart;
|
||||
} else {
|
||||
d_isvalid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
} while(fl && (c!=EOF));
|
||||
|
||||
/* here we are in a dilemma. If we interpret quotes in comments,
|
||||
* this may break end-of-block comment when singular quotes are
|
||||
* in a comment. If we don't interpret quotes in a comment,
|
||||
* a quoted string with end-of-comment in it may break when
|
||||
* commented.
|
||||
*
|
||||
* Unfortunately GeckOS has quotes in comments, and in an inconsistent way.
|
||||
*
|
||||
* #define E_FILLNAM <-34 / * illegal name (joker "*","?","\"") * /
|
||||
*
|
||||
* ... except if we handle backslash-escaped quotes? No, then this breaks
|
||||
* in apps/lsh/lsh.a65:347
|
||||
*
|
||||
* / * TODO: interpret "\" escape codes, shell variables * /
|
||||
*
|
||||
* But I guess for 2.4 it is ok to break things like this.
|
||||
*/
|
||||
|
||||
if (!incomment) {
|
||||
/* not in comment */
|
||||
|
||||
/* flag if we're in a quoted string */
|
||||
/* but only if quote isnot escaped with backslash */
|
||||
if(c=='"' && last!='\\' && !quotebs) {
|
||||
inquote ^= 1;
|
||||
}
|
||||
|
||||
#if(0)
|
||||
/* implement backslashed quotes for 2.4 */
|
||||
if(c=='\\') quotebs=1; else quotebs=0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
/* in comment */
|
||||
|
||||
/* check for end of comment */
|
||||
/* note: incomment only set true if not quoted, and quote not changed in comment */
|
||||
if((!inquote) && (c=='*'))
|
||||
{
|
||||
if((d=getc(fp))!='/') {
|
||||
d_isvalid = 1;
|
||||
} else {
|
||||
incomment--;
|
||||
/* convene normal processing */
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* force newline at the end of a file */
|
||||
if (c == EOF && last != EOF) {
|
||||
last = EOF;
|
||||
c = '\n';
|
||||
} else {
|
||||
last = c;
|
||||
}
|
||||
|
||||
} while(incomment && (c!=EOF));
|
||||
|
||||
return(c-'\t'?c:' ');
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ linkr/ Test linking using .dsb and generated code
|
||||
csapiec/ Test on pointer arithmetic in relocating mode
|
||||
math/ Math tests (currently divide by zero, thanks Frederic Cambus)
|
||||
alxl/ Various '816 width tests (includes Samuel Falvo's test)
|
||||
pparity/ Tests of preprocessor macro arity (with Emil Johansson's test)
|
||||
recucom/ Recursive comments test
|
||||
|
||||
Cameron Kaiser, André Fachat
|
||||
|
||||
|
@ -8,7 +8,9 @@ $ENV{'CC'} = $cc;
|
||||
$ENV{'CFLAGS'} = $cflags;
|
||||
$|++;
|
||||
|
||||
$ntests = 0;
|
||||
$dtests = $tests || "ALL";
|
||||
$tests = '' if ($tests eq "ALL");
|
||||
|
||||
print <<"EOF";
|
||||
CC = $cc
|
||||
@ -43,12 +45,14 @@ W: while($x = readdir(D)) {
|
||||
}
|
||||
system("$make clean");
|
||||
print STDOUT "=" x 35, " PASSED! ", "=" x 35, "\n";
|
||||
$ntests++;
|
||||
} elsif (-e "ok" && -e "test.s") {
|
||||
unlink("a.o65");
|
||||
&failed("../../xa test.s");
|
||||
&failed("../hextool -cmp=ok < a.o65");
|
||||
unlink("a.o65");
|
||||
print STDOUT "PASSED\n";
|
||||
$ntests++;
|
||||
} else {
|
||||
print STDOUT "ignored\n";
|
||||
}
|
||||
@ -56,8 +60,12 @@ W: while($x = readdir(D)) {
|
||||
}
|
||||
closedir(D);
|
||||
print STDOUT "=" x 79, "\n";
|
||||
print STDOUT "\n## ALL TESTS PASS ##\n";
|
||||
exit 0;
|
||||
if ($ntests) { # ntestacy is a terrible thing
|
||||
print STDOUT "\n## ALL SELECTED TESTS PASS ($dtests, n=$ntests) ##\n";
|
||||
exit 0;
|
||||
}
|
||||
print STDOUT "\n## NO TESTS WERE RUN ##\n";
|
||||
exit 1;
|
||||
|
||||
sub failed {
|
||||
system(@_);
|
||||
|
12
xa/tests/pparity/Makefile
Normal file
12
xa/tests/pparity/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
default:
|
||||
# xa should not allow this to happen. if it does, this test is no good.
|
||||
../../xa bad.s || exit 0 && exit 1
|
||||
../../xa bad2.s || exit 0 && exit 1
|
||||
../../xa bad3.s || exit 0 && exit 1
|
||||
../../xa bad4.s || exit 0 && exit 1
|
||||
# expected-to-fail tests did fail. should be no more errors now.
|
||||
../../xa good.s -o good.o
|
||||
../hextool -cmp=good.ok < good.o
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
3
xa/tests/pparity/bad.s
Normal file
3
xa/tests/pparity/bad.s
Normal file
@ -0,0 +1,3 @@
|
||||
#define FOO(a,b)
|
||||
#define BAR(c) FOO(c)
|
||||
|
3
xa/tests/pparity/bad2.s
Normal file
3
xa/tests/pparity/bad2.s
Normal file
@ -0,0 +1,3 @@
|
||||
#define FOO(a,b,c)
|
||||
#define BAR(b,c) FOO(b,c)
|
||||
|
10
xa/tests/pparity/bad3.s
Normal file
10
xa/tests/pparity/bad3.s
Normal file
@ -0,0 +1,10 @@
|
||||
#define FOO(a,b,c)
|
||||
#define BAR(a,b,c) FOO(c,b,a)
|
||||
|
||||
#define FOO(a,b,c)
|
||||
#define BAR(b,c) FOO("x",b,c)
|
||||
|
||||
#define FOO(a,b,c) .byt a,b,c
|
||||
#define BAR(c) FOO("1", "2", c)
|
||||
|
||||
FOO("3")
|
4
xa/tests/pparity/bad4.s
Normal file
4
xa/tests/pparity/bad4.s
Normal file
@ -0,0 +1,4 @@
|
||||
#define FOO(a)
|
||||
#define BAR(c) FOO(c,a)
|
||||
|
||||
BAR(1, 2)
|
1
xa/tests/pparity/good.ok
Normal file
1
xa/tests/pparity/good.ok
Normal file
@ -0,0 +1 @@
|
||||
123
|
10
xa/tests/pparity/good.s
Normal file
10
xa/tests/pparity/good.s
Normal file
@ -0,0 +1,10 @@
|
||||
#define FOO(a,b,c)
|
||||
#define BAR(a,b,c) FOO(c,b,a)
|
||||
|
||||
#define FOO(a,b,c)
|
||||
#define BAR(b,c) FOO("x",b,c)
|
||||
|
||||
#define FOO(a,b,c) .byt a,b,c
|
||||
#define BAR(c) FOO("1", "2", c)
|
||||
|
||||
BAR("3")
|
BIN
xa/tests/recucom/ok
Normal file
BIN
xa/tests/recucom/ok
Normal file
Binary file not shown.
33
xa/tests/recucom/test.s
Normal file
33
xa/tests/recucom/test.s
Normal file
@ -0,0 +1,33 @@
|
||||
*=$1000
|
||||
|
||||
lda #0
|
||||
|
||||
; recursive comments (may / should?) go away with 2.4
|
||||
|
||||
/*
|
||||
sta $2000
|
||||
/* commented
|
||||
lda #1
|
||||
*/
|
||||
*/
|
||||
|
||||
; C++ comments
|
||||
|
||||
// sta $2001
|
||||
|
||||
|
||||
; quotes in comments
|
||||
|
||||
lda #2 /* this is '$' */
|
||||
lda #3 /* this is "$" */
|
||||
lda #4 /* this is "\"" */
|
||||
lda #5 /* this is '"' */
|
||||
|
||||
; examples in preprocessor statements
|
||||
|
||||
#define E_ILLNAM <-34 /* illegal name (joker "*", "?", "\"") */
|
||||
|
||||
/* TODO: interpret "\" escape codes, shell variables */
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user