summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJuliusz Chroboczek <jch@pps.jussieu.fr>2008-05-02 19:24:21 +0200
committerJuliusz Chroboczek <jch@pps.jussieu.fr>2008-05-02 19:24:21 +0200
commit4ecd697abe1026eb27e1373bf357ebca2ade4138 (patch)
tree75b68f89cf454ebfc129cb945dab70bc84c29698 /util.c
parent5cb6dcac85b89deea8263e1b7bcb7714e07063ff (diff)
Use asprintf on GNU platforms.
This fixes fonttosfnt on AMD64 with glibc. It will still break on non-GNU RISC platforms, because I'm incompetent and cannot use va_copy.
Diffstat (limited to 'util.c')
-rw-r--r--util.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/util.c b/util.c
index 2d0d1c0..5c58b9a 100644
--- a/util.c
+++ b/util.c
@@ -77,8 +77,22 @@ sprintf_reliable(char *f, ...)
s = vsprintf_reliable(f, args);
va_end(args);
return s;
-}
+}
+#ifdef __GLIBC__
+char*
+vsprintf_reliable(char *f, va_list args)
+{
+ char *r;
+ int rc;
+
+ rc = vasprintf(&r, f, args);
+ if(rc < 0)
+ return NULL;
+ return r;
+}
+#else
+/* This is not portable, doesn't do va_copy right. */
char*
vsprintf_reliable(char *f, va_list args)
{
@@ -101,6 +115,7 @@ vsprintf_reliable(char *f, va_list args)
}
/* NOTREACHED */
}
+#endif
/* Build a UTF-16 string from a Latin-1 string.
Result is not NUL-terminated. */