From 5d66d3a11a0917febab9a7529d66634c8e85e77f Mon Sep 17 00:00:00 2001 From: Andre Fachat Date: Sun, 27 Mar 2022 22:57:02 +0200 Subject: [PATCH 1/2] update to official xa-2.3.12 --- xa/Makefile | 2 +- xa/man/xa.1 | 6 +++--- xa/src/xa.c | 4 ++-- xa/src/xat.c | 23 +++++++++++------------ xa/tests/README | 1 + xa/tests/alxl/Makefile | 24 ++++++++++++++++++++++++ xa/tests/alxl/alxl.ok | 1 + xa/tests/alxl/alxl.s | 13 +++++++++++++ xa/tests/alxl/alxlo1.ok | 1 + xa/tests/alxl/alxlo1.s | 10 ++++++++++ xa/tests/alxl/alxlo2.ok | 1 + xa/tests/alxl/alxlo2.s | 10 ++++++++++ xa/tests/alxl/alxlx1.s | 12 ++++++++++++ xa/tests/alxl/alxlx2.s | 11 +++++++++++ xa/tests/alxl/alxlx3.s | 10 ++++++++++ xa/tests/alxl/sizes.ok | Bin 0 -> 30 bytes xa/tests/alxl/sizes.s | 22 ++++++++++++++++++++++ 17 files changed, 133 insertions(+), 18 deletions(-) create mode 100644 xa/tests/alxl/Makefile create mode 100644 xa/tests/alxl/alxl.ok create mode 100644 xa/tests/alxl/alxl.s create mode 100644 xa/tests/alxl/alxlo1.ok create mode 100644 xa/tests/alxl/alxlo1.s create mode 100644 xa/tests/alxl/alxlo2.ok create mode 100644 xa/tests/alxl/alxlo2.s create mode 100644 xa/tests/alxl/alxlx1.s create mode 100644 xa/tests/alxl/alxlx2.s create mode 100644 xa/tests/alxl/alxlx3.s create mode 100644 xa/tests/alxl/sizes.ok create mode 100644 xa/tests/alxl/sizes.s diff --git a/xa/Makefile b/xa/Makefile index 5da23e1..7bbfd64 100644 --- a/xa/Makefile +++ b/xa/Makefile @@ -63,7 +63,7 @@ install: xa uncpk #$(MKDIR) $(DOCDIR)/xa65 dist: clean - cd .. ; tar cvf xa-2.3.11.tar xa-2.3.11 ; gzip xa-2.3.11.tar + cd .. ; tar cvf xa-2.3.12.tar xa-2.3.12 ; gzip xa-2.3.12.tar test: xa uncpk cd tests && ./harness -make="$(MAKE)" -cc="$(CC)" -cflags="$(CFLAGS)" diff --git a/xa/man/xa.1 b/xa/man/xa.1 index 9032ad8..5b060e3 100644 --- a/xa/man/xa.1 +++ b/xa/man/xa.1 @@ -1,4 +1,4 @@ -.TH XA "1" "9 November 2019" +.TH XA "1" "24 November 2021" .SH NAME xa \- 6502/R65C02/65816 cross-assembler @@ -298,7 +298,7 @@ shift right (8) .B >= => greater than or equal to (7) .TP -.B < +.B > greater than (7) .TP .B <= =< @@ -982,7 +982,7 @@ This manual page was written by David Weinehall , Andre Fachat and Cameron Kaiser . Original xa package (C)1989-1997 Andre Fachat. Additional changes -(C)1989-2019 Andre Fachat, Jolse Maginnis, David Weinehall, +(C)1989-2021 Andre Fachat, Jolse Maginnis, David Weinehall, Cameron Kaiser. The official maintainer is Cameron Kaiser. .SH 30 YEARS OF XA diff --git a/xa/src/xa.c b/xa/src/xa.c index ca9f0f5..0595708 100644 --- a/xa/src/xa.c +++ b/xa/src/xa.c @@ -55,9 +55,9 @@ #define ANZWARN 13 #define programname "xa" -#define progversion "v2.3.11" +#define progversion "v2.3.12" #define authors "Written by Andre Fachat, Jolse Maginnis, David Weinehall and Cameron Kaiser" -#define copyright "Copyright (C) 1989-2020 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." +#define copyright "Copyright (C) 1989-2021 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." /* exported globals */ int ncmos, cmosfl, w65816, n65816; diff --git a/xa/src/xat.c b/xa/src/xat.c index 6f46ee7..6da4dd7 100644 --- a/xa/src/xat.c +++ b/xa/src/xat.c @@ -139,8 +139,8 @@ static int ktp[]={ 0,3,17,25,28,29,29,29,29,32,34,34,38,40,41,42,58, * opcodes for each addressing mode * high byte: supported architecture (no bits = original NMOS 6502) * bit 1: R65C02 - * bit 2: 65816 - * bit 3: 65816 and allows 16-bit quantity (immediate only) + * bit 2: 65816 and allows 16-bit quantity (accum only) + * bit 3: 65816 and allows 16-bit quantity (index only) * low byte: opcode itself * * each opcode is indexed in this order: *=65816, ^=R65C02 @@ -1430,8 +1430,8 @@ fprintf(stderr, "Kdsb E_DSB %i\n", j); { #ifdef DEBUG_AM fprintf(stderr, -"b4: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %u, er=%d\n", - pc[segment], am, vv[0], fl, (vv[0]&0xffff00), er); +"b4: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %u, er=%d, bl=%d\n", + pc[segment], am, vv[0], fl, (vv[0]&0xffff00), er, bl); #endif /* terrible KLUDGE!!!! OH NOES!!!1! @@ -1444,8 +1444,8 @@ fprintf(stderr, am=opt[am]; #ifdef DEBUG_AM fprintf(stderr, -"aftaa1: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %d\n", - pc[segment], am, vv[0], fl, (vv[0]&0xffff00)); +"aftaa1: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %d, bl = %d\n", + pc[segment], am, vv[0], fl, (vv[0]&0xffff00), bl); #endif if(t[*ll-1]!='!') { if(bl && !er && !(vv[0]&0xffff00) && opt[am]>=0) { @@ -1460,8 +1460,8 @@ fprintf(stderr, } #ifdef DEBUG_AM fprintf(stderr, -"aftaa2: pc=%d, am=%d and vv[0]=%d, optimize=%d, bitmask=%d, op=%d\n", - pc[segment], am, vv[0], fl, (vv[0]&0xffff00), ct[n][opt[am]]); +"aftaa2: pc=%d, am=%d and vv[0]=%d, optimize=%d, bitmask=%d, op=%d, bl=%d\n", + pc[segment], am, vv[0], fl, (vv[0]&0xffff00), ct[n][opt[am]], bl); #endif } @@ -1470,17 +1470,16 @@ fprintf(stderr, else { bl=le[am]; + if( ((ct[n][am]&0x400) && memode) || ((ct[n][am]&0x800) && xmode)) { + bl++; + } if ((am != 11 && am != 16) && (vv[0] > 255 || vv[0] < -256) && bl == 2) { er = E_OVERFLOW; } else if ((am != 11 && am != 16) && (vv[0] > 65535 || vv[0] < -65536) && (bl == 2 || bl == 3)) { er = E_OVERFLOW; - } else - if( ((ct[n][am]&0x400) && memode) || ((ct[n][am]&0x800) && xmode)) { - bl++; } *ll=bl; - } #ifdef DEBUG_AM diff --git a/xa/tests/README b/xa/tests/README index 3be8f70..c773221 100644 --- a/xa/tests/README +++ b/xa/tests/README @@ -43,6 +43,7 @@ quotch/ Test quoting problematic characters (thanks Simon Rowe) 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) Cameron Kaiser, AndrĂ© Fachat diff --git a/xa/tests/alxl/Makefile b/xa/tests/alxl/Makefile new file mode 100644 index 0000000..c6024c5 --- /dev/null +++ b/xa/tests/alxl/Makefile @@ -0,0 +1,24 @@ +default: + # xa should not allow this to happen. if it does, this test is no good. + ../../xa alxl.s || exit 0 && exit 1 + ../../xa alxlo1.s || exit 0 && exit 1 + ../../xa alxlo2.s || exit 0 && exit 1 + ../../xa alxlx1.s || exit 0 && exit 1 + ../../xa alxlx2.s || exit 0 && exit 1 + ../../xa alxlx3.s || exit 0 && exit 1 + ../../xa sizes.s || exit 0 && exit 1 + ../../xa -w alxlx1.s || exit 0 && exit 1 + ../../xa -w alxlx2.s || exit 0 && exit 1 + ../../xa -w alxlx3.s || exit 0 && exit 1 + # expected-to-fail tests did fail. should be no more errors now. + ../../xa -w alxl.s -o alxl.o + ../hextool -cmp=alxl.ok < alxl.o + ../../xa -w alxlo1.s -o alxlo1.o + ../hextool -cmp=alxlo1.ok < alxlo1.o + ../../xa -w alxlo2.s -o alxlo2.o + ../hextool -cmp=alxlo2.ok < alxlo2.o + ../../xa -w sizes.s -o sizes.o + ../hextool -cmp=sizes.ok < sizes.o + +clean: + rm -f *.o diff --git a/xa/tests/alxl/alxl.ok b/xa/tests/alxl/alxl.ok new file mode 100644 index 0000000..0d5e499 --- /dev/null +++ b/xa/tests/alxl/alxl.ok @@ -0,0 +1 @@ +¢4 4©4 \ No newline at end of file diff --git a/xa/tests/alxl/alxl.s b/xa/tests/alxl/alxl.s new file mode 100644 index 0000000..105dcfa --- /dev/null +++ b/xa/tests/alxl/alxl.s @@ -0,0 +1,13 @@ +; test for the xa .xl opcode that should set the XR handling to 16 bit + + *=$f000 + + ; set X/Y registers to 16 bit ... + rep #%00010000 + ; ... and tell the assembler about it + .xl + ldx #$1234 + ldy #$1234 + + .al + lda #$1234 diff --git a/xa/tests/alxl/alxlo1.ok b/xa/tests/alxl/alxlo1.ok new file mode 100644 index 0000000..768d6f6 --- /dev/null +++ b/xa/tests/alxl/alxlo1.ok @@ -0,0 +1 @@ +©4 \ No newline at end of file diff --git a/xa/tests/alxl/alxlo1.s b/xa/tests/alxl/alxlo1.s new file mode 100644 index 0000000..65480fb --- /dev/null +++ b/xa/tests/alxl/alxlo1.s @@ -0,0 +1,10 @@ +; test for the xa .xl opcode that should set the XR handling to 16 bit + + *=$f000 + + ; set X/Y registers to 16 bit ... + rep #%00010000 + ; ... and tell the assembler about it + + .al + lda #$1234 diff --git a/xa/tests/alxl/alxlo2.ok b/xa/tests/alxl/alxlo2.ok new file mode 100644 index 0000000..f729f99 --- /dev/null +++ b/xa/tests/alxl/alxlo2.ok @@ -0,0 +1 @@ +¢4 4 \ No newline at end of file diff --git a/xa/tests/alxl/alxlo2.s b/xa/tests/alxl/alxlo2.s new file mode 100644 index 0000000..3f5e555 --- /dev/null +++ b/xa/tests/alxl/alxlo2.s @@ -0,0 +1,10 @@ +; test for the xa .xl opcode that should set the XR handling to 16 bit + + *=$f000 + + ; set X/Y registers to 16 bit ... + rep #%00010000 + ; ... and tell the assembler about it + .xl + ldx #$1234 + ldy #$1234 diff --git a/xa/tests/alxl/alxlx1.s b/xa/tests/alxl/alxlx1.s new file mode 100644 index 0000000..944a458 --- /dev/null +++ b/xa/tests/alxl/alxlx1.s @@ -0,0 +1,12 @@ +; test for the xa .xl opcode that should set the XR handling to 16 bit + + *=$f000 + + ; set X/Y registers to 16 bit ... + rep #%00010000 + ; ... and tell the assembler about it + + .al + ldx #$1234 + ldy #$1234 + lda #$1234 diff --git a/xa/tests/alxl/alxlx2.s b/xa/tests/alxl/alxlx2.s new file mode 100644 index 0000000..deb27b4 --- /dev/null +++ b/xa/tests/alxl/alxlx2.s @@ -0,0 +1,11 @@ +; test for the xa .xl opcode that should set the XR handling to 16 bit + + *=$f000 + + ; set X/Y registers to 16 bit ... + rep #%00010000 + ; ... and tell the assembler about it + .xl + ldx #$1234 + ldy #$1234 + lda #$1234 diff --git a/xa/tests/alxl/alxlx3.s b/xa/tests/alxl/alxlx3.s new file mode 100644 index 0000000..78a3005 --- /dev/null +++ b/xa/tests/alxl/alxlx3.s @@ -0,0 +1,10 @@ +; test for the xa .xl opcode that should set the XR handling to 16 bit + + *=$f000 + + ; set X/Y registers to 16 bit ... + rep #%00010000 + ; ... and tell the assembler about it + ldx #$1234 + ldy #$1234 + lda #$1234 diff --git a/xa/tests/alxl/sizes.ok b/xa/tests/alxl/sizes.ok new file mode 100644 index 0000000000000000000000000000000000000000..579e6f6d50e5cd4d7716e0b0cb4187674e58cd0c GIT binary patch literal 30 ecmYd@F;)@;;q?&Au+~^> 16) & $FFFF) +#define LO(z) ((z) & $FFFF) + + .al + .xl + *=$112233 + SYM: + rts + jmp SYM + jmp $112233 + lda $112233 + lda @$2233 + lda $2233 + lda $33 + +#print HI(SYM) + lda #HI(SYM) + pha +#print LO(SYM) + lda #LO(SYM) + pha + From b5c1e9b902da49d4111d8f8a916f68b114b822bb Mon Sep 17 00:00:00 2001 From: Andre Fachat Date: Sun, 27 Mar 2022 23:01:03 +0200 Subject: [PATCH 2/2] update to official xa-2.3.13 --- xa/ChangeLog | 20 +++++++++++++ xa/Makefile | 4 +-- xa/misc/file65.c | 5 ++-- xa/misc/reloc65.c | 24 +++++++++------- xa/src/xa.c | 44 +++++++++++++++++++++++------ xa/src/xap.c | 58 +++++++++++++++++++++++++++++++------- xa/src/xat.c | 12 ++++++-- xa/tests/harness | 1 + xa/tests/stringcom/ok | Bin 0 -> 79 bytes xa/tests/stringcom/test.s | 21 ++++++++++++++ 10 files changed, 154 insertions(+), 35 deletions(-) create mode 100644 xa/tests/stringcom/ok create mode 100644 xa/tests/stringcom/test.s diff --git a/xa/ChangeLog b/xa/ChangeLog index c09970f..998c3c1 100644 --- a/xa/ChangeLog +++ b/xa/ChangeLog @@ -363,3 +363,23 @@ xa-2.3.11 -- Cameron Kaiser 4 May 2020 +xa-2.3.12 + + * Regression fix for address size validation in 65816 mode (thanks Sam + Falvo; we had a pending fix for this but I like his test case). + * Testsuite expanded. + +-- Cameron Kaiser 26 November 2021 + +xa-2.3.13 + + * Fix // and /* */ in quoted strings. Incredible no one ever hit this + before (thanks ZornsLemma). + * Segfault fixes for file65, reloc65 and xa. Remember, kids, if you ever + run xa as root all kittens will die. Please save the kittens (thanks + Stephen Kitt). + * Just compare to null in the preprocessor (thanks Bas Wassink). + * Testsuite expanded. + +-- Cameron Kaiser 25 March 2022 + diff --git a/xa/Makefile b/xa/Makefile index 7bbfd64..33d390e 100644 --- a/xa/Makefile +++ b/xa/Makefile @@ -53,7 +53,7 @@ clean: (cd src && ${MAKE} clean) (cd loader && ${MAKE} clean) (cd misc && ${MAKE} mrproper) - rm -f xa *.exe *.o65 + rm -f xa *.exe *.o65 *.s install: xa uncpk $(MKDIR) $(BINDIR) @@ -63,7 +63,7 @@ install: xa uncpk #$(MKDIR) $(DOCDIR)/xa65 dist: clean - cd .. ; tar cvf xa-2.3.12.tar xa-2.3.12 ; gzip xa-2.3.12.tar + cd .. ; tar cvf xa-2.3.13.tar xa-2.3.13 ; gzip xa-2.3.13.tar test: xa uncpk cd tests && ./harness -make="$(MAKE)" -cc="$(CC)" -cflags="$(CFLAGS)" diff --git a/xa/misc/file65.c b/xa/misc/file65.c index 5eb03b5..cec2d98 100644 --- a/xa/misc/file65.c +++ b/xa/misc/file65.c @@ -101,13 +101,14 @@ int main(int argc, char *argv[]) { rompar = 1; if(argv[i][1]=='A') rompar++; if(argv[i][2]) romoff = atoi(argv[i]+2); - else romoff = atoi(argv[++i]); + else if(i + 1 < argc) romoff = atoi(argv[++i]); + else fprintf(stderr,"%s: missing offset\n",programname); break; case 'P': xapar = 1; break; default: - fprintf(stderr,"file65: %s unknown option\n",argv[i]); + fprintf(stderr,"%s: %s unknown option\n",programname,argv[i]); break; } } else { diff --git a/xa/misc/reloc65.c b/xa/misc/reloc65.c index eeb64cf..bd00eb0 100644 --- a/xa/misc/reloc65.c +++ b/xa/misc/reloc65.c @@ -84,6 +84,7 @@ int main(int argc, char *argv[]) { FILE *fp; int tflag = 0, dflag = 0, bflag = 0, zflag = 0; int tbase = 0, dbase = 0, bbase = 0, zbase = 0; + int *base; char *outfile = "a.o65"; int extract = 0; @@ -108,37 +109,40 @@ int main(int argc, char *argv[]) { switch(argv[i][1]) { case 'o': if(argv[i][2]) outfile=argv[i]+2; - else outfile=argv[++i]; + else if(i + 1 < argc) outfile=argv[++i]; + else fprintf(stderr,"%s: missing output file\n",programname); break; case 'X': extract=3; break; case 'b': + base=NULL; switch(argv[i][2]) { case 't': tflag= 1; - if(argv[i][3]) tbase = atoi(argv[i]+3); - else tbase = atoi(argv[++i]); + base=&tbase; break; case 'd': dflag= 1; - if(argv[i][3]) dbase = atoi(argv[i]+3); - else dbase = atoi(argv[++i]); + base=&dbase; break; case 'b': bflag= 1; - if(argv[i][3]) bbase = atoi(argv[i]+3); - else bbase = atoi(argv[++i]); + base=&bbase; break; case 'z': zflag= 1; - if(argv[i][3]) zbase = atoi(argv[i]+3); - else zbase = atoi(argv[++i]); + base=&zbase; break; default: printf("Unknown segment type '%c' - ignored!\n", argv[i][2]); break; } + if (base != NULL) { + if(argv[i][3]) *base = atoi(argv[i]+3); + else if(i + 1 < argc) *base = atoi(argv[++i]); + else fprintf(stderr,"%s: missing address\n",programname); + } break; case 'x': /* extract segment */ switch(argv[i][2]) { @@ -158,7 +162,7 @@ int main(int argc, char *argv[]) { } break; default: - fprintf(stderr,"reloc65: %s unknown option, use '-?' for help\n",argv[i]); + fprintf(stderr,"%s: %s unknown option, use '-?' for help\n",programname,argv[i]); break; } } else { diff --git a/xa/src/xa.c b/xa/src/xa.c index 0595708..02e305e 100644 --- a/xa/src/xa.c +++ b/xa/src/xa.c @@ -55,9 +55,9 @@ #define ANZWARN 13 #define programname "xa" -#define progversion "v2.3.12" +#define progversion "v2.3.13" #define authors "Written by Andre Fachat, Jolse Maginnis, David Weinehall and Cameron Kaiser" -#define copyright "Copyright (C) 1989-2021 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." +#define copyright "Copyright (C) 1989-2022 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." /* exported globals */ int ncmos, cmosfl, w65816, n65816; @@ -218,8 +218,12 @@ int main(int argc,char *argv[]) case 'O': /* output charset */ { char *name = NULL; - if (argv[i][2] == 0) { - name = argv[++i]; + if (argv[i][2] == 0) { + if (i + 1 < argc) name = argv[++i]; + else { + fprintf(stderr, "-O requires an argument\n"); + exit(1); + } } else { name = argv[i]+2; } @@ -231,7 +235,13 @@ int main(int argc,char *argv[]) case 'A': /* make text segment start so that text relocation is not necessary when _file_ starts at adr */ romable = 2; - if(argv[i][2]==0) romaddr = atoi(argv[++i]); + if(argv[i][2]==0) { + if (i + 1 < argc) romaddr = atoi(argv[++i]); + else { + fprintf(stderr, "-A requires an argument\n"); + exit(1); + } + } else romaddr = atoi(argv[i]+2); break; case 'G': @@ -276,28 +286,44 @@ int main(int argc,char *argv[]) break; case 'I': if(argv[i][2]==0) { - reg_include(argv[++i]); + if (i + 1 < argc) reg_include(argv[++i]); + else { + fprintf(stderr, "-I requires an argument\n"); + exit(1); + } } else { reg_include(argv[i]+2); } break; case 'o': if(argv[i][2]==0) { - ofile=argv[++i]; + if (i + 1 < argc) ofile=argv[++i]; + else { + fprintf(stderr, "-o requires an argument\n"); + exit(1); + } } else { ofile=argv[i]+2; } break; case 'l': if(argv[i][2]==0) { - lfile=argv[++i]; + if (i + 1 < argc) lfile=argv[++i]; + else { + fprintf(stderr, "-l requires an argument\n"); + exit(1); + } } else { lfile=argv[i]+2; } break; case 'e': if(argv[i][2]==0) { - efile=argv[++i]; + if (i + 1 < argc) efile=argv[++i]; + else { + fprintf(stderr, "-e requires an argument\n"); + exit(1); + } } else { efile=argv[i]+2; } diff --git a/xa/src/xap.c b/xa/src/xap.c index e2f1491..4dff224 100644 --- a/xa/src/xap.c +++ b/xa/src/xap.c @@ -60,6 +60,8 @@ static int pp_undef(char*); #define VALBEF 6 static int ungeteof = 0; +static int quotebs = 0; +static int inquote = 0; static char *cmd[]={ "echo","include","define","undef","printdef","print", "ifdef","ifndef","else","endif", @@ -792,7 +794,7 @@ int pp_open(char *name) flist[0].filep=fp; flist[0].flinep=NULL; - return(((long)fp)==0l); + return (fp == NULL); } void pp_close(void) @@ -875,6 +877,7 @@ int pgetline(char *t) int c,er=E_OK; int rlen, tlen; char *p = 0; + char *q = 0; loopfl =0; /* set if additional fetch needed */ @@ -924,12 +927,38 @@ int pgetline(char *t) } /* handle the double-slash comment (like in C++) */ - p = strchr(in_line, '/'); - if (p != NULL) { - if (p[1] == '/') { - *p = 0; /* terminate string */ + /* 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'; @@ -987,15 +1016,22 @@ int egetc(FILE *fp) { /* smart getc that can skip C comment blocks */ int rgetc(FILE *fp) { - static int c,d,fl; - + static int c,cc,d,fl; + cc=0; fl=0; do { while((c=egetc(fp))==13); /* remove ^M for unices */ - if(fl && (c=='*')) + /* 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 + + if(!inquote && fl && (c=='*')) { if((d=egetc(fp))!='/') ungetc(d,fp); @@ -1005,12 +1041,14 @@ int rgetc(FILE *fp) while((c=egetc(fp))==13); } } + + /* in comment block */ if(c=='\n') { flist[fsp].fline++; nlf=1; } else - if(c=='/') + if(!inquote && c=='/') { if((d=egetc(fp))!='*') ungetc(d,fp); diff --git a/xa/src/xat.c b/xa/src/xat.c index 6da4dd7..88d5342 100644 --- a/xa/src/xat.c +++ b/xa/src/xat.c @@ -2111,7 +2111,7 @@ static void tg_hex(signed char *s, int *l, int *v) static int tg_asc(signed char *s, signed char *t, int *q, int *p, int *na1, int *na2,int n) { - int er=E_OK,i=0,j=0; + int er=E_OK,i=0,j=0,bs=0; signed char delimiter = s[i++]; @@ -2122,8 +2122,16 @@ fprintf(stderr, "tg_asc token = %i\n", n); t[j++]='"'; /* pass2 token for string */ j++; /* skip place for length */ - while(s[i]!='\0' && s[i]!=delimiter) + while(s[i]!='\0' && (bs || s[i]!=delimiter)) { + +#if(0) +/* implement backslashed quotes for 2.4 */ + if(n != Kbin && s[i] == '\\' && !bs) { + fprintf(stderr, "B"); bs=1; i++; continue; + } else bs=0; +#endif + /* do NOT convert for Kbin or Kaasc, or for initial parse */ if (!n || n == Kbin || n == Kaasc) { t[j++]=s[i]; diff --git a/xa/tests/harness b/xa/tests/harness index fdc7d53..ddcacbb 100755 --- a/xa/tests/harness +++ b/xa/tests/harness @@ -55,6 +55,7 @@ W: while($x = readdir(D)) { chdir(".."); } closedir(D); +print STDOUT "=" x 79, "\n"; print STDOUT "\n## ALL TESTS PASS ##\n"; exit 0; diff --git a/xa/tests/stringcom/ok b/xa/tests/stringcom/ok new file mode 100644 index 0000000000000000000000000000000000000000..a7a755e3ce51c690931d861a6ac35df3822764fd GIT binary patch literal 79 zcmZQ&XbARntuQh*3-$vt^x+IRs}d{};20dNuLUBt^!4?@JTM8;qXkr