Fixed some errors

This commit is contained in:
ceriel 1991-09-18 09:48:15 +00:00
parent abb71310d2
commit 3a0c239091
2 changed files with 44 additions and 22 deletions

View file

@ -196,11 +196,11 @@ wr_ohead(head)
BEGINSEEK(PARTDBUG, off); BEGINSEEK(PARTDBUG, off);
#endif #endif
} }
#if BYTE_ORDER == 0x0123 if (BYTE_ORDER != 0x0123 || sizeof(struct outhead) != SZ_HEAD)
if (sizeof(struct outhead) != SZ_HEAD)
#endif
{ {
register char *c = (char *) head; char buf[SZ_HEAD];
register char *c = &buf[0];
put2(head->oh_magic, c); c += 2; put2(head->oh_magic, c); c += 2;
put2(head->oh_stamp, c); c += 2; put2(head->oh_stamp, c); c += 2;
@ -210,36 +210,57 @@ wr_ohead(head)
put2(head->oh_nname, c); c += 2; put2(head->oh_nname, c); c += 2;
put4(head->oh_nemit, c); c += 4; put4(head->oh_nemit, c); c += 4;
put4(head->oh_nchar, c); 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) wr_sect(sect, cnt)
struct outsect *s; register struct outsect *sect;
unsigned int cnt1; register unsigned int cnt;
{ {
register unsigned int cnt = cnt1; { register unsigned int i = cnt;
register struct outsect *sect = s;
register char *c = (char *) sect;
while (cnt--) { while (i--) {
if (offcnt >= 1 && offcnt < SECTCNT) { if (offcnt >= 1 && offcnt < SECTCNT) {
BEGINSEEK(PARTEMIT+offcnt, sect->os_foff); BEGINSEEK(PARTEMIT+offcnt, sect->os_foff);
}
offset[offcnt++] = sect->os_foff;
sect++;
} }
offset[offcnt++] = sect->os_foff; sect -= cnt;
}
#if BYTE_ORDER == 0x0123 #if BYTE_ORDER == 0x0123
if (sizeof(struct outsect) != SZ_SECT) if (sizeof(struct outsect) != SZ_SECT)
#endif #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_base, c); c += 4;
put4(sect->os_size, c); c += 4; put4(sect->os_size, c); c += 4;
put4(sect->os_foff, c); c += 4; put4(sect->os_foff, c); c += 4;
put4(sect->os_flen, c); c += 4; put4(sect->os_flen, c); c += 4;
put4(sect->os_lign, 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) wr_outsect(s)

View file

@ -6,14 +6,15 @@
#include <ranlib.h> #include <ranlib.h>
#include "object.h" #include "object.h"
wr_ranlib(fd, ran, cnt) wr_ranlib(fd, ran, cnt1)
struct ranlib *ran; struct ranlib *ran;
register long cnt; long cnt1;
{ {
#if BYTE_ORDER == 0x0123 #if BYTE_ORDER == 0x0123
if (sizeof (struct ranlib) != SZ_RAN) if (sizeof (struct ranlib) != SZ_RAN)
#endif #endif
{ {
register long cnt = cnt1;
register struct ranlib *r = ran; register struct ranlib *r = ran;
register char *c = (char *) r; register char *c = (char *) r;
@ -23,5 +24,5 @@ wr_ranlib(fd, ran, cnt)
r++; r++;
} }
} }
wr_bytes(fd, (char *) ran, cnt * SZ_RAN); wr_bytes(fd, (char *) ran, cnt1 * SZ_RAN);
} }