about summary refs log tree commit diff
path: root/steprl.c
diff options
context:
space:
mode:
Diffstat (limited to 'steprl.c')
-rw-r--r--steprl.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/steprl.c b/steprl.c
new file mode 100644
index 0000000..5c14a23
--- /dev/null
+++ b/steprl.c
@@ -0,0 +1,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);
+}