+#if 0
+static int is_std_fmt(const char *fmt)
+{
+ static const char *fmt_re_str =
+ "^[0 -+#']?[1-9]*(\\.[1-9]*)?[hlLqjzt]?[diouxXeEfFgGaAc]";
+
+ static regex_t fmt_re;
+ static int preapred_re = 0;
+
+ regmatch_t match[1];
+ int res;
+
+ if(!preapred_re) {
+ int res = regcomp(&fmt_re, fmt_re_str, REG_EXTENDED);
+ assert(res == 0 && "Could not prepare regex");
+ preapred_re = 1;
+ }
+
+ res = regexec(&fmt_re, fmt, 1, &match[0], 0);
+
+#if 0
+ if(res != 0) {
+ char buf[256];
+ regerror(res, &fmt_re, buf, sizeof(buf));
+ printf("%s ", buf);
+ }
+
+ printf("res: %d, start: %d, end: %d\n",
+ res, match[0].rm_so, match[0].rm_eo);
+#endif
+
+ return res == 0 ? match[0].rm_eo : -1;
+}
+#endif
+
+struct settings {
+ char pad;
+ int width;
+ int left_just;
+ int put_plus;
+ int alternate;
+};
+
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+
+
+static void dump_with_settings(const appender_t *app, void *object, size_t limit,
+ const struct settings *settings, const char *str)
+{
+ if(settings->width >= 0) {
+ int i;
+ size_t n = strlen(str);
+ int lim = MIN(settings->width, limit);
+ int to_print = MIN(lim, n);
+ int to_pad = to_print - lim;
+
+ if(!settings->left_just)
+ for(i = 0; i < to_pad; ++i)
+ app->append_char(object, lim, settings->pad);
+
+ app->append_str(object, to_print, str);
+
+ if(!settings->left_just)
+ for(i = 0; i < to_pad; ++i)
+ app->append_char(object, lim, settings->pad);
+ }
+
+ else
+ app->append_str(object, limit, str);
+}
+
+
+
+/* Length specifiers. */
+enum {
+ len_char,
+ len_short,
+ len_int,
+ len_long,
+ len_long_long
+};
+
+