+/* A wrapper around data_out() that limits string output to short
+ string width and null terminates the result. */
+static void
+format_short (char *s, const struct fmt_spec *fp, const union value *v)
+{
+ struct fmt_spec fmt_subst;
+
+ /* Limit to short string width. */
+ if (formats[fp->type].cat & FCAT_STRING)
+ {
+ fmt_subst = *fp;
+
+ assert (fmt_subst.type == FMT_A || fmt_subst.type == FMT_AHEX);
+ if (fmt_subst.type == FMT_A)
+ fmt_subst.w = min (8, fmt_subst.w);
+ else
+ fmt_subst.w = min (16, fmt_subst.w);
+
+ fp = &fmt_subst;
+ }
+
+ /* Format. */
+ data_out (s, fp, v);
+
+ /* Null terminate. */
+ s[fp->w] = '\0';
+}
+