+ /*
+ * The HANG flag means that the next field
+ * always follows on the same line.
+ * The NOBREAK flag means that the next field
+ * follows on the same line unless the field was overrun.
+ * Normally, break the line at the end of each field.
+ */
+
+ if ((p->flags & TERMP_HANG) == 0 &&
+ ((p->flags & TERMP_NOBREAK) == 0 ||
+ vbr + term_len(p, p->trailspace) > vfield))
+ endline(p);
+}
+
+/*
+ * Store the number of input characters to print in this field in *nbr
+ * and their total visual width to print in *vbr.
+ * If there is only whitespace in the field, both remain zero.
+ * The desired visual width of the field is provided by vtarget.
+ * If the first word is longer, the field will be overrun.
+ */
+static void
+term_fill(struct termp *p, size_t *nbr, size_t *vbr, size_t vtarget)
+{
+ size_t ic; /* Character position in the input buffer. */
+ size_t vis; /* Visual position of the current character. */
+ size_t vn; /* Visual position of the next character. */
+ int breakline; /* Break at the end of this word. */
+ int graph; /* Last character was non-blank. */
+
+ *nbr = *vbr = vis = 0;
+ breakline = graph = 0;
+ for (ic = p->tcol->col; ic < p->tcol->lastcol; ic++) {
+ switch (p->tcol->buf[ic]) {
+ case '\b': /* Escape \o (overstrike) or backspace markup. */
+ assert(ic > 0);
+ vis -= (*p->width)(p, p->tcol->buf[ic - 1]);
+ continue;
+
+ case '\t': /* Normal ASCII whitespace. */
+ case ' ':
+ case ASCII_BREAK: /* Escape \: (breakpoint). */
+ switch (p->tcol->buf[ic]) {
+ case '\t':
+ vn = term_tab_next(vis);