Uninitialized vector entry?
[minix3.git] / lib / ack / libp / unp.c
blobd9d5a5fa867f49cacd7c0d0ef9af75f6fd7b5a25
1 /* $Header$ */
2 /*
3 * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
5 * This product is part of the Amsterdam Compiler Kit.
7 * Permission to use, sell, duplicate or disclose this software must be
8 * obtained in writing. Requests for such permissions may be sent to
10 * Dr. Andrew S. Tanenbaum
11 * Wiskundig Seminarium
12 * Vrije Universiteit
13 * Postbox 7161
14 * 1007 MC Amsterdam
15 * The Netherlands
19 /* Author: J.W. Stevenson */
21 #include <pc_err.h>
23 extern _trp();
25 #define assert(x) /* nothing */
27 #ifndef EM_WSIZE
28 #define EM_WSIZE _EM_WSIZE
29 #endif
31 struct descr {
32 int low;
33 int diff;
34 int size;
37 _unp(ad,zd,i,ap,zp,noext) int i; struct descr *ad,*zd; char *ap,*zp; int noext; {
39 if (zd->diff > ad->diff ||
40 (i -= ad->low) < 0 ||
41 (i+zd->diff) > ad->diff)
42 _trp(EUNPACK);
43 ap += (i * ad->size);
44 i = (zd->diff + 1) * zd->size;
45 if (zd->size == 1) {
46 int *aptmp = (int *) ap;
47 assert(ad->size == EM_WSIZE);
48 while (--i >= 0)
49 if (noext) *aptmp++ = *zp++ & 0377;
50 else *aptmp++ = *zp++;
51 #if EM_WSIZE > 2
52 } else if (zd->size == 2) {
53 int *aptmp = (int *) ap;
54 short *zptmp = (short *) zp;
55 assert(ad->size == EM_WSIZE);
56 while (--i >= 0)
57 if (noext) *aptmp++ = *zptmp++ & 0177777;
58 else *aptmp++ = *zptmp++;
59 #endif
60 } else {
61 assert(ad->size == zd->size);
62 while (--i >= 0)
63 *ap++ = *zp++;