From db04688faa20f3576257c0fe41752ec435beab9a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:25 -0800 Subject: Import Upstream version 5c3 --- unif.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 97 insertions(+), 17 deletions(-) (limited to 'unif.c') diff --git a/unif.c b/unif.c index 6a5fe84..35fc86e 100644 --- a/unif.c +++ b/unif.c @@ -107,9 +107,8 @@ SCM resizuve(vect, len) siz = l * sz; if (siz != l * sz) wta(MAKINUM(l * sz), (char *) NALLOC, s_resizuve); DEFER_INTS; - SETCHARS(vect, (char *)must_realloc((char *)CHARS(vect), - (long)LENGTH(vect)*sz, - (long)siz, s_resizuve)); + must_realloc_cell(vect, (long)LENGTH(vect)*sz, + (long)siz, s_resizuve); if VECTORP(vect) { sz = LENGTH(vect); while(l > sz) VELTS(vect)[--l] = UNSPECIFIED; @@ -144,13 +143,13 @@ SCM make_uve(k, prot) SCM prot; { SCM v; - long i, type; + long i, type; if (BOOL_T==prot) { i = sizeof(long)*((k+LONG_BIT-1)/LONG_BIT); type = tc7_bvect; } else if ICHRP(prot) { - i = sizeof(char)*k; + i = sizeof(char)*(k + 1); type = tc7_string; } else if INUMP(prot) { @@ -191,11 +190,10 @@ SCM make_uve(k, prot) type = tc7_dvect; } # endif - - NEWCELL(v); DEFER_INTS; - SETCHARS(v, must_malloc((i ? i : 1L), s_vector)); + v = must_malloc_cell((i ? i : 1L), s_vector); SETLENGTH(v, (k 0) iprin1(ulong2num(VELTS(ra)[j]), port, writing); + if (n-- > 0) intprint(VELTS(ra)[j], -10, port); for (j += inc; n-- > 0; j += inc) { lputc(' ', port); - iprin1(ulong2num(VELTS(ra)[j]), port, writing); + intprint(VELTS(ra)[j], -10, port); } break; case tc7_ivect: @@ -1896,6 +1892,88 @@ SCM array_prot(ra) } } +/* Looks like ARRAY-REF, if just enough indices are provided, + If one extra is provided then the last index specifies bit + position in an integer element. +*/ +static char s_logaref[] = "logaref"; +SCM scm_logaref(args) + SCM args; +{ + SCM ra, inds, ibit; + int i, rank = 1; + ASSERT(NIMP(args), UNDEFINED, WNA, s_logaref); + ra = CAR(args); + ASSERT(NIMP(ra), ra, ARG1, s_logaref); + if ARRAYP(ra) rank = ARRAY_NDIM(ra); + inds = args = CDR(args); + for (i = rank; i; i--) { + ASSERT(NIMP(args) && CONSP(args), UNDEFINED, WNA, s_logaref); + args = CDR(args); + } + if NULLP(args) return aref(ra, inds); + ASSERT(NIMP(args) && CONSP(args) && NULLP(CDR(args)), + inds, WNA, s_logaref); + ASSERT(INUMP(CAR(args)), CAR(args), ARGn, s_logaref); + ibit = CAR(args); + if (1==rank) + inds = CAR(inds); + else { /* Destructively modify arglist */ + args = inds; + for (i = rank-1; i; i--) { + ASSERT(NIMP(args) && CONSP(args), UNDEFINED, WNA, s_logaref); + args = CDR(args); + } + CDR(args) = EOL; + } + args = aref(ra, inds); + return INUMP(args) ? + ((1<