From 1399e1071cb0be85e1813a7903cf81d2119c1afe Mon Sep 17 00:00:00 2001 From: fachat Date: Fri, 17 Aug 2012 12:24:54 +0200 Subject: [PATCH] fix sign problem when length of internal line presentation got over 128... --- xa/src/xa.c | 5 ++--- xa/src/xalisting.c | 6 ++++++ xa/src/xalisting.h | 2 ++ xa/src/xat.c | 5 +++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/xa/src/xa.c b/xa/src/xa.c index e28995d..49ab4bc 100644 --- a/xa/src/xa.c +++ b/xa/src/xa.c @@ -680,11 +680,11 @@ static int pass2(void) while((ner_max==0 || nermn.tmpemn.tmpz) { // get the length of the entry (now two byte - need to handle the sign) - l = afile->mn.tmp[afile->mn.tmpe++]; + l = 255 & afile->mn.tmp[afile->mn.tmpe++]; l |= afile->mn.tmp[afile->mn.tmpe++] << 8; ll=l; - // printf("%p: l=%d first=%02x\n", afile->mn.tmp+afile->mn.tmpe-1, l, 0xff & afile->mn.tmp[afile->mn.tmpe]); + //printf("%p: l=%d first=%02x\n", afile->mn.tmp+afile->mn.tmpe-1, l, 0xff & afile->mn.tmp[afile->mn.tmpe]); if(!l) { @@ -712,7 +712,6 @@ static int pass2(void) /* t_p2_l() includes the listing call to do_listing() */ er=t_p2_l(afile->mn.tmp+afile->mn.tmpe,&ll,&al); - if(er==E_NOLINE) { } else diff --git a/xa/src/xalisting.c b/xa/src/xalisting.c index 39b4331..f325eeb 100644 --- a/xa/src/xalisting.c +++ b/xa/src/xalisting.c @@ -166,6 +166,12 @@ static formatter_t *formatp = &def_format; /*********************************************************************************************/ +void list_flush() { + if (listfp != NULL) { + fflush(listfp); + } +} + void list_start(const char *formatname) { formatp = &def_format; diff --git a/xa/src/xalisting.h b/xa/src/xalisting.h index 5b14b60..8505047 100644 --- a/xa/src/xalisting.h +++ b/xa/src/xalisting.h @@ -22,6 +22,8 @@ void list_start(char *formatname); //either NULL or "html" void list_end(); +void list_flush(); // debug helper + void list_setfile(FILE *fp); void list_line(int l); /* set line number for the coming listing output */ void list_filename(char *fname);/* set file name for the coming listing output */ diff --git a/xa/src/xat.c b/xa/src/xat.c index 33fc984..2433064 100644 --- a/xa/src/xat.c +++ b/xa/src/xat.c @@ -1013,7 +1013,7 @@ fprintf(stderr, "guessing instruction length is %d\n", bl); /* adjust length by token listing buffer length */ #ifdef DEBUG_CONV - printf("converted: (er=%d, t=%p, ll=%d):",er, t, *ll); + printf("converted: (er=%d, t=%p, ll=%d, tlen=%d):",er, t, *ll, tlen); for(i=0;i<*ll;i++) printf("%02x,",t[i] & 0xff); printf("\n"); @@ -1078,7 +1078,8 @@ int t_p2_l(signed char *t, int *ll, int *al) if (tlen > l) { // that is corrupt data and should not happen - printf("t_p2_l (ll=%d, t=%p):", *ll, t); + list_flush(); + printf("corrupt: t_p2_l (l=%d, tlen=%d, ll=%d, t=%p):", l, tlen, *ll, t); for(int i=0;i