[BACK]Return to l64a.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / stdlib

File: [cvs.NetBSD.org] / src / lib / libc / stdlib / l64a.c (download)

Revision 1.12, Sat Jan 22 22:19:19 2000 UTC (20 years, 1 month ago) by mycroft
Branch: MAIN
CVS Tags: netbsd-1-6-base, netbsd-1-6-RELEASE, netbsd-1-6-RC3, netbsd-1-6-RC2, netbsd-1-6-RC1, netbsd-1-6-PATCH002-RELEASE, netbsd-1-6-PATCH002-RC4, netbsd-1-6-PATCH002-RC3, netbsd-1-6-PATCH002-RC2, netbsd-1-6-PATCH002-RC1, netbsd-1-6-PATCH002, netbsd-1-6-PATCH001-RELEASE, netbsd-1-6-PATCH001-RC3, netbsd-1-6-PATCH001-RC2, netbsd-1-6-PATCH001-RC1, netbsd-1-6-PATCH001, netbsd-1-6, netbsd-1-5-base, netbsd-1-5-RELEASE, netbsd-1-5-PATCH003, netbsd-1-5-PATCH002, netbsd-1-5-PATCH001, netbsd-1-5-BETA2, netbsd-1-5-BETA, netbsd-1-5-ALPHA2, netbsd-1-5, nathanw_sa_end, nathanw_sa_before_merge, nathanw_sa_base, nathanw_sa, minoura-xpg4dl-base, minoura-xpg4dl, fvdl_fs64_base
Changes since 1.11: +4 -4 lines

Delint.
Remove trailing ; from uses of __weak_alias().  The macro inserts this if
needed.

/*	$NetBSD: l64a.c,v 1.12 2000/01/22 22:19:19 mycroft Exp $	*/

/*
 * Written by J.T. Conklin <jtc@netbsd.org>.
 * Public domain.
 */

#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: l64a.c,v 1.12 2000/01/22 22:19:19 mycroft Exp $");
#endif

#include "namespace.h"

#include <assert.h>
#include <errno.h>
#include <stdlib.h>

#ifdef __weak_alias
__weak_alias(l64a,_l64a)
__weak_alias(l64a_r,_l64a_r)
#endif

char *
l64a (value)
	long value;
{
	static char buf[8];

	(void)l64a_r(value, buf, sizeof (buf));
	return buf;
}

int
l64a_r (value, buffer, buflen)
	long value;
	char *buffer;
	int buflen;
{
	char *s = buffer;
	int digit;
	unsigned long v = value;

	_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);
}