diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2021-06-27 17:57:54 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2021-06-27 17:57:54 +0000 |
commit | be51c141f11b2f1550c1b8bbd47639509679ecd3 (patch) | |
tree | d34469b5bc2a0774c98deaa7c24fff6bcd606281 /roff.c | |
parent | 78fc2ca35b074c97e98436c33ca288bd9a7a09d0 (diff) | |
download | mandoc-be51c141f11b2f1550c1b8bbd47639509679ecd3.tar.gz mandoc-be51c141f11b2f1550c1b8bbd47639509679ecd3.tar.zst mandoc-be51c141f11b2f1550c1b8bbd47639509679ecd3.zip |
add a style message about overlong text lines,
trying very hard to avoid false positives,
not at all trying to catch as many cases as possible;
feature originally suggested by tb@,
OK tb@ kn@ jmc@
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.376 2020/08/27 12:59:02 schwarze Exp $ */ +/* $Id: roff.c,v 1.377 2021/06/27 17:57:55 schwarze Exp $ */ /* * Copyright (c) 2010-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> @@ -1823,7 +1823,7 @@ roff_parsetext(struct roff *r, struct buf *buf, int pos, int *offs) } int -roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs) +roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs, size_t len) { enum roff_tok t; int e; @@ -1834,6 +1834,14 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs) ppos = pos = *offs; + if (len > 80 && r->tbl == NULL && r->eqn == NULL && + (r->man->flags & ROFF_NOFILL) == 0 && + strchr(" .\\", buf->buf[pos]) == NULL && + buf->buf[pos] != r->control && + strcspn(buf->buf, " ") < 80) + mandoc_msg(MANDOCERR_TEXT_LONG, ln, (int)len - 1, + "%.20s...", buf->buf + pos); + /* Handle in-line equation delimiters. */ if (r->tbl == NULL && |