Re: Patch for man to ignore trailing spaces in man.conf
> From: todd.mil...@courtesan.com > To: mayukh_b...@hotmail.com > CC: tech@openbsd.org; schwa...@openbsd.org > Subject: Re: Patch for man to ignore trailing spaces in man.conf > Date: Mon, 23 May 2016 10:01:54 -0600 > > Your patch got munged by your mailer. Here's a different patch > that achieves the same thing and also removes the requirement that > the last line in man.conf end with a newline. > > - todd > > Index: usr.bin/mandoc/manpath.c > === > RCS file: /cvs/src/usr.bin/mandoc/manpath.c,v > retrieving revision 1.17 > diff -u -p -u -r1.17 manpath.c > --- usr.bin/mandoc/manpath.c 7 Nov 2015 17:58:52 - 1.17 > +++ usr.bin/mandoc/manpath.c 23 May 2016 15:59:09 - > @@ -173,13 +173,12 @@ manconf_file(struct manconf *conf, const > > 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++) { Thanks much. I like your patch better too. Cheers, Mayukh
Re: Patch for man to ignore trailing spaces in man.conf
Hi Todd, Todd C. Miller wrote on Mon, May 23, 2016 at 10:01:54AM -0600: > Your patch got munged by your mailer. Here's a different patch > that achieves the same thing and also removes the requirement that > the last line in man.conf end with a newline. OK schwarze@. Thanks, Ingo > Index: usr.bin/mandoc/manpath.c > === > RCS file: /cvs/src/usr.bin/mandoc/manpath.c,v > retrieving revision 1.17 > diff -u -p -u -r1.17 manpath.c > --- usr.bin/mandoc/manpath.c 7 Nov 2015 17:58:52 - 1.17 > +++ usr.bin/mandoc/manpath.c 23 May 2016 15:59:09 - > @@ -173,13 +173,12 @@ manconf_file(struct manconf *conf, const > > 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++) { >
Re: Patch for man to ignore trailing spaces in man.conf
Your patch got munged by your mailer. Here's a different patch that achieves the same thing and also removes the requirement that the last line in man.conf end with a newline. - todd Index: usr.bin/mandoc/manpath.c === RCS file: /cvs/src/usr.bin/mandoc/manpath.c,v retrieving revision 1.17 diff -u -p -u -r1.17 manpath.c --- usr.bin/mandoc/manpath.c7 Nov 2015 17:58:52 - 1.17 +++ usr.bin/mandoc/manpath.c23 May 2016 15:59:09 - @@ -173,13 +173,12 @@ manconf_file(struct manconf *conf, const 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++) {
Re: Patch for man to ignore trailing spaces in man.conf
Hi Mayukh, On Sun, May 22, 2016 at 11:17:18PM -0700, Mayukh Bose wrote: > [...] > Here's my patch to fix this: > [...] Ironically, your patch about whitespace handling has mangled whitespace. Can you send it again? Maybe your MUA tried sending it as some sort of formatted text instead of plain text. -- Gregor
Patch for man to ignore trailing spaces in man.conf
Hi all, I used pkg_add to add jdk and after installation, it told me to add /usr/local/jdk-1.7.0/man to man.conf. Therefore, I googled on modifying man.conf and came across the OpenBSD man page online:http://man.openbsd.org/OpenBSD-current/man5/man.conf.5 I cut-and-pasted the EXAMPLES section into /etc/man.conf exactly as stated from the webpage and then added an extra line for the jdk manpath:manpath /usr/share/man manpath /usr/X11R6/man manpath /usr/local/man manpath /usr/local/jdk-1.7.0/man And after this, "man java" worked fine, but "man man", "man printf", "man man.conf" etc. stopped working! After a bit of debugging, I found that the problem was that the manpath lines for the first two lines had trailing spaces at the end (I had cut/pasted them from the webpage above, but it appears the page has the trailing spaces in it as well). So I figured I should fix man so that it properly handles trailing spaces in man.conf. Here's my patch to fix this: $ cvs -d anon...@anoncvs.usa.openbsd.org:/cvs diffcvs server: Diffing .Index: manpath.c===RCS file: /cvs/src/usr.bin/mandoc/manpath.c,vretrieving revision 1.17diff -u -p -r1.17 manpath.c--- manpath.c 7 Nov 2015 17:58:52 - 1.17+++ manpath.c 23 May 2016 06:15:00 -@@ -176,7 +176,14 @@ manconf_file(struct manconf *conf, constep = cp + linelen;if (ep[-1] != '\n')break;- *--ep = '\0';+ ep--;+ while (ep > cp && isspace(*ep)) {+ *ep = '\0';+ ep--;+ }+ if (ep == cp)+ continue;+while (isspace((unsigned char)*cp))cp++;if (*cp == '#') Cheers,Mayukh