From: ceriel Date: Wed, 18 Sep 1991 09:48:15 +0000 (+0000) Subject: Fixed some errors X-Git-Tag: release-5-5~866 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3a0c239091de59d47c02f404e823468498aedc00;p=ack.git Fixed some errors --- diff --git a/modules/src/object/wr.c b/modules/src/object/wr.c index c8d5a0196..43c81c26d 100644 --- a/modules/src/object/wr.c +++ b/modules/src/object/wr.c @@ -196,11 +196,11 @@ wr_ohead(head) BEGINSEEK(PARTDBUG, off); #endif } -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outhead) != SZ_HEAD) -#endif + if (BYTE_ORDER != 0x0123 || sizeof(struct outhead) != SZ_HEAD) { - register char *c = (char *) head; + char buf[SZ_HEAD]; + + register char *c = &buf[0]; put2(head->oh_magic, c); c += 2; put2(head->oh_stamp, c); c += 2; @@ -210,36 +210,57 @@ wr_ohead(head) put2(head->oh_nname, c); c += 2; put4(head->oh_nemit, c); c += 4; put4(head->oh_nchar, c); + OUTWRITE(PARTEMIT, buf, (long)SZ_HEAD); } - OUTWRITE(PARTEMIT, (char *)head, (long)SZ_HEAD); + else OUTWRITE(PARTEMIT, (char *)head, (long)SZ_HEAD); } -wr_sect(s, cnt1) - struct outsect *s; - unsigned int cnt1; +wr_sect(sect, cnt) + register struct outsect *sect; + register unsigned int cnt; { - register unsigned int cnt = cnt1; - register struct outsect *sect = s; - register char *c = (char *) sect; + { register unsigned int i = cnt; - while (cnt--) { - if (offcnt >= 1 && offcnt < SECTCNT) { - BEGINSEEK(PARTEMIT+offcnt, sect->os_foff); + while (i--) { + if (offcnt >= 1 && offcnt < SECTCNT) { + BEGINSEEK(PARTEMIT+offcnt, sect->os_foff); + } + offset[offcnt++] = sect->os_foff; + sect++; } - offset[offcnt++] = sect->os_foff; + sect -= cnt; + } #if BYTE_ORDER == 0x0123 - if (sizeof(struct outsect) != SZ_SECT) + if (sizeof(struct outsect) != SZ_SECT) #endif - { + while (cnt) + { + register char *c; + register unsigned int i; + + i = __parts[PARTEMIT].cnt/SZ_SECT; + c = __parts[PARTEMIT].pnow; + if (i > cnt) i = cnt; + cnt -= i; + __parts[PARTEMIT].cnt -= (i*SZ_SECT); + while (i--) { put4(sect->os_base, c); c += 4; put4(sect->os_size, c); c += 4; put4(sect->os_foff, c); c += 4; put4(sect->os_flen, c); c += 4; put4(sect->os_lign, c); c += 4; + sect++; + } + __parts[PARTEMIT].pnow = c; + if (cnt) { + __wr_flush(&__parts[PARTEMIT]); } - sect++; } - OUTWRITE(PARTEMIT, (char *) s, (long) cnt1 * SZ_SECT); +#if BYTE_ORDER == 0x0123 + else { + OUTWRITE(PARTEMIT, (char *) sect, (long) cnt * SZ_SECT); + } +#endif } wr_outsect(s) diff --git a/modules/src/object/wr_ranlib.c b/modules/src/object/wr_ranlib.c index f564bedca..2b4532f9a 100644 --- a/modules/src/object/wr_ranlib.c +++ b/modules/src/object/wr_ranlib.c @@ -6,14 +6,15 @@ #include #include "object.h" -wr_ranlib(fd, ran, cnt) +wr_ranlib(fd, ran, cnt1) struct ranlib *ran; - register long cnt; + long cnt1; { #if BYTE_ORDER == 0x0123 if (sizeof (struct ranlib) != SZ_RAN) #endif { + register long cnt = cnt1; register struct ranlib *r = ran; register char *c = (char *) r; @@ -23,5 +24,5 @@ wr_ranlib(fd, ran, cnt) r++; } } - wr_bytes(fd, (char *) ran, cnt * SZ_RAN); + wr_bytes(fd, (char *) ran, cnt1 * SZ_RAN); }