From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- sys/osb/chrupk.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 sys/osb/chrupk.c (limited to 'sys/osb/chrupk.c') diff --git a/sys/osb/chrupk.c b/sys/osb/chrupk.c new file mode 100644 index 00000000..f909c8d9 --- /dev/null +++ b/sys/osb/chrupk.c @@ -0,0 +1,32 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include + +/* CHRUPK -- Unpack a byte string into XCHAR. This routine does not + * know about EOS terminators. The input and output arrays may be the same. + * Note that while XCHAR is signed, the signedness of the C char is unspecified, + * hence we pack the chars into unsigned bytes and restore the sign explicitly. + */ +CHRUPK (a, a_off, b, b_off, nchars) +XCHAR *a, *b; +XINT *a_off, *b_off, *nchars; +{ + register unsigned char *ip; + register XCHAR *op; + register int n, ch; + + /* Set pointers to last char plus one so that we can unpack the array + * in the reverse direction. + */ + n = *nchars; + ip = &((unsigned char *)a)[*a_off-1+n]; + op = &b[*b_off-1+n]; + + /* Unpack string from right to left. + */ + while (--n >= 0) + *--op = ((ch = *--ip) <= 127) ? ch : ch - 256; +} -- cgit