+ if (TPremain)
+ TPremain--;
+ }
+ outflags &= ~MMAN_nbrword;
+}
+
+static void
+print_line(const char *s, int newflags)
+{
+
+ outflags &= ~MMAN_br;
+ outflags |= MMAN_nl;
+ print_word(s);
+ outflags |= newflags;
+}
+
+static void
+print_block(const char *s, int newflags)
+{
+
+ outflags &= ~MMAN_PP;
+ if (MMAN_sp & outflags) {
+ outflags &= ~(MMAN_sp | MMAN_br);
+ if (MMAN_PD & outflags) {
+ print_line(".PD", 0);
+ outflags &= ~MMAN_PD;
+ }
+ } else if (! (MMAN_PD & outflags))
+ print_line(".PD 0", MMAN_PD);
+ outflags |= MMAN_nl;
+ print_word(s);
+ outflags |= MMAN_Bk_susp | newflags;
+}
+
+static void
+print_offs(const char *v)
+{
+ char buf[24];
+ struct roffsu su;
+ size_t sz;
+
+ print_line(".RS", MMAN_Bk_susp);
+
+ /* Convert v into a number (of characters). */
+ if (NULL == v || '\0' == *v || 0 == strcmp(v, "left"))
+ sz = 0;
+ else if (0 == strcmp(v, "indent"))
+ sz = 6;
+ else if (0 == strcmp(v, "indent-two"))
+ sz = 12;
+ else if (a2roffsu(v, &su, SCALE_MAX)) {
+ if (SCALE_EN == su.unit)
+ sz = su.scale;
+ else {
+ /*
+ * XXX
+ * If we are inside an enclosing list,
+ * there is no easy way to add the two
+ * indentations because they are provided
+ * in terms of different units.
+ */
+ print_word(v);
+ outflags |= MMAN_nl;
+ return;
+ }
+ } else
+ sz = strlen(v);
+
+ /*
+ * We are inside an enclosing list.
+ * Add the two indentations.
+ */
+ if (Bl_stack_len)
+ sz += Bl_stack[Bl_stack_len - 1];
+
+ snprintf(buf, sizeof(buf), "%zun", sz);
+ print_word(buf);
+ outflags |= MMAN_nl;
+}
+
+/*
+ * Set up the indentation for a list item; used from pre_it().
+ */
+void
+print_width(const char *v, const struct mdoc_node *child, size_t defsz)
+{
+ char buf[24];
+ struct roffsu su;
+ size_t sz, chsz;
+ int numeric, remain;
+
+ numeric = 1;
+ remain = 0;
+
+ /* Convert v into a number (of characters). */
+ if (NULL == v)
+ sz = defsz;
+ else if (a2roffsu(v, &su, SCALE_MAX)) {
+ if (SCALE_EN == su.unit)
+ sz = su.scale;
+ else {
+ sz = 0;
+ numeric = 0;
+ }
+ } else
+ sz = strlen(v);
+
+ /* XXX Rough estimation, might have multiple parts. */
+ chsz = (NULL != child && MDOC_TEXT == child->type) ?
+ strlen(child->string) : 0;
+
+ /* Maybe we are inside an enclosing list? */
+ mid_it();
+
+ /*
+ * Save our own indentation,
+ * such that child lists can use it.
+ */
+ Bl_stack[Bl_stack_len++] = sz + 2;
+
+ /* Set up the current list. */
+ if (defsz && chsz > sz)
+ print_block(".HP", 0);
+ else {
+ print_block(".TP", 0);
+ remain = sz + 2;