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

unix.superglobalmegacorp.com

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