summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2016-11-10 12:47:06 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2016-11-10 12:47:06 +0000
commitbe6a574f2f0287b2c97deea6c341625fa9675384 (patch)
tree2adf4ade4917f06a56def6a6a7c7087f3e83a0c4
parent1e57026764df0231083bc962f244abdc8983c104 (diff)
warn about trailing whitespace at the end of comments;
missing feature noticed by jmc@
-rw-r--r--usr.bin/mandoc/read.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 63d7b20a9ad..bbea60bc211 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.125 2016/10/09 18:16:46 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.126 2016/11/10 12:47:05 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -418,11 +418,17 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
i += 2;
/* Comment, skip to end of line */
for (; i < blk.sz; ++i) {
- if ('\n' == blk.buf[i]) {
- ++i;
- ++lnn;
- break;
- }
+ if (blk.buf[i] != '\n')
+ continue;
+ if (blk.buf[i - 1] == ' ' ||
+ blk.buf[i - 1] == '\t')
+ mandoc_msg(
+ MANDOCERR_SPACE_EOL,
+ curp, curp->line,
+ pos, NULL);
+ ++i;
+ ++lnn;
+ break;
}
/* Backout trailing whitespaces */