summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-05-28 13:44:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-05-28 13:44:13 +0000
commit54eafe98e5e52265dee76115b0519d5b88d7fa6b (patch)
tree0c1fd935fa1df7f00e4bc56f151d2bc3250ca9c6
parent7956db275a13d70a6b9fb672cf085b78e70f124c (diff)
downloadmandoc-54eafe98e5e52265dee76115b0519d5b88d7fa6b.tar.gz
Trim trailing whitespace from man.conf lines; patch from millert@.
-rw-r--r--manpath.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/manpath.c b/manpath.c
index 7b15533a..84293af0 100644
--- a/manpath.c
+++ b/manpath.c
@@ -224,13 +224,12 @@ manconf_file(struct manconf *conf, const char *file)
while ((linelen = getline(&line, &linesz, stream)) != -1) {
cp = line;
- ep = cp + linelen;
- if (ep[-1] != '\n')
- break;
- *--ep = '\0';
+ ep = cp + linelen - 1;
+ while (ep > cp && isspace((unsigned char)*ep))
+ *ep-- = '\0';
while (isspace((unsigned char)*cp))
cp++;
- if (*cp == '#')
+ if (cp == ep || *cp == '#')
continue;
for (tok = 0; tok < sizeof(toks)/sizeof(toks[0]); tok++) {