summaryrefslogtreecommitdiff
path: root/src/libstddjb/int64_fmt_generic.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-07-11 16:19:36 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-07-11 16:19:36 +0000
commit9ec6602c9d3c1a8801d996aa3a56c779ce1c5f70 (patch)
tree5e545ff43b1e5890f0931c244a8b410eb036eb6c /src/libstddjb/int64_fmt_generic.c
parent846cd5b2b12947753f5fd3f02c49f7d828fb763d (diff)
downloadskalibs-9ec6602c9d3c1a8801d996aa3a56c779ce1c5f70.tar.xz
bits-fmtscan refactor, part one
Diffstat (limited to 'src/libstddjb/int64_fmt_generic.c')
-rw-r--r--src/libstddjb/int64_fmt_generic.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstddjb/int64_fmt_generic.c b/src/libstddjb/int64_fmt_generic.c
new file mode 100644
index 0000000..f57f915
--- /dev/null
+++ b/src/libstddjb/int64_fmt_generic.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/uint64.h>
+
+size_t int64_fmt_generic (char *fmt, int64_t d, uint8_t base)
+{
+ if (d >= 0) return uint64_fmt_generic(fmt, (uint64_t)d, base) ;
+ if (fmt) *fmt++ = '-' ;
+ return 1 + uint64_fmt_generic(fmt, -(uint64_t)d, base) ;
+}