From 2acaaee4b3242addec92558e23d8e32cee130280 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Thu, 30 Oct 1980 08:36:13 -0800 Subject: [PATCH] date and time created 80/10/30 00:36:13 by mckusick SCCS-vsn: usr.bin/pascal/libpc/UNPACK.c 1.1 --- usr/src/usr.bin/pascal/libpc/UNPACK.c | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 usr/src/usr.bin/pascal/libpc/UNPACK.c diff --git a/usr/src/usr.bin/pascal/libpc/UNPACK.c b/usr/src/usr.bin/pascal/libpc/UNPACK.c new file mode 100644 index 0000000000..6ba20bdb83 --- /dev/null +++ b/usr/src/usr.bin/pascal/libpc/UNPACK.c @@ -0,0 +1,41 @@ +/* Copyright (c) 1979 Regents of the University of California */ + +static char sccsid[] = "@(#)UNPACK.c 1.1 %G%"; + +#include "h01errs.h" + +/* + * unpack(z,a,i) + * + * with: z and a as in pack + * + * semantics: for j := u to v do + * a[j-u+i] := z[j] + */ + +UNPACK(i, a, z, size_a, lb_a, ub_a, size_z) + + int i; /* subscript into a to begin packing */ + char *a; /* pointer to structure a */ + char *z; /* pointer to structure z */ + int size_a; /* sizeof(a_type) */ + int lb_a; /* lower bound of structure a */ + int ub_a; /* (upper bound of a) - (lb_a + sizeof(z_type)) */ + int size_z; /* sizeof(z_type) */ +{ + int subscr; + register char *cp; + register char *zp = z; + register char *limit; + + subscr = i - lb_a; + if (subscr < 0 || subscr > ub_a) { + ERROR(EPACK, i); + return; + } + cp = &a[subscr * size_a]; + limit = cp + size_z; + do { + *cp++ = *zp++; + } while (cp < limit); +} -- 2.20.1