14bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes/****************************************************************
24bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
34bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesThe author of this software is David M. Gay.
44bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
54bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesCopyright (C) 1998 by Lucent Technologies
64bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesAll Rights Reserved
74bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
84bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesPermission to use, copy, modify, and distribute this software and
94bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesits documentation for any purpose and without fee is hereby
104bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesgranted, provided that the above copyright notice appear in all
114bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughescopies and that both that the copyright notice and this
124bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughespermission notice and warranty disclaimer appear in supporting
134bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesdocumentation, and that the name of Lucent or any of its entities
144bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesnot be used in advertising or publicity pertaining to
154bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesdistribution of the software without specific, written prior
164bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughespermission.
174bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
184bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
194bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
204bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
214bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
224bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
234bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
244bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
254bd97cee28dd815fff54fc97560be60d566c1fa5Elliott HughesTHIS SOFTWARE.
264bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
274bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes****************************************************************/
284bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
294bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes/* Please send bug reports to David M. Gay (dmg at acm dot org,
304bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes * with " at " changed at "@" and " dot " changed to ".").	*/
314bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
324bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#include "gdtoaimp.h"
334bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
344bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifndef MULTIPLE_THREADS
354bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes char *dtoa_result;
364bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
374bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
384bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes char *
394bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef KR_headers
404bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesrv_alloc(i) int i;
414bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
424bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesrv_alloc(int i)
434bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
444bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes{
454bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	int j, k, *r;
464bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
474bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	j = sizeof(ULong);
484bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	for(k = 0;
494bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
504bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		j <<= 1)
514bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			k++;
524bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	r = (int*)Balloc(k);
534bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	if (r == NULL)
544bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		return (
554bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifndef MULTIPLE_THREADS
564bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		dtoa_result =
574bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
584bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			NULL);
594bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	*r = k;
604bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	return
614bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifndef MULTIPLE_THREADS
624bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	dtoa_result =
634bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
644bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		(char *)(r+1);
654bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	}
664bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
674bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes char *
684bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef KR_headers
694bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesnrv_alloc(s, rve, n) char *s, **rve; int n;
704bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
714bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesnrv_alloc(char *s, char **rve, int n)
724bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
734bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes{
744bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	char *rv, *t;
754bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
764bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	t = rv = rv_alloc(n);
774bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	if (t == NULL)
784bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		return (NULL);
794bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	while((*t = *s++) !=0)
804bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		t++;
814bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	if (rve)
824bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		*rve = t;
834bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	return rv;
844bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	}
854bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
864bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes/* freedtoa(s) must be used to free values s returned by dtoa
874bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes * when MULTIPLE_THREADS is #defined.  It should be used in all cases,
884bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes * but for consistency with earlier versions of dtoa, it is optional
894bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes * when MULTIPLE_THREADS is not defined.
904bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes */
914bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
924bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes void
934bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef KR_headers
944bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesfreedtoa(s) char *s;
954bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
964bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesfreedtoa(char *s)
974bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
984bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes{
994bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	Bigint *b = (Bigint *)((int *)s - 1);
1004bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	b->maxwds = 1 << (b->k = *(int*)b);
1014bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	Bfree(b);
1024bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifndef MULTIPLE_THREADS
1034bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	if (s == dtoa_result)
1044bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		dtoa_result = 0;
1054bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
1064bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	}
1074bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
1084bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes int
1094bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughesquorem
1104bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef KR_headers
1114bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	(b, S) Bigint *b, *S;
1124bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
1134bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	(Bigint *b, Bigint *S)
1144bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
1154bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes{
1164bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	int n;
1174bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	ULong *bx, *bxe, q, *sx, *sxe;
1184bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef ULLong
1194bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	ULLong borrow, carry, y, ys;
1204bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
1214bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	ULong borrow, carry, y, ys;
1224bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef Pack_32
1234bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	ULong si, z, zs;
1244bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
1254bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
1264bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes
1274bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	n = S->wds;
1284bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef DEBUG
1294bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	/*debug*/ if (b->wds > n)
1304bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	/*debug*/	Bug("oversize b in quorem");
1314bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
1324bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	if (b->wds < n)
1334bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		return 0;
1344bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	sx = S->x;
1354bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	sxe = sx + --n;
1364bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	bx = b->x;
1374bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	bxe = bx + n;
1384bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	q = *bxe / (*sxe + 1);	/* ensure q <= true quotient */
1394bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef DEBUG
1404bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	/*debug*/ if (q > 9)
1414bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	/*debug*/	Bug("oversized quotient in quorem");
1424bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
1434bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	if (q) {
1444bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		borrow = 0;
1454bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		carry = 0;
1464bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		do {
1474bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef ULLong
1484bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			ys = *sx++ * (ULLong)q + carry;
1494bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			carry = ys >> 32;
1504bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			y = *bx - (ys & 0xffffffffUL) - borrow;
1514bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			borrow = y >> 32 & 1UL;
1524bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			*bx++ = y & 0xffffffffUL;
1534bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
1544bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef Pack_32
1554bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			si = *sx++;
1564bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			ys = (si & 0xffff) * q + carry;
1574bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			zs = (si >> 16) * q + (ys >> 16);
1584bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			carry = zs >> 16;
1594bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
1604bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			borrow = (y & 0x10000) >> 16;
1614bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			z = (*bx >> 16) - (zs & 0xffff) - borrow;
1624bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			borrow = (z & 0x10000) >> 16;
1634bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			Storeinc(bx, z, y);
1644bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
1654bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			ys = *sx++ * q + carry;
1664bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			carry = ys >> 16;
1674bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			y = *bx - (ys & 0xffff) - borrow;
1684bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			borrow = (y & 0x10000) >> 16;
1694bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			*bx++ = y & 0xffff;
1704bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
1714bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
1724bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			}
1734bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			while(sx <= sxe);
1744bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		if (!*bxe) {
1754bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			bx = b->x;
1764bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			while(--bxe > bx && !*bxe)
1774bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes				--n;
1784bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			b->wds = n;
1794bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			}
1804bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		}
1814bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	if (cmp(b, S) >= 0) {
1824bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		q++;
1834bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		borrow = 0;
1844bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		carry = 0;
1854bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		bx = b->x;
1864bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		sx = S->x;
1874bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		do {
1884bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef ULLong
1894bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			ys = *sx++ + carry;
1904bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			carry = ys >> 32;
1914bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			y = *bx - (ys & 0xffffffffUL) - borrow;
1924bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			borrow = y >> 32 & 1UL;
1934bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			*bx++ = y & 0xffffffffUL;
1944bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
1954bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#ifdef Pack_32
1964bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			si = *sx++;
1974bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			ys = (si & 0xffff) + carry;
1984bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			zs = (si >> 16) + (ys >> 16);
1994bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			carry = zs >> 16;
2004bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
2014bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			borrow = (y & 0x10000) >> 16;
2024bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			z = (*bx >> 16) - (zs & 0xffff) - borrow;
2034bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			borrow = (z & 0x10000) >> 16;
2044bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			Storeinc(bx, z, y);
2054bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#else
2064bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			ys = *sx++ + carry;
2074bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			carry = ys >> 16;
2084bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			y = *bx - (ys & 0xffff) - borrow;
2094bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			borrow = (y & 0x10000) >> 16;
2104bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			*bx++ = y & 0xffff;
2114bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
2124bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes#endif
2134bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			}
2144bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			while(sx <= sxe);
2154bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		bx = b->x;
2164bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		bxe = bx + n;
2174bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		if (!*bxe) {
2184bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			while(--bxe > bx && !*bxe)
2194bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes				--n;
2204bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			b->wds = n;
2214bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes			}
2224bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes		}
2234bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	return q;
2244bd97cee28dd815fff54fc97560be60d566c1fa5Elliott Hughes	}
225