summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2013-06-13 10:54:39 -0400
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-06-14 10:44:08 +0200
commit10d12e77d5cdffd064719356a87f839225916a4a (patch)
tree0e367602e34de44b29411856930fe9d2930b5c6d /libc
parentf143f920694cec922ed2ac4082aab223acc413df (diff)
libc/misc/gnu/obprintf.c: implement obstack_printf and obstack_vprintf
This adds a straight forward implementation for obstack_printf and obstack_vprintf on uClibc's already existing obstack_grow and vasprintf. It does not attempt to port over glibc's implementation in terms of _IO_* structs and functions. Signed-off-by: Anthony G. Basile <blueness@gentoo.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/gnu/Makefile.in2
-rw-r--r--libc/misc/gnu/obprintf.c35
2 files changed, 36 insertions, 1 deletions
diff --git a/libc/misc/gnu/Makefile.in b/libc/misc/gnu/Makefile.in
index d820746ed..5106b479b 100644
--- a/libc/misc/gnu/Makefile.in
+++ b/libc/misc/gnu/Makefile.in
@@ -7,7 +7,7 @@
subdirs += libc/misc/gnu
-CSRC-$(UCLIBC_HAS_OBSTACK) := obstack.c
+CSRC-$(UCLIBC_HAS_OBSTACK) := obstack.c obprintf.c
MISC_GNU_DIR := $(top_srcdir)libc/misc/gnu
MISC_GNU_OUT := $(top_builddir)libc/misc/gnu
diff --git a/libc/misc/gnu/obprintf.c b/libc/misc/gnu/obprintf.c
new file mode 100644
index 000000000..70c058fe5
--- /dev/null
+++ b/libc/misc/gnu/obprintf.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2013 Gentoo Foundation
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#ifdef _LIBC
+# include <obstack.h>
+#else
+# include "obstack.h"
+#endif
+
+int
+_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
+{
+ int n;
+ char *s;
+ n = vasprintf(&s, format, args);
+ obstack_grow(obstack, s, n);
+ return n;
+}
+weak_alias (_obstack_vprintf, obstack_vprintf)
+
+int
+_obstack_printf (struct obstack *obstack, const char *format, ...)
+{
+ int n;
+ va_list ap;
+ va_start (ap, format);
+ n = _obstack_vprintf (obstack, format, ap);
+ va_end (ap);
+ return n;
+}
+weak_alias (_obstack_printf, obstack_printf)