about summary refs log tree commit diff
path: root/steprl.c
blob: 39ae92e5642b5485d32fbd1a0ac6c71aee82da53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "ste.h"

char *
steprl(char *dst, char *end, long n)
{
	if (dst >= end)
		return end;

	char buf[24];
	char *bufend = buf + sizeof buf;
	char *s = bufend;

	unsigned long u = n < 0 ? -n : n;

	do {
		*--s = '0' + (u % 10);
		u /= 10;
	} while (u);

	if (n < 0)
		*--s = '-';

	return stecpe(dst, end, s, bufend);
}