diff --git a/modules/src/object/object.h b/modules/src/object/object.h index 0f87c4b8d..92bc4b1cc 100644 --- a/modules/src/object/object.h +++ b/modules/src/object/object.h @@ -13,6 +13,14 @@ #define Xchar(ch) ((ch) & 0377) #endif +#if ! defined(BYTES_REVERSED) +#define BYTES_REVERSED 1 +#endif + +#if ! defined(WORDS_REVERSED) +#define WORDS_REVERSED 1 +#endif + #if BYTES_REVERSED #define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8)) #define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8)) diff --git a/modules/src/object/rd.c b/modules/src/object/rd.c index 6f9d84374..2618750de 100644 --- a/modules/src/object/rd.c +++ b/modules/src/object/rd.c @@ -155,23 +155,21 @@ rd_sect(sect, cnt) while (cnt--) { sect--; #if ! (BYTES_REVERSED || WORDS_REVERSED) - if (sizeof(struct outsect) != SZ_SECT) { + if (sizeof(struct outsect) != SZ_SECT) #endif - c -= 4; sect->os_lign = get4(c); - c -= 4; sect->os_flen = get4(c); - c -= 4; sect->os_foff = get4(c); -#if ! (BYTES_REVERSED || WORDS_REVERSED) + { + c -= 4; sect->os_lign = get4(c); + c -= 4; sect->os_flen = get4(c); + c -= 4; sect->os_foff = get4(c); } -#endif offset[--offcnt] = sect->os_foff + rd_base; #if ! (BYTES_REVERSED || WORDS_REVERSED) - if (sizeof(struct outsect) != SZ_SECT) { + if (sizeof(struct outsect) != SZ_SECT) #endif - c -= 4; sect->os_size = get4(c); - c -= 4; sect->os_base = get4(c); -#if ! (BYTES_REVERSED || WORDS_REVERSED) + { + c -= 4; sect->os_size = get4(c); + c -= 4; sect->os_base = get4(c); } -#endif } } diff --git a/modules/src/object/rd_arhdr.c b/modules/src/object/rd_arhdr.c index 95c63ea19..8ea9f773e 100644 --- a/modules/src/object/rd_arhdr.c +++ b/modules/src/object/rd_arhdr.c @@ -10,39 +10,26 @@ int rd_arhdr(fd, arhdr) register struct ar_hdr *arhdr; { -#if WORDS_REVERSED && ! BYTES_REVERSED - if (sizeof (struct ar_hdr) != AR_TOTAL) -#endif - { - char buf[AR_TOTAL]; - register char *c = buf; - register char *p = arhdr->ar_name; - register int i; + char buf[AR_TOTAL]; + register char *c = buf; + register char *p = arhdr->ar_name; + register int i; - i = read(fd, c, AR_TOTAL); - if (i == 0) return 0; - if (i != AR_TOTAL) { - rd_fatal(); - } - i = 14; - while (i--) { - *p++ = *c++; - } - arhdr->ar_date = ((long) get2(c)) << 16; c += 2; - arhdr->ar_date |= ((long) get2(c)) & 0xffff; c += 2; - arhdr->ar_uid = *c++; - arhdr->ar_gid = *c++; - arhdr->ar_mode = get2(c); c += 2; - arhdr->ar_size = (long) get2(c) << 16; c += 2; - arhdr->ar_size |= (long) get2(c) & 0xffff; + i = read(fd, c, AR_TOTAL); + if (i == 0) return 0; + if (i != AR_TOTAL) { + rd_fatal(); } -#if WORDS_REVERSED && !BYTES_REVERSED - else { - register int i; - i = read(fd, (char *) arhdr, AR_TOTAL); - if (i == 0) return 0; - if (i != AR_TOTAL) rd_fatal(); + i = 14; + while (i--) { + *p++ = *c++; } -#endif + arhdr->ar_date = ((long) get2(c)) << 16; c += 2; + arhdr->ar_date |= ((long) get2(c)) & 0xffff; c += 2; + arhdr->ar_uid = *c++; + arhdr->ar_gid = *c++; + arhdr->ar_mode = get2(c); c += 2; + arhdr->ar_size = (long) get2(c) << 16; c += 2; + arhdr->ar_size |= (long) get2(c) & 0xffff; return 1; } diff --git a/modules/src/object/wr_arhdr.c b/modules/src/object/wr_arhdr.c index 988a5def2..a074f2dfe 100644 --- a/modules/src/object/wr_arhdr.c +++ b/modules/src/object/wr_arhdr.c @@ -9,28 +9,20 @@ wr_arhdr(fd, arhdr) register struct ar_hdr *arhdr; { -#if WORDS_REVERSED && !BYTES_REVERSED - if (sizeof (struct ar_hdr) != AR_TOTAL) -#endif - { - char buf[AR_TOTAL]; - register char *c = buf; - register char *p = arhdr->ar_name; - register int i = 14; + char buf[AR_TOTAL]; + register char *c = buf; + register char *p = arhdr->ar_name; + register int i = 14; - while (i--) { - *c++ = *p++; - } - put2((int)(arhdr->ar_date>>16),c); c += 2; - put2((int)(arhdr->ar_date),c); c += 2; - *c++ = arhdr->ar_uid; - *c++ = arhdr->ar_gid; - put2(arhdr->ar_mode,c); c += 2; - put2((int)(arhdr->ar_size>>16),c); c += 2; - put2((int)(arhdr->ar_size),c); - wr_bytes(fd, buf, (long) AR_TOTAL); + while (i--) { + *c++ = *p++; } -#if WORDS_REVERSED && !BYTES_REVERSED - else wr_bytes(fd, (char *) arhdr, (long) AR_TOTAL); -#endif + put2((int)(arhdr->ar_date>>16),c); c += 2; + put2((int)(arhdr->ar_date),c); c += 2; + *c++ = arhdr->ar_uid; + *c++ = arhdr->ar_gid; + put2(arhdr->ar_mode,c); c += 2; + put2((int)(arhdr->ar_size>>16),c); c += 2; + put2((int)(arhdr->ar_size),c); + wr_bytes(fd, buf, (long) AR_TOTAL); }