Not exactly recommended for use, rather for groff compatibility.
While here, introduce similar SHRT_MAX limits as in man(7),
fixing a few cases of infinite output found by jsg@ with afl.
-# $OpenBSD: Makefile,v 1.17 2014/11/10 20:59:41 schwarze Exp $
+# $OpenBSD: Makefile,v 1.18 2014/12/24 23:31:59 schwarze Exp $
REGRESS_TARGETS = beforeNAME blank centered nested spacing
-REGRESS_TARGETS += badargs empty offset-empty
+REGRESS_TARGETS += badargs empty offset-empty offset-neg
REGRESS_TARGETS += break broken unclosed
LINT_TARGETS = beforeNAME blank nested badargs break broken unclosed
SKIP_TMAN = beforeNAME centered
-# groff-1.22.2 defect:
+# groff-1.22.3 defects:
# - a display breaking another block continues indefinitely
+# - negative offsets take no effect, but advance the indention on exit
-SKIP_GROFF = break
+SKIP_GROFF = break offset-neg
# adjustment is disabled in groff for now
--- /dev/null
+.Dd December 24, 2014
+.Dt BD-INDENT 1
+.Os OpenBSD
+.Sh NAME
+.Nm Bd-indent
+.Nd indenting display blocks
+.Sh DESCRIPTION
+regular text
+.Bd -ragged -offset 8n
+outer display
+.Bd -ragged -offset -5n
+inner display
+.Ed
+outer display
+.Ed
+regular text
+.Bd -ragged -offset -3n
+outer display
+.Bd -ragged -offset 8n
+inner display
+.Ed
+outer display
+.Ed
+regular text
--- /dev/null
+BD-INDENT(1) General Commands Manual BD-INDENT(1)
+
+N\bNA\bAM\bME\bE
+ B\bBd\bd-\b-i\bin\bnd\bde\ben\bnt\bt - indenting display blocks
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ regular text
+
+ outer display
+
+ inner display
+ outer display
+ regular text
+
+ outer display
+
+ inner display
+ outer display
+ regular text
+
+OpenBSD December 24, 2014 OpenBSD
-.Dd June 17, 2009
+.Dd December 25, 2014
.Dt BL-BULLET 1
.Os OpenBSD
.Sh NAME
.Nm Bl-bullet
.Nd bullet lists
.Sh DESCRIPTION
+.Bl -bullet -width -4n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -bullet -width -3n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -bullet -width -2n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -bullet -width -1n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
.Bl -bullet -width 0n
.It
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
B\bBl\bl-\b-b\bbu\bul\bll\ble\bet\bt - bullet lists
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ +\b+\bo\bo x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+ +\b+\bo\bo x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+ +\b+\bo\bo x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+ +\b+\bo\bo x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+\b+\bo\bo x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x
+\b+\bo\bo x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x x
-OpenBSD June 17, 2009 OpenBSD
+OpenBSD December 25, 2014 OpenBSD
-.Dd June 17, 2009
+.Dd December 25, 2014
.Dt BL-DASH 1
.Os OpenBSD
.Sh NAME
.Nm Bl-dash
.Nd dash and hyphen lists
.Sh DESCRIPTION
+.Bl -dash -width -4n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -dash -width -3n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -dash -width -2n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -dash -width -1n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
.Bl -dash -width 0n
.It
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
B\bBl\bl-\b-d\bda\bas\bsh\bh - dash and hyphen lists
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ -\b- x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+ -\b- x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+ -\b- x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+ -\b- x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
-\b- x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x
-\b- x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x x
-OpenBSD June 17, 2009 OpenBSD
+OpenBSD December 25, 2014 OpenBSD
-.Dd June 17, 2009
+.Dd December 25, 2014
.Dt BL-ENUM 1
.Os OpenBSD
.Sh NAME
.Nm Bl-enum
.Nd enumerated lists
.Sh DESCRIPTION
+.Bl -enum -width -4n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -enum -width -3n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -enum -width -2n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -enum -width -1n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -enum -width 0n
+.It
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
.Bl -enum -width 1n
.It
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
B\bBl\bl-\b-e\ben\bnu\bum\bm - enumerated lists
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ 1. x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x
+
+ 1. x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x
+
+ 1. x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x
+
+ 1. x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x
+
+ 1. x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x
+
1. x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x x
12. x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x x x
-OpenBSD June 17, 2009 OpenBSD
+OpenBSD December 25, 2014 OpenBSD
-.Dd April 8, 2014
+.Dd December 25, 2014
.Dt BL-HANG 1
.Os OpenBSD
.Sh NAME
.Nm Bl-hang
.Nd hanged lists
.Sh DESCRIPTION
+.Bl -hang -width -4n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -hang -width -3n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -hang -width -2n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -hang -width -1n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -hang -width 0n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -hang -width 1n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -hang -width 2n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -hang -width 3n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -hang -width 4n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
.Bl -hang -width 5n
.It tag
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
B\bBl\bl-\b-h\bha\ban\bng\bg - hanged lists
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x x x x x x x
+
tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x x x x x x x x x x x
tag text
-OpenBSD April 8, 2014 OpenBSD
+OpenBSD December 25, 2014 OpenBSD
-.Dd November 20, 2014
+.Dd December 25, 2014
.Dt BL-OFFSET 1
.Os OpenBSD
.Sh NAME
.It
Bl item offset 78n
.El
+.Bl -item -offset -3n
+.It
+Bl item offset -3n
+.El
.Bl -tag -width Ds -offset
.It tag
Bl tag width Ds offset empty
.It tag
Bl tag width Ds offset 78n
.El
+.Bl -tag -width Ds -offset -3n
+.It tag
+Bl tag width Ds offset -3n
+.El
offset
78n
+ Bl item offset -3n
+
tag Bl tag width Ds offset empty
tag Bl tag width Ds offset left
offset
78n
-OpenBSD November 20, 2014 OpenBSD
+ tag Bl tag width Ds offset -3n
+
+OpenBSD December 25, 2014 OpenBSD
-.Dd November 16, 2014
+.Dd December 25, 2014
.Dt BL-TAG 1
.Os OpenBSD
.Sh NAME
.Nm Bl-tag
.Nd tagged lists
.Sh DESCRIPTION
+.Bl -tag -width -4n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -tag -width -3n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -tag -width -2n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -tag -width -1n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -tag -width 0n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -tag -width 1n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -tag -width 2n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -tag -width 3n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
+.Bl -tag -width 4n
+.It tag
+x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+.El
.Bl -tag -width 5n
.It tag
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
B\bBl\bl-\b-t\bta\bag\bg - tagged lists
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ tag
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x
+
+ tag
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x
+
+ tag
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x
+
+ tag
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+ tag
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x
+
+ tag
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x
+
+ tag
+ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x
+
+ tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+ x x x x x x
+
tag x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x x x x
second paragraph
-OpenBSD November 16, 2014 OpenBSD
+OpenBSD December 25, 2014 OpenBSD
-/* $OpenBSD: mdoc_man.c,v 1.78 2014/12/23 13:48:15 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.79 2014/12/24 23:31:59 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
static void print_line(const char *, int);
static void print_block(const char *, int);
static void print_offs(const char *, int);
-static void print_width(const char *,
- const struct mdoc_node *, size_t);
+static void print_width(const struct mdoc_bl *,
+ const struct mdoc_node *);
static void print_count(int *);
static void print_node(DECL_ARGS);
#define BL_STACK_MAX 32
-static size_t Bl_stack[BL_STACK_MAX]; /* offsets [chars] */
+static int Bl_stack[BL_STACK_MAX]; /* offsets [chars] */
static int Bl_stack_post[BL_STACK_MAX]; /* add final .RE */
static int Bl_stack_len; /* number of nested Bl blocks */
static int TPremain; /* characters before tag is full */
{
char buf[24];
struct roffsu su;
- size_t sz;
+ int sz;
print_line(".RS", MMAN_Bk_susp);
else if (keywords && !strcmp(v, "indent-two"))
sz = 12;
else if (a2roffsu(v, &su, SCALE_EN) > 1) {
- if (su.scale < 0.0)
- su.scale = 0.0;
if (SCALE_EN == su.unit)
sz = su.scale;
else {
if (Bl_stack_len)
sz += Bl_stack[Bl_stack_len - 1];
- (void)snprintf(buf, sizeof(buf), "%zun", sz);
+ (void)snprintf(buf, sizeof(buf), "%dn", sz);
print_word(buf);
outflags |= MMAN_nl;
}
* Set up the indentation for a list item; used from pre_it().
*/
static void
-print_width(const char *v, const struct mdoc_node *child, size_t defsz)
+print_width(const struct mdoc_bl *bl, const struct mdoc_node *child)
{
char buf[24];
struct roffsu su;
- size_t sz, chsz;
- int numeric, remain;
+ int numeric, remain, sz, chsz;
numeric = 1;
remain = 0;
- /* Convert v into a number (of characters). */
- if (NULL == v)
- sz = defsz;
- else if (a2roffsu(v, &su, SCALE_MAX) > 1) {
- if (su.scale < 0.0)
- su.scale = 0.0;
+ /* Convert the width into a number (of characters). */
+ if (bl->width == NULL)
+ sz = (bl->type == LIST_hang) ? 6 : 0;
+ else if (a2roffsu(bl->width, &su, SCALE_MAX) > 1) {
if (SCALE_EN == su.unit)
sz = su.scale;
else {
numeric = 0;
}
} else
- sz = strlen(v);
+ sz = strlen(bl->width);
/* XXX Rough estimation, might have multiple parts. */
- chsz = (NULL != child && MDOC_TEXT == child->type) ?
- strlen(child->string) : 0;
+ if (bl->type == LIST_enum)
+ chsz = (bl->count > 8) + 1;
+ else if (child != NULL && child->type == MDOC_TEXT)
+ chsz = strlen(child->string);
+ else
+ chsz = 0;
/* Maybe we are inside an enclosing list? */
mid_it();
Bl_stack[Bl_stack_len++] = sz + 2;
/* Set up the current list. */
- if (defsz && chsz > sz)
+ if (chsz > sz && bl->type != LIST_tag)
print_block(".HP", 0);
else {
print_block(".TP", 0);
remain = sz + 2;
}
if (numeric) {
- (void)snprintf(buf, sizeof(buf), "%zun", sz + 2);
+ (void)snprintf(buf, sizeof(buf), "%dn", sz + 2);
print_word(buf);
} else
- print_word(v);
+ print_word(bl->width);
TPremain = remain;
}
{
char buf[24];
- (void)snprintf(buf, sizeof(buf), "%d.", ++*count);
+ (void)snprintf(buf, sizeof(buf), "%d.\\&", ++*count);
print_word(buf);
}
case LIST_dash:
/* FALLTHROUGH */
case LIST_hyphen:
- print_width(bln->norm->Bl.width, NULL, 0);
+ print_width(&bln->norm->Bl, NULL);
TPremain = 0;
outflags |= MMAN_nl;
font_push('B');
outflags |= MMAN_nl;
return(0);
case LIST_enum:
- print_width(bln->norm->Bl.width, NULL, 0);
+ print_width(&bln->norm->Bl, NULL);
TPremain = 0;
outflags |= MMAN_nl;
print_count(&bln->norm->Bl.count);
outflags |= MMAN_nl;
return(0);
case LIST_hang:
- print_width(bln->norm->Bl.width, n->child, 6);
+ print_width(&bln->norm->Bl, n->child);
TPremain = 0;
outflags |= MMAN_nl;
return(1);
case LIST_tag:
- print_width(bln->norm->Bl.width, n->child, 0);
+ print_width(&bln->norm->Bl, n->child);
putchar('\n');
outflags &= ~MMAN_spc;
return(1);
/* Restore the indentation of the enclosing list. */
print_line(".RS", MMAN_Bk_susp);
- (void)snprintf(buf, sizeof(buf), "%zun",
+ (void)snprintf(buf, sizeof(buf), "%dn",
Bl_stack[Bl_stack_len - 1]);
print_word(buf);
-/* $OpenBSD: mdoc_term.c,v 1.200 2014/12/23 13:48:15 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.201 2014/12/24 23:31:59 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
#include <assert.h>
#include <ctype.h>
+#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
void (*post)(DECL_ARGS);
};
-static size_t a2width(const struct termp *, const char *);
+static int a2width(const struct termp *, const char *);
static void print_bvspace(struct termp *,
const struct mdoc_node *,
free(volume);
}
-static size_t
+static int
a2width(const struct termp *p, const char *v)
{
struct roffsu su;
if (a2roffsu(v, &su, SCALE_MAX) < 2) {
SCALE_HS_INIT(&su, term_strlen(p, v));
su.scale /= term_strlen(p, "0");
- } else if (su.scale < 0.0)
- su.scale = 0.0;
-
+ }
return(term_hspan(p, &su));
}
static int
termp_it_pre(DECL_ARGS)
{
- const struct mdoc_node *bl, *nn;
char buf[24];
- int i;
- size_t width, offset, ncols, dcol;
+ const struct mdoc_node *bl, *nn;
+ size_t ncols, dcol;
+ int i, offset, width;
enum mdoc_list type;
if (MDOC_BLOCK == n->type) {
bl = n->parent->parent->parent;
type = bl->norm->Bl.type;
+ /*
+ * Defaults for specific list types.
+ */
+
+ switch (type) {
+ case LIST_bullet:
+ /* FALLTHROUGH */
+ case LIST_dash:
+ /* FALLTHROUGH */
+ case LIST_hyphen:
+ /* FALLTHROUGH */
+ case LIST_enum:
+ width = term_len(p, 2);
+ break;
+ case LIST_hang:
+ width = term_len(p, 8);
+ break;
+ case LIST_column:
+ /* FALLTHROUGH */
+ case LIST_tag:
+ width = term_len(p, 10);
+ break;
+ default:
+ width = 0;
+ break;
+ }
+ offset = 0;
+
/*
* First calculate width and offset. This is pretty easy unless
* we're a -column list, in which case all prior columns must
* be accounted for.
*/
- width = offset = 0;
-
- if (bl->norm->Bl.offs)
+ if (bl->norm->Bl.offs != NULL) {
offset = a2width(p, bl->norm->Bl.offs);
+ if (offset < 0 && (size_t)(-offset) > p->offset)
+ offset = -p->offset;
+ else if (offset > SHRT_MAX)
+ offset = 0;
+ }
switch (type) {
case LIST_column:
* number for buffering single arguments. See the above
* handling for column for how this changes.
*/
- assert(bl->norm->Bl.width);
width = a2width(p, bl->norm->Bl.width) + term_len(p, 2);
- break;
- }
-
- /*
- * List-type can override the width in the case of fixed-head
- * values (bullet, dash/hyphen, enum). Tags need a non-zero
- * offset.
- */
-
- switch (type) {
- case LIST_bullet:
- /* FALLTHROUGH */
- case LIST_dash:
- /* FALLTHROUGH */
- case LIST_hyphen:
- /* FALLTHROUGH */
- case LIST_enum:
- if (width < term_len(p, 2))
- width = term_len(p, 2);
- break;
- case LIST_hang:
- if (0 == width)
- width = term_len(p, 8);
- break;
- case LIST_column:
- /* FALLTHROUGH */
- case LIST_tag:
- if (0 == width)
- width = term_len(p, 10);
- break;
- default:
+ if (width < 0 && (size_t)(-width) > p->offset)
+ width = -p->offset;
+ else if (width > SHRT_MAX)
+ width = 0;
break;
}
case LIST_enum:
/*
* Weird special case.
- * Very narrow enum lists actually hang.
+ * Some very narrow lists actually hang.
*/
- if (width == term_len(p, 2))
- p->flags |= TERMP_HANG;
/* FALLTHROUGH */
case LIST_bullet:
/* FALLTHROUGH */
case LIST_dash:
/* FALLTHROUGH */
case LIST_hyphen:
+ if (width <= (int)term_len(p, 2))
+ p->flags |= TERMP_HANG;
if (MDOC_HEAD != n->type)
break;
p->flags |= TERMP_NOBREAK;
case LIST_hyphen:
/* FALLTHROUGH */
case LIST_tag:
- assert(width);
if (MDOC_HEAD == n->type)
p->rmargin = p->offset + width;
else
{
size_t tabwidth, lm, len, rm, rmax;
struct mdoc_node *nn;
+ int offset;
if (MDOC_BLOCK == n->type) {
print_bvspace(p, n, n);
p->offset += term_len(p, p->defindent + 1);
else if ( ! strcmp(n->norm->Bd.offs, "indent-two"))
p->offset += term_len(p, (p->defindent + 1) * 2);
- else
- p->offset += a2width(p, n->norm->Bd.offs);
+ else {
+ offset = a2width(p, n->norm->Bd.offs);
+ if (offset < 0 && (size_t)(-offset) > p->offset)
+ p->offset = 0;
+ else if (offset < SHRT_MAX)
+ p->offset += offset;
+ }
/*
* If -ragged or -filled are specified, the block does nothing
-/* $OpenBSD: term.c,v 1.101 2014/12/24 09:57:41 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.102 2014/12/24 23:31:59 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
}
if (TERMP_HANG & p->flags) {
- p->overstep = (int)(vis - maxvis +
+ p->overstep += (int)(p->offset + vis - p->rmargin +
p->trailspace * (*p->width)(p, ' '));
/*