summaryrefslogtreecommitdiff
path: root/lib/snprintf.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-09-28 10:50:20 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-09-28 10:50:20 -0700
commit304b60556397464143c6fc24edb856b03fc9781a (patch)
tree230a24f6dc769b2e54088cebe34db0a7829bf681 /lib/snprintf.c
parentbb2018587b4e14a170a648d08dcdd74dc995d8ce (diff)
downloadnasm-304b60556397464143c6fc24edb856b03fc9781a.tar.gz
Add substitutes for snprintf() and vsnprintf()
To deal with fools^Wpeople trying to keep really old systems alive, create a proper framework for substitution functions, and make it possible to deal with the lack of snprintf/vsnprintf in particular.
Diffstat (limited to 'lib/snprintf.c')
-rw-r--r--lib/snprintf.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/snprintf.c b/lib/snprintf.c
new file mode 100644
index 00000000..f56a492a
--- /dev/null
+++ b/lib/snprintf.c
@@ -0,0 +1,24 @@
+/*
+ * snprintf()
+ *
+ * Implement snprintf() in terms of vsnprintf()
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "nasmlib.h"
+
+int snprintf(char *str, size_t size, const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, format);
+ rv = vsnprintf(str, size, format, ap);
+ va_end(ap);
+
+ return rv;
+}
+