From 1cbb0a34f08821a669d5a284019ff48c7c222c0a Mon Sep 17 00:00:00 2001 From: Andre Fachat Date: Wed, 11 Oct 2023 18:36:13 +0200 Subject: [PATCH] add another off-by-one --- xa/src/xaa.c | 8 ++++---- xa/src/xap.c | 19 ++++++++++--------- xa/src/xat.c | 40 +++++++++++++++++++++++++++++----------- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/xa/src/xaa.c b/xa/src/xaa.c index 588b0ce..c11f3e5 100644 --- a/xa/src/xaa.c +++ b/xa/src/xaa.c @@ -88,7 +88,7 @@ int a_term(signed char *s, int *v, int *l, int xpc, int *pfl, int *label, int f) } *l=pp; -/* printf("a_term: afl->%04x *pfl=%04x, (pc=%04x)\n",afl,*pfl, xpc); */ +//fprintf(stderr, "a_term: nolink=%d, noundef=%d ->er=%d; l=%d, pp=%d, afl->%04x *pfl=%04x, (pc=%04x)\n",nolink, noundef ,er, *l, pp, afl,*pfl, xpc); return(er); } @@ -98,9 +98,8 @@ static int ag_term(signed char *s, int p, int *v, int *nafl, int *label) afl = 0; -/* -printf("ag_term(%02x %02x %02x %02x %02x %02x\n",s[0],s[1],s[2],s[3],s[4],s[5]); -*/ +//fprintf(stderr, "ag_term(%02x %02x %02x %02x %02x %02x\n",s[0],s[1],s[2],s[3],s[4],s[5]); + while(s[pp]=='-') { pp++; @@ -174,6 +173,7 @@ printf("pointer: v=%04x, afl=%04x\n",*v,afl); while(!er && s[pp]!=')' && s[pp]!=']' && s[pp]!=',' && s[pp]!=T_END && s[pp]!=T_COMMENT) { +fprintf(stderr, "ag_term while: s[pp=%d]=%02x\n", pp, s[pp]); er=get_op(s,&o); if(!er && pr[o]>p) diff --git a/xa/src/xap.c b/xa/src/xap.c index ef678ce..6dacd6e 100644 --- a/xa/src/xap.c +++ b/xa/src/xap.c @@ -1010,17 +1010,18 @@ int pgetline(char *t) handle this right */ er=pp_cpp(in_line+1); } else { - if((er=pp_comand(in_line+1))) - { - if(er!=1) - { - logout(in_line); - logout("\n"); - } - } + if((er=pp_comand(in_line+1))) + { + if(er!=1) + { + logout(in_line); + logout("\n"); + } + } } - } else + } else { er=1; + } if(c==EOF) { if (loopfl && fsp) { diff --git a/xa/src/xat.c b/xa/src/xat.c index 8949633..02f0444 100644 --- a/xa/src/xat.c +++ b/xa/src/xat.c @@ -432,18 +432,23 @@ fprintf(stderr, "- p1 %d starting -\n", pc[segment]); * using memcpy is fine here */ inp = 0; - /* discard label definitions before copying the buffer */ + /* discard label definitions before copying the buffer, so we don't get + * label defined errors */ while (inp