Annotation of 41BSD/lib/libpc/PACK.c, revision 1.1.1.1

1.1       root        1: /* Copyright (c) 1979 Regents of the University of California */
                      2: 
                      3: static char sccsid[] = "@(#)PACK.c 1.1 10/29/80";
                      4: 
                      5: #include "h01errs.h"
                      6: 
                      7: /*
                      8:  * pack(a,i,z)
                      9:  *
                     10:  * with:       a: array[m..n] of t
                     11:  *     z: packed array[u..v] of t
                     12:  *
                     13:  * semantics:  for j := u to v do
                     14:  *                     z[j] := a[j-u+i];
                     15:  *
                     16:  * need to check:
                     17:  *     1. i >= m
                     18:  *     2. i+(v-u) <= n         (i.e. i-m <= (n-m)-(v-u))
                     19:  *
                     20:  * on stack:   lv(z), lv(a), rv(i) (len 4)
                     21:  *
                     22:  * move w(t)*(v-u+1) bytes from lv(a)+w(t)*(i-m) to lv(z)
                     23:  */
                     24: 
                     25: PACK(i, a, z, size_a, lb_a, ub_a, size_z)
                     26: 
                     27:        int     i;      /* subscript into a to begin packing */
                     28:        char    *a;     /* pointer to structure a */
                     29:        char    *z;     /* pointer to structure z */
                     30:        int     size_a; /* sizeof(a_type) */
                     31:        int     lb_a;   /* lower bound of structure a */
                     32:        int     ub_a;   /* (upper bound of a) - (lb_a + sizeof(z_type)) */
                     33:        int     size_z; /* sizeof(z_type) */
                     34: {
                     35:        int             subscr;
                     36:        register char   *cp;
                     37:        register char   *zp = z;
                     38:        register char   *limit;
                     39: 
                     40:        subscr = i - lb_a;
                     41:        if (subscr < 0 || subscr > ub_a) {
                     42:                ERROR(EPACK, i);
                     43:                return;
                     44:        }
                     45:        cp = &a[subscr * size_a];
                     46:        limit = cp + size_z;
                     47:        do      {
                     48:                *zp++ = *cp++;
                     49:        } while (cp < limit);
                     50: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.