about summary refs log tree commit diff
path: root/steprl.c
blob: 5c14a23123013e657ad514ea6571083fa2eabce0 (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
25
#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;

	int neg = n < 0;
	if (neg)
		n = -n;

	if (!n)
		*--s = '0';
	for (; n > 0; n /= 10)
		*--s = '0' + (n%10);
	if (neg)
		*--s = '-';

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