summaryrefslogtreecommitdiffhomepage
path: root/ir/obstack
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2010-05-04 15:13:45 +0200
committerMatthias Braun <matze@braunis.de>2010-05-04 15:13:45 +0200
commitbb6d574bb9c74fca9f205b94aef021e57832aaad (patch)
tree81eda8dce328899cc0ca6c9d2fbcbb771f67aaa0 /ir/obstack
parentec9bf8c53e9a750f39225ff384fcfad7c0303850 (diff)
implement obstack_vprintf
[r27479]
Diffstat (limited to 'ir/obstack')
-rw-r--r--ir/obstack/obstack_printf.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/ir/obstack/obstack_printf.c b/ir/obstack/obstack_printf.c
index 836ffa8..a8b5a98 100644
--- a/ir/obstack/obstack_printf.c
+++ b/ir/obstack/obstack_printf.c
@@ -8,18 +8,15 @@
#define vsnprintf _vsnprintf
#endif
-int obstack_printf(struct obstack *obst, const char *fmt, ...)
+int obstack_vprintf(struct obstack *obst, const char *fmt, va_list ap)
{
char buf[128];
char *buffer = buf;
size_t size = sizeof(buf);
- va_list ap;
int len;
for (;;) {
- va_start(ap, fmt);
len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
- va_end(ap);
/* snprintf should return -1 only in the error case, but older glibcs
* and probably other systems are buggy in this respect and return -1 if
@@ -47,3 +44,15 @@ int obstack_printf(struct obstack *obst, const char *fmt, ...)
return len;
}
+
+int obstack_printf(struct obstack *obst, const char *fmt, ...)
+{
+ va_list ap;
+ int res;
+
+ va_start(ap, fmt);
+ res = obstack_vprintf(obst, fmt, ap);
+ va_end(ap);
+
+ return res;
+}