From 087a6180190c5d1c597d06f763297716179d9574 Mon Sep 17 00:00:00 2001
From: Eric Andersen <andersen@codepoet.org>
Date: Sat, 29 Sep 2001 07:53:25 +0000
Subject: Add in gcvt()

---
 libc/stdlib/Makefile |  2 +-
 libc/stdlib/gcvt.c   | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 libc/stdlib/gcvt.c

(limited to 'libc/stdlib')

diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile
index cff8ada0a..c228cd9d6 100644
--- a/libc/stdlib/Makefile
+++ b/libc/stdlib/Makefile
@@ -38,7 +38,7 @@ MOBJ2=atexit.o exit.o
 
 CSRC =	abort.c getenv.c mktemp.c qsort.c realpath.c abs.c bsearch.c \
 	mkstemp.c putenv.c rand.c random.c setenv.c system.c div.c ldiv.c \
-	getpt.c ptsname.c grantpt.c unlockpt.c
+	getpt.c ptsname.c grantpt.c unlockpt.c gcvt.c
 ifeq ($(HAS_FLOATING_POINT),true)
 	CSRC += strtod.c
 endif
diff --git a/libc/stdlib/gcvt.c b/libc/stdlib/gcvt.c
new file mode 100644
index 000000000..4ce5cf4ee
--- /dev/null
+++ b/libc/stdlib/gcvt.c
@@ -0,0 +1,11 @@
+
+#include <stdlib.h>
+
+#ifdef __UCLIBC_HAS_FLOATS__
+#define MAX_NDIGIT 17
+char * gcvt(double number, size_t ndigit, char* buf)
+{
+    sprintf(buf, "%.*g", (ndigit > MAX_NDIGIT)? MAX_NDIGIT : ndigit, number);
+    return buf;
+}
+#endif
-- 
cgit v1.2.3