diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2011-07-07 20:07:39 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2011-07-07 20:07:39 +0000 |
commit | d7a5aaff22bf95164c4cbfc11e3570f76371574e (patch) | |
tree | e8991f8ceb7eaae2a7acb90e0fece86561674c46 /usr.bin/mandoc/roff.c | |
parent | b80a593cb2ba82dd11b2d62f1fb6b390188df403 (diff) |
Fix a bogus "unknown macro" error reported in the pod2man(1) preamble:
- Actually let roff_parse() recognize ".\}" as a cond block end request.
- Do not rewrite "\}" to the zero-width space "\&" because that prevents
recognition of immediately preceding macros; use normal blanks instead.
- To avoid a vertical spacing regression in pod2man(1) manuals,
drop one vertical spacing request just before NAME.
From kristaps@.
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r-- | usr.bin/mandoc/roff.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 06a944eda77..b6e50bad52c 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.38 2011/07/05 04:12:41 schwarze Exp $ */ +/* $Id: roff.c,v 1.39 2011/07/07 20:07:38 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -592,11 +592,18 @@ roff_parse(struct roff *r, const char *buf, int *pos) size_t maclen; enum rofft t; - if ('\0' == buf[*pos] || '"' == buf[*pos]) + if ('\0' == buf[*pos] || '"' == buf[*pos] || + '\t' == buf[*pos] || ' ' == buf[*pos]) return(ROFF_MAX); + /* + * We stop the macro parse at an escape, tab, space, or nil. + * However, `\}' is also a valid macro, so make sure we don't + * clobber it by seeing the `\' as the end of token. + */ + mac = buf + *pos; - maclen = strcspn(mac, " \\\t\0"); + maclen = strcspn(mac + 1, " \\\t\0") + 1; t = (r->current_string = roff_getstrn(r, mac, maclen)) ? ROFF_USERDEF : roff_hash_find(mac, maclen); @@ -878,7 +885,22 @@ roff_cond_sub(ROFF_ARGS) ep++; if ('}' != *ep) continue; - *ep = '&'; + + /* + * Make the \} go away. + * This is a little haphazard, as it's not quite + * clear how nroff does this. + * If we're at the end of line, then just chop + * off the \} and resize the buffer. + * If we aren't, then conver it to spaces. + */ + + if ('\0' == *(ep + 1)) { + *--ep = '\0'; + *szp -= 2; + } else + *(ep - 1) = *ep = ' '; + roff_ccond(r, ROFF_ccond, bufp, szp, ln, pos, pos + 2, offs); break; |