]> git.draconx.ca Git - dxcommon.git/blobdiff - t/nls/gettext.h
help_print_optstring: Don't depend on snprintf.
[dxcommon.git] / t / nls / gettext.h
index b8a8060bc4bfc4760662ed097a0f2c6e52762745..83929924f718ccde6bcb58fb095618f218b085bc 100644 (file)
 #ifndef TEST_NLS_GETTEXT_H_
 #define TEST_NLS_GETTEXT_H_
 
+#include <stdio.h>
+#include <stdarg.h>
+
 #define gettext(s) (s)
 #define pgettext_expr(a, s) (s)
 
+/*
+ * We don't need a real snprintf for testing help functionality; substitute
+ * using vsprintf to ease testing on C89 implementations.
+ */
+#define help_do_snprintf help_do_snprintf
+static inline int help_do_snprintf(char *buf, size_t n, const char *fmt, ...)
+{
+       va_list ap;
+       int ret;
+
+       va_start(ap, fmt);
+       ret = vsprintf(buf, fmt, ap);
+       va_end(ap);
+
+       return ret;
+}
+
 #endif