prevent sign-extension in unpack when needed
This commit is contained in:
parent
c40ca6ebbd
commit
d16c25fc80
|
@ -47,6 +47,14 @@ _pac(ad,zd,zp,i,ap) int i; struct descr *ad,*zd; char *zp,*ap; {
|
||||||
assert(ad->size == EM_WSIZE);
|
assert(ad->size == EM_WSIZE);
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
*zp++ = *aptmp++;
|
*zp++ = *aptmp++;
|
||||||
|
#if EM_WSIZE > 2
|
||||||
|
} else if (zd->size == 2) {
|
||||||
|
int *aptmp = (int *)ap;
|
||||||
|
short *zptmp = (short *) zp;
|
||||||
|
assert(ad->size == EM_WSIZE);
|
||||||
|
while (--i >= 0)
|
||||||
|
*zptmp++ = *aptmp++;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
assert(ad->size == zd->size);
|
assert(ad->size == zd->size);
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct descr {
|
||||||
int size;
|
int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
_unp(ad,zd,i,ap,zp) int i; struct descr *ad,*zd; char *ap,*zp; {
|
_unp(ad,zd,i,ap,zp,noext) int i; struct descr *ad,*zd; char *ap,*zp; int noext; {
|
||||||
|
|
||||||
if (zd->diff > ad->diff ||
|
if (zd->diff > ad->diff ||
|
||||||
(i -= ad->low) < 0 ||
|
(i -= ad->low) < 0 ||
|
||||||
|
@ -46,7 +46,17 @@ _unp(ad,zd,i,ap,zp) int i; struct descr *ad,*zd; char *ap,*zp; {
|
||||||
int *aptmp = (int *) ap;
|
int *aptmp = (int *) ap;
|
||||||
assert(ad->size == EM_WSIZE);
|
assert(ad->size == EM_WSIZE);
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
*aptmp++ = *zp++;
|
if (noext) *aptmp++ = *zp++ & 0377;
|
||||||
|
else *aptmp++ = *zp++;
|
||||||
|
#if EM_WSIZE > 2
|
||||||
|
} else if (zd->size == 2) {
|
||||||
|
int *aptmp = (int *) ap;
|
||||||
|
short *zptmp = (short *) zp;
|
||||||
|
assert(ad->size == EM_WSIZE);
|
||||||
|
while (--i >= 0)
|
||||||
|
if (noext) *aptmp++ = *zptmp++ & 0177777;
|
||||||
|
else *aptmp++ = *zptmp++;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
assert(ad->size == zd->size);
|
assert(ad->size == zd->size);
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
|
|
Loading…
Reference in a new issue