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 | |
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')
-rw-r--r-- | usr.bin/mandoc/man_validate.c | 25 | ||||
-rw-r--r-- | usr.bin/mandoc/roff.c | 30 |
2 files changed, 46 insertions, 9 deletions
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index bfa17bd77c9..82ad699bbd6 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.45 2011/05/29 21:22:18 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.46 2011/07/07 20:07:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -53,27 +53,28 @@ static int check_sec(CHKARGS); static void check_text(CHKARGS); static int post_AT(CHKARGS); +static int post_vs(CHKARGS); static int post_fi(CHKARGS); static int post_nf(CHKARGS); static int post_TH(CHKARGS); static int post_UC(CHKARGS); static v_check posts_at[] = { post_AT, NULL }; +static v_check posts_br[] = { post_vs, check_eq0, NULL }; static v_check posts_eq0[] = { check_eq0, NULL }; static v_check posts_fi[] = { check_eq0, post_fi, NULL }; -static v_check posts_le1[] = { check_le1, NULL }; static v_check posts_ft[] = { check_ft, NULL }; static v_check posts_nf[] = { check_eq0, post_nf, NULL }; static v_check posts_par[] = { check_par, NULL }; static v_check posts_part[] = { check_part, NULL }; static v_check posts_sec[] = { check_sec, NULL }; +static v_check posts_sp[] = { post_vs, check_le1, NULL }; static v_check posts_th[] = { check_ge2, check_le5, post_TH, NULL }; static v_check posts_uc[] = { post_UC, NULL }; static v_check pres_bline[] = { check_bline, NULL }; - static const struct man_valid man_valids[MAN_MAX] = { - { NULL, posts_eq0 }, /* br */ + { NULL, posts_br }, /* br */ { pres_bline, posts_th }, /* TH */ { pres_bline, posts_sec }, /* SH */ { pres_bline, posts_sec }, /* SS */ @@ -95,7 +96,7 @@ static const struct man_valid man_valids[MAN_MAX] = { { NULL, NULL }, /* IR */ { NULL, NULL }, /* RI */ { NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */ - { NULL, posts_le1 }, /* sp */ /* FIXME: should warn only. */ + { NULL, posts_sp }, /* sp */ /* FIXME: should warn only. */ { pres_bline, posts_nf }, /* nf */ { pres_bline, posts_fi }, /* fi */ { NULL, NULL }, /* RE */ @@ -554,3 +555,17 @@ post_AT(CHKARGS) m->meta.source = mandoc_strdup(p); return(1); } + +static int +post_vs(CHKARGS) +{ + + /* + * Don't warn about this because it occurs in pod2man and would + * cause considerable (unfixable) warnage. + */ + if (NULL == n->prev && MAN_ROOT == n->parent->type) + man_node_delete(m, n); + + return(1); +} 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; |