standards/51209: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD)

Stefan Farfeleder stefan at fafoe.dyndns.org
Mon Apr 21 05:00:23 PDT 2003


The following reply was made to PR standards/51209; it has been noted by GNATS.

From: Stefan Farfeleder <stefan at fafoe.dyndns.org>
To: bug-followup at FreeBSD.org
Cc:  
Subject: Re: standards/51209: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD)
Date: Mon, 21 Apr 2003 13:52:01 +0200

 On Mon, Apr 21, 2003 at 02:59:46PM +0400, Sergey A.Osokin wrote:
 
 > +int
 > +l64a_r (long value, char *buffer, int buflen)
 > +{
 > +	char *s = buffer;
 > +	int digit;
 > +	unsigned long v = value;
 	^^^^^^^^^^^^^
 Shouldn't this be 'uint32_t'?  According to SUSv3:
 
 "If the type long contains more than 32 bits, only the low-order 32 bits
 shall be used for these operations."
 
 > +
 > +	_DIAGASSERT(buffer != NULL);
 > +
 > +	if (value == 0UL) 
 > +		goto out;
 > +
 > +	for (; v != 0 && buflen > 1; s++, buflen--) {
 > +		digit = (int)(v & 0x3f);
 > +
 > +		if (digit < 2) 
 > +			*s = digit + '.';
 > +		else if (digit < 12)
 > +			*s = digit + '0' - 2;
 > +		else if (digit < 38)
 > +			*s = digit + 'A' - 12;
 > +		else
 > +			*s = digit + 'a' - 38;
 > +		v >>= 6;
 > +	}
 > +
 > +out:
 > +	*s = '\0';
 > +
 > +	return (v == 0UL ? 0 : -1);
 > +}


More information about the freebsd-standards mailing list