+/*
+ * In the NLS-disabled case, all format strings are of the form
+ *
+ * "blah blah %s"
+ *
+ * so we exploit this to implement a simple snprintf workalike using the
+ * libcdecl output helpers directly.
+ *
+ * In the NLS-enabled case, we have to use snprintf as format strings may
+ * be translated. GNU libintl ensures a suitable version is available.
+ */
+static size_t
+fmt_err(struct err_state *state, const char *fmt, const char *arg)
+{
+#if ENABLE_NLS
+ snprintf(state->str, state->nstr, fmt, arg);
+ return strlen(fmt) + strlen(arg);
+#else
+ struct output_state dst = { state->str, state->nstr };
+ size_t rc;
+
+ rc = cdecl__strlcpy(dst.dst, fmt, dst.dstlen);
+ cdecl__advance(&dst, rc-2);
+ cdecl__emit(&dst, arg);
+
+ return dst.accum;
+#endif
+}
+