From 204684a74f74656968829862e116433f20be863a Mon Sep 17 00:00:00 2001 From: schwarze Date: Thu, 18 Dec 2014 20:15:31 +0000 Subject: [PATCH] Only keep leading .Sm inside a list when it immediately precedes the first .It. Otherwise, move it out together with whatever follows. Fixing an assertion failure found by jsg@ with afl. --- regress/usr.bin/mandoc/mdoc/Bl/noIt.in | 4 +++- regress/usr.bin/mandoc/mdoc/Bl/noIt.out_ascii | 2 +- regress/usr.bin/mandoc/mdoc/Bl/noIt.out_lint | 7 +++++-- usr.bin/mandoc/mdoc_validate.c | 7 +++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/regress/usr.bin/mandoc/mdoc/Bl/noIt.in b/regress/usr.bin/mandoc/mdoc/Bl/noIt.in index 5e5b4b473a3..46d8c0d283c 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/noIt.in +++ b/regress/usr.bin/mandoc/mdoc/Bl/noIt.in @@ -13,7 +13,9 @@ Tagged text. .El .Bl -bullet Stray text. -.Em More stray text. +.Sm off +.Em More Sy stray Em text. +.Sm on .It Bullet point. .El diff --git a/regress/usr.bin/mandoc/mdoc/Bl/noIt.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/noIt.out_ascii index a7a0f0daf19..9f603f1cb0a 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/noIt.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bl/noIt.out_ascii @@ -7,7 +7,7 @@ DDEESSCCRRIIPPTTIIOONN Stray text. _M_o_r_e _s_t_r_a_y _t_e_x_t_. tag Tagged text. - Stray text. _M_o_r_e _s_t_r_a_y _t_e_x_t_. + Stray text. _M_o_r_essttrraayy_t_e_x_t_. ++oo Bullet point. Stray text only. diff --git a/regress/usr.bin/mandoc/mdoc/Bl/noIt.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/noIt.out_lint index 00f22c91dd1..efe0eeeacfa 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/noIt.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bl/noIt.out_lint @@ -1,5 +1,8 @@ mandoc: noIt.in:9:1: WARNING: moving content out of list: text mandoc: noIt.in:10:2: WARNING: moving content out of list: Em mandoc: noIt.in:15:1: WARNING: moving content out of list: text -mandoc: noIt.in:16:2: WARNING: moving content out of list: Em -mandoc: noIt.in:21:1: WARNING: moving content out of list: text +mandoc: noIt.in:16:2: WARNING: moving content out of list: Sm +mandoc: noIt.in:17:2: WARNING: moving content out of list: Em +mandoc: noIt.in:17:10: WARNING: moving content out of list: Sy +mandoc: noIt.in:17:19: WARNING: moving content out of list: Em +mandoc: noIt.in:23:1: WARNING: moving content out of list: text diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 003dcbe7935..760592f10fd 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.180 2014/12/18 19:22:47 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.181 2014/12/18 20:15:31 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -1475,7 +1475,10 @@ post_bl(POST_ARGS) nchild = nbody->child; while (NULL != nchild) { - if (MDOC_It == nchild->tok || MDOC_Sm == nchild->tok) { + if (nchild->tok == MDOC_It || + (nchild->tok == MDOC_Sm && + nchild->next != NULL && + nchild->next->tok == MDOC_It)) { nchild = nchild->next; continue; } -- 2.20.1