From fad7287310f0636736ec51e3fbb38efde4b0c9ac Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 16 Feb 2014 12:30:53 +0000 Subject: when indenting, extend the right margin accordingly, when needed; fixes a crash reported by blambert@ and a few other, similar ones --- regress/usr.bin/mandoc/man/IP/width.in | 9 ++++++++- regress/usr.bin/mandoc/man/IP/width.out_ascii | 8 +++++++- regress/usr.bin/mandoc/man/RS/Makefile | 4 ++-- regress/usr.bin/mandoc/man/RS/width.in | 12 ++++++++++++ regress/usr.bin/mandoc/man/RS/width.out_ascii | 16 ++++++++++++++++ regress/usr.bin/mandoc/man/TP/width.in | 11 ++++++++++- regress/usr.bin/mandoc/man/TP/width.out_ascii | 8 +++++++- regress/usr.bin/mandoc/mdoc/Bl/tag.in | 6 +++++- regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii | 5 ++++- usr.bin/mandoc/man_term.c | 15 +++++++++------ usr.bin/mandoc/mdoc_term.c | 9 ++++++--- 11 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 regress/usr.bin/mandoc/man/RS/width.in create mode 100644 regress/usr.bin/mandoc/man/RS/width.out_ascii diff --git a/regress/usr.bin/mandoc/man/IP/width.in b/regress/usr.bin/mandoc/man/IP/width.in index e9e5c0c3e93..266324244bc 100644 --- a/regress/usr.bin/mandoc/man/IP/width.in +++ b/regress/usr.bin/mandoc/man/IP/width.in @@ -1,4 +1,4 @@ -.TH IP-WIDTH 1 "January 4, 2011" OpenBSD +.TH IP-WIDTH 1 "February 16, 2014" OpenBSD .SH NAME IP-width \- indentation width of indented paragraphs .SH DESCRIPTION @@ -23,6 +23,10 @@ text indented .br text +.IP tag 100n +indented +.br +text .PP Literal mode: .nf @@ -41,3 +45,6 @@ text .IP tag 5n indented text +.IP tag 100n +indented +text diff --git a/regress/usr.bin/mandoc/man/IP/width.out_ascii b/regress/usr.bin/mandoc/man/IP/width.out_ascii index 0b25dad924c..429c82761c7 100644 --- a/regress/usr.bin/mandoc/man/IP/width.out_ascii +++ b/regress/usr.bin/mandoc/man/IP/width.out_ascii @@ -26,6 +26,9 @@ DDEESSCCRRIIPPTTIIOONN tag indented text + tag indented + text + Literal mode: tag @@ -46,6 +49,9 @@ DDEESSCCRRIIPPTTIIOONN tag indented text + tag indented + text + -OpenBSD January 4, 2011 IP-WIDTH(1) +OpenBSD February 16, 2014 IP-WIDTH(1) diff --git a/regress/usr.bin/mandoc/man/RS/Makefile b/regress/usr.bin/mandoc/man/RS/Makefile index adefaeab654..6d0c822dfaf 100644 --- a/regress/usr.bin/mandoc/man/RS/Makefile +++ b/regress/usr.bin/mandoc/man/RS/Makefile @@ -1,5 +1,5 @@ -# $OpenBSD: Makefile,v 1.5 2013/11/11 00:35:51 schwarze Exp $ +# $OpenBSD: Makefile,v 1.6 2014/02/16 12:30:52 schwarze Exp $ -REGRESS_TARGETS = breaking empty literal lonelyRE nested +REGRESS_TARGETS = breaking empty literal lonelyRE nested width .include diff --git a/regress/usr.bin/mandoc/man/RS/width.in b/regress/usr.bin/mandoc/man/RS/width.in new file mode 100644 index 00000000000..7dc19dad9e8 --- /dev/null +++ b/regress/usr.bin/mandoc/man/RS/width.in @@ -0,0 +1,12 @@ +.TH RS-WIDTH 1 "February 16, 2014" OpenBSD +.SH NAME +RS-width \- excessive indentation +.SH DESCRIPTION +regular +text +.RS 100n +indented +text +.RE +regular +text diff --git a/regress/usr.bin/mandoc/man/RS/width.out_ascii b/regress/usr.bin/mandoc/man/RS/width.out_ascii new file mode 100644 index 00000000000..211ada7de13 --- /dev/null +++ b/regress/usr.bin/mandoc/man/RS/width.out_ascii @@ -0,0 +1,16 @@ +RS-WIDTH(1) OpenBSD Reference Manual RS-WIDTH(1) + + + +NNAAMMEE + RS-width - excessive indentation + +DDEESSCCRRIIPPTTIIOONN + regular text + indented + text + regular text + + + +OpenBSD February 16, 2014 RS-WIDTH(1) diff --git a/regress/usr.bin/mandoc/man/TP/width.in b/regress/usr.bin/mandoc/man/TP/width.in index a80bb9a10a0..d57aa0049b5 100644 --- a/regress/usr.bin/mandoc/man/TP/width.in +++ b/regress/usr.bin/mandoc/man/TP/width.in @@ -1,4 +1,4 @@ -.TH TP-WIDTH 1 "January 4, 2011" OpenBSD +.TH TP-WIDTH 1 "February 16, 2014" OpenBSD .SH NAME TP-width \- indentation width of indented paragraphs .SH DESCRIPTION @@ -28,6 +28,11 @@ tag indented .br text +.TP 100n +tag +indented +.br +text .PP Literal mode: .nf @@ -51,3 +56,7 @@ text tag indented text +.TP 100n +tag +indented +text diff --git a/regress/usr.bin/mandoc/man/TP/width.out_ascii b/regress/usr.bin/mandoc/man/TP/width.out_ascii index 300eb43dc5b..ffb137db1c3 100644 --- a/regress/usr.bin/mandoc/man/TP/width.out_ascii +++ b/regress/usr.bin/mandoc/man/TP/width.out_ascii @@ -26,6 +26,9 @@ DDEESSCCRRIIPPTTIIOONN tag indented text + tag indented + text + Literal mode: tag @@ -46,6 +49,9 @@ DDEESSCCRRIIPPTTIIOONN tag indented text + tag indented + text + -OpenBSD January 4, 2011 TP-WIDTH(1) +OpenBSD February 16, 2014 TP-WIDTH(1) diff --git a/regress/usr.bin/mandoc/mdoc/Bl/tag.in b/regress/usr.bin/mandoc/mdoc/Bl/tag.in index bbf12de82d7..df16b629c3c 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/tag.in +++ b/regress/usr.bin/mandoc/mdoc/Bl/tag.in @@ -1,4 +1,4 @@ -.Dd May 19, 2013 +.Dd February 16, 2014 .Dt BL-TAG 1 .Os OpenBSD .Sh NAME @@ -37,6 +37,10 @@ x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x .It zehn_ zehn x x x x x x x x x x x x x x x x 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 100n +.It hundred +text text +.El .Pp Trailing white space in the head: .Bl -tag -width 5n diff --git a/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii index 930c7281e8b..8cff8ee53cf 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii @@ -33,6 +33,9 @@ DDEESSCCRRIIPPTTIIOONN x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x + hundred text + text + Trailing white space in the head: a b @@ -59,4 +62,4 @@ DDEESSCCRRIIPPTTIIOONN second paragraph -OpenBSD May 19, 2013 OpenBSD +OpenBSD February 16, 2014 OpenBSD diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 630720af481..cde6fd9f8c9 100644 --- a/usr.bin/mandoc/man_term.c +++ b/usr.bin/mandoc/man_term.c @@ -1,7 +1,7 @@ -/* $Id: man_term.c,v 1.93 2013/12/22 23:33:52 schwarze Exp $ */ +/* $Id: man_term.c,v 1.94 2014/02/16 12:30:51 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010-2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -654,7 +654,8 @@ pre_IP(DECL_ARGS) return(0); case (MAN_BODY): p->offset = mt->offset + len; - p->rmargin = p->maxrmargin; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; break; default: break; @@ -744,7 +745,8 @@ pre_TP(DECL_ARGS) return(0); case (MAN_BODY): p->offset = mt->offset + len; - p->rmargin = p->maxrmargin; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; p->trailspace = 0; p->flags &= ~TERMP_NOBREAK; break; @@ -905,8 +907,9 @@ pre_RS(DECL_ARGS) sz = (size_t)ival; mt->offset += sz; - p->rmargin = p->maxrmargin; - p->offset = mt->offset < p->rmargin ? mt->offset : p->rmargin; + p->offset = mt->offset; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; if (++mt->lmarginsz < MAXMARGINS) mt->lmargincur = mt->lmarginsz; diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 68b2311fc63..6b14033b113 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,7 +1,7 @@ -/* $Id: mdoc_term.c,v 1.160 2013/12/25 21:24:03 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.161 2014/02/16 12:30:51 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze * Copyright (c) 2013 Franco Fichtner * * Permission to use, copy, modify, and distribute this software for any @@ -869,8 +869,11 @@ termp_it_pre(DECL_ARGS) assert(width); if (MDOC_HEAD == n->type) p->rmargin = p->offset + width; - else + else { p->offset += width; + if (p->rmargin < p->offset) + p->rmargin = p->offset; + } break; case (LIST_column): assert(width); -- cgit v1.2.3