aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit39a7e043a9a1b07aaf2badd9f29c81c59b69e4a0 (patch)
tree86b573e9493262fc06e43c9d49f985333b7e3c05
parent3705a7e862c2fb360cf2bb2602eb79158b113468 (diff)
downloadmandoc-39a7e043a9a1b07aaf2badd9f29c81c59b69e4a0.tar.gz
mandoc-39a7e043a9a1b07aaf2badd9f29c81c59b69e4a0.tar.zst
mandoc-39a7e043a9a1b07aaf2badd9f29c81c59b69e4a0.zip
Trim trailing whitespace from man.conf lines; patch from millert@.
-rw-r--r--manpath.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/manpath.c b/manpath.c
index 0627f13d..83c329ec 100644
--- a/manpath.c
+++ b/manpath.c
@@ -1,4 +1,4 @@
-/* $Id: manpath.c,v 1.29 2015/11/07 17:58:55 schwarze Exp $ */
+/* $Id: manpath.c,v 1.30 2016/05/28 13:44:13 schwarze Exp $ */
/*
* Copyright (c) 2011, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -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++) {