summaryrefslogtreecommitdiff
path: root/fmt_ulong.c
diff options
context:
space:
mode:
authorDmitry Bogatov <KAction@debian.org>2018-11-29 05:18:27 +0000
committerDmitry Bogatov <KAction@debian.org>2018-11-29 05:18:27 +0000
commit78fbb41eaf3abb208abe6acfb06db005adeadf35 (patch)
treef09dac61e9f2fe6d865d76d57dac12674eec1279 /fmt_ulong.c
Import Upstream version 0.80
Diffstat (limited to 'fmt_ulong.c')
-rw-r--r--fmt_ulong.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fmt_ulong.c b/fmt_ulong.c
new file mode 100644
index 0000000..ab12e8c
--- /dev/null
+++ b/fmt_ulong.c
@@ -0,0 +1,13 @@
+#include "fmt.h"
+
+unsigned int fmt_ulong(s,u) register char *s; register unsigned long u;
+{
+ register unsigned int len; register unsigned long q;
+ len = 1; q = u;
+ while (q > 9) { ++len; q /= 10; }
+ if (s) {
+ s += len;
+ do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */
+ }
+ return len;
+}