change over to new error message format
[unix-history] / usr / src / usr.bin / pascal / libpc / UNPACK.c
CommitLineData
2acaaee4
KM
1/* Copyright (c) 1979 Regents of the University of California */
2
86997b19 3static char sccsid[] = "@(#)UNPACK.c 1.3 %G%";
2acaaee4 4
2acaaee4
KM
5
6/*
7 * unpack(z,a,i)
8 *
9 * with: z and a as in pack
10 *
11 * semantics: for j := u to v do
12 * a[j-u+i] := z[j]
13 */
14
15UNPACK(i, a, z, size_a, lb_a, ub_a, size_z)
16
492cc5d3 17 long i; /* subscript into a to begin packing */
2acaaee4
KM
18 char *a; /* pointer to structure a */
19 char *z; /* pointer to structure z */
492cc5d3
KM
20 long size_a; /* sizeof(a_type) */
21 long lb_a; /* lower bound of structure a */
22 long ub_a; /* (upper bound of a) - (lb_a + sizeof(z_type)) */
23 long size_z; /* sizeof(z_type) */
2acaaee4
KM
24{
25 int subscr;
26 register char *cp;
27 register char *zp = z;
28 register char *limit;
29
30 subscr = i - lb_a;
31 if (subscr < 0 || subscr > ub_a) {
86997b19 32 ERROR("i = %D: Bad i to unpack(z,a,i)\n", i);
2acaaee4
KM
33 return;
34 }
35 cp = &a[subscr * size_a];
36 limit = cp + size_z;
37 do {
38 *cp++ = *zp++;
39 } while (cp < limit);
40}