diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/libman.h | 12 | ||||
-rw-r--r-- | usr.bin/mandoc/libmdoc.h | 17 | ||||
-rw-r--r-- | usr.bin/mandoc/man.c | 252 | ||||
-rw-r--r-- | usr.bin/mandoc/man_html.c | 56 | ||||
-rw-r--r-- | usr.bin/mandoc/man_macro.c | 122 | ||||
-rw-r--r-- | usr.bin/mandoc/man_term.c | 42 | ||||
-rw-r--r-- | usr.bin/mandoc/man_validate.c | 153 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 282 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_argv.c | 60 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 59 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 357 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_man.c | 39 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 75 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 34 |
14 files changed, 779 insertions, 781 deletions
diff --git a/usr.bin/mandoc/libman.h b/usr.bin/mandoc/libman.h index d62540b4edc..fcff91d550b 100644 --- a/usr.bin/mandoc/libman.h +++ b/usr.bin/mandoc/libman.h @@ -1,4 +1,4 @@ -/* $Id: libman.h,v 1.31 2011/11/05 16:02:18 schwarze Exp $ */ +/* $Id: libman.h,v 1.32 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -39,7 +39,7 @@ struct man { struct roff *roff; }; -#define MACRO_PROT_ARGS struct man *m, \ +#define MACRO_PROT_ARGS struct man *man, \ enum mant tok, \ int line, \ int ppos, \ @@ -61,10 +61,10 @@ extern const struct man_macro *const man_macros; __BEGIN_DECLS -#define man_pmsg(m, l, p, t) \ - mandoc_msg((t), (m)->parse, (l), (p), NULL) -#define man_nmsg(m, n, t) \ - mandoc_msg((t), (m)->parse, (n)->line, (n)->pos, NULL) +#define man_pmsg(man, l, p, t) \ + mandoc_msg((t), (man)->parse, (l), (p), NULL) +#define man_nmsg(man, n, t) \ + mandoc_msg((t), (man)->parse, (n)->line, (n)->pos, NULL) int man_word_alloc(struct man *, int, int, const char *); int man_block_alloc(struct man *, int, int, enum mant); int man_head_alloc(struct man *, int, int, enum mant); diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h index f82dfb58140..f907baf07e3 100644 --- a/usr.bin/mandoc/libmdoc.h +++ b/usr.bin/mandoc/libmdoc.h @@ -1,4 +1,4 @@ -/* $Id: libmdoc.h,v 1.50 2012/07/18 11:09:30 schwarze Exp $ */ +/* $Id: libmdoc.h,v 1.51 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -43,7 +43,7 @@ struct mdoc { struct roff *roff; }; -#define MACRO_PROT_ARGS struct mdoc *m, \ +#define MACRO_PROT_ARGS struct mdoc *mdoc, \ enum mdoct tok, \ int line, \ int ppos, \ @@ -100,10 +100,10 @@ extern const struct mdoc_macro *const mdoc_macros; __BEGIN_DECLS -#define mdoc_pmsg(m, l, p, t) \ - mandoc_msg((t), (m)->parse, (l), (p), NULL) -#define mdoc_nmsg(m, n, t) \ - mandoc_msg((t), (m)->parse, (n)->line, (n)->pos, NULL) +#define mdoc_pmsg(mdoc, l, p, t) \ + mandoc_msg((t), (mdoc)->parse, (l), (p), NULL) +#define mdoc_nmsg(mdoc, n, t) \ + mandoc_msg((t), (mdoc)->parse, (n)->line, (n)->pos, NULL) int mdoc_macro(MACRO_PROT_ARGS); int mdoc_word_alloc(struct mdoc *, int, int, const char *); @@ -114,9 +114,8 @@ int mdoc_block_alloc(struct mdoc *, int, int, int mdoc_head_alloc(struct mdoc *, int, int, enum mdoct); int mdoc_tail_alloc(struct mdoc *, int, int, enum mdoct); int mdoc_body_alloc(struct mdoc *, int, int, enum mdoct); -int mdoc_endbody_alloc(struct mdoc *m, int line, int pos, - enum mdoct tok, struct mdoc_node *body, - enum mdoc_endbody end); +int mdoc_endbody_alloc(struct mdoc *, int, int, enum mdoct, + struct mdoc_node *, enum mdoc_endbody); void mdoc_node_delete(struct mdoc *, struct mdoc_node *); int mdoc_node_relink(struct mdoc *, struct mdoc_node *); void mdoc_hash_init(void); diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index 5bace1583da..08c89b795c3 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.68 2012/07/14 10:43:48 schwarze Exp $ */ +/* $Id: man.c,v 1.69 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -56,20 +56,20 @@ static int man_descope(struct man *, int, int); const struct man_node * -man_node(const struct man *m) +man_node(const struct man *man) { - assert( ! (MAN_HALT & m->flags)); - return(m->first); + assert( ! (MAN_HALT & man->flags)); + return(man->first); } const struct man_meta * -man_meta(const struct man *m) +man_meta(const struct man *man) { - assert( ! (MAN_HALT & m->flags)); - return(&m->meta); + assert( ! (MAN_HALT & man->flags)); + return(&man->meta); } @@ -108,28 +108,28 @@ man_alloc(struct roff *roff, struct mparse *parse) int -man_endparse(struct man *m) +man_endparse(struct man *man) { - assert( ! (MAN_HALT & m->flags)); - if (man_macroend(m)) + assert( ! (MAN_HALT & man->flags)); + if (man_macroend(man)) return(1); - m->flags |= MAN_HALT; + man->flags |= MAN_HALT; return(0); } int -man_parseln(struct man *m, int ln, char *buf, int offs) +man_parseln(struct man *man, int ln, char *buf, int offs) { - m->flags |= MAN_NEWLINE; + man->flags |= MAN_NEWLINE; - assert( ! (MAN_HALT & m->flags)); + assert( ! (MAN_HALT & man->flags)); - return (roff_getcontrol(m->roff, buf, &offs) ? - man_pmacro(m, ln, buf, offs) : - man_ptext(m, ln, buf, offs)); + return (roff_getcontrol(man->roff, buf, &offs) ? + man_pmacro(man, ln, buf, offs) : + man_ptext(man, ln, buf, offs)); } @@ -153,16 +153,16 @@ man_free1(struct man *man) static void -man_alloc1(struct man *m) +man_alloc1(struct man *man) { - memset(&m->meta, 0, sizeof(struct man_meta)); - m->flags = 0; - m->last = mandoc_calloc(1, sizeof(struct man_node)); - m->first = m->last; - m->last->type = MAN_ROOT; - m->last->tok = MAN_MAX; - m->next = MAN_NEXT_CHILD; + memset(&man->meta, 0, sizeof(struct man_meta)); + man->flags = 0; + man->last = mandoc_calloc(1, sizeof(struct man_node)); + man->first = man->last; + man->last->type = MAN_ROOT; + man->last->tok = MAN_MAX; + man->next = MAN_NEXT_CHILD; } @@ -230,7 +230,7 @@ man_node_append(struct man *man, struct man_node *p) static struct man_node * -man_node_alloc(struct man *m, int line, int pos, +man_node_alloc(struct man *man, int line, int pos, enum man_type type, enum mant tok) { struct man_node *p; @@ -241,89 +241,89 @@ man_node_alloc(struct man *m, int line, int pos, p->type = type; p->tok = tok; - if (MAN_NEWLINE & m->flags) + if (MAN_NEWLINE & man->flags) p->flags |= MAN_LINE; - m->flags &= ~MAN_NEWLINE; + man->flags &= ~MAN_NEWLINE; return(p); } int -man_elem_alloc(struct man *m, int line, int pos, enum mant tok) +man_elem_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(m, line, pos, MAN_ELEM, tok); - if ( ! man_node_append(m, p)) + p = man_node_alloc(man, line, pos, MAN_ELEM, tok); + if ( ! man_node_append(man, p)) return(0); - m->next = MAN_NEXT_CHILD; + man->next = MAN_NEXT_CHILD; return(1); } int -man_tail_alloc(struct man *m, int line, int pos, enum mant tok) +man_tail_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(m, line, pos, MAN_TAIL, tok); - if ( ! man_node_append(m, p)) + p = man_node_alloc(man, line, pos, MAN_TAIL, tok); + if ( ! man_node_append(man, p)) return(0); - m->next = MAN_NEXT_CHILD; + man->next = MAN_NEXT_CHILD; return(1); } int -man_head_alloc(struct man *m, int line, int pos, enum mant tok) +man_head_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(m, line, pos, MAN_HEAD, tok); - if ( ! man_node_append(m, p)) + p = man_node_alloc(man, line, pos, MAN_HEAD, tok); + if ( ! man_node_append(man, p)) return(0); - m->next = MAN_NEXT_CHILD; + man->next = MAN_NEXT_CHILD; return(1); } int -man_body_alloc(struct man *m, int line, int pos, enum mant tok) +man_body_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(m, line, pos, MAN_BODY, tok); - if ( ! man_node_append(m, p)) + p = man_node_alloc(man, line, pos, MAN_BODY, tok); + if ( ! man_node_append(man, p)) return(0); - m->next = MAN_NEXT_CHILD; + man->next = MAN_NEXT_CHILD; return(1); } int -man_block_alloc(struct man *m, int line, int pos, enum mant tok) +man_block_alloc(struct man *man, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(m, line, pos, MAN_BLOCK, tok); - if ( ! man_node_append(m, p)) + p = man_node_alloc(man, line, pos, MAN_BLOCK, tok); + if ( ! man_node_append(man, p)) return(0); - m->next = MAN_NEXT_CHILD; + man->next = MAN_NEXT_CHILD; return(1); } int -man_word_alloc(struct man *m, int line, int pos, const char *word) +man_word_alloc(struct man *man, int line, int pos, const char *word) { struct man_node *n; - n = man_node_alloc(m, line, pos, MAN_TEXT, MAN_MAX); - n->string = roff_strdup(m->roff, word); + n = man_node_alloc(man, line, pos, MAN_TEXT, MAN_MAX); + n->string = roff_strdup(man->roff, word); - if ( ! man_node_append(m, n)) + if ( ! man_node_append(man, n)) return(0); - m->next = MAN_NEXT_SIBLING; + man->next = MAN_NEXT_SIBLING; return(1); } @@ -343,52 +343,52 @@ man_node_free(struct man_node *p) void -man_node_delete(struct man *m, struct man_node *p) +man_node_delete(struct man *man, struct man_node *p) { while (p->child) - man_node_delete(m, p->child); + man_node_delete(man, p->child); - man_node_unlink(m, p); + man_node_unlink(man, p); man_node_free(p); } int -man_addeqn(struct man *m, const struct eqn *ep) +man_addeqn(struct man *man, const struct eqn *ep) { struct man_node *n; - assert( ! (MAN_HALT & m->flags)); + assert( ! (MAN_HALT & man->flags)); - n = man_node_alloc(m, ep->ln, ep->pos, MAN_EQN, MAN_MAX); + n = man_node_alloc(man, ep->ln, ep->pos, MAN_EQN, MAN_MAX); n->eqn = ep; - if ( ! man_node_append(m, n)) + if ( ! man_node_append(man, n)) return(0); - m->next = MAN_NEXT_SIBLING; - return(man_descope(m, ep->ln, ep->pos)); + man->next = MAN_NEXT_SIBLING; + return(man_descope(man, ep->ln, ep->pos)); } int -man_addspan(struct man *m, const struct tbl_span *sp) +man_addspan(struct man *man, const struct tbl_span *sp) { struct man_node *n; - assert( ! (MAN_HALT & m->flags)); + assert( ! (MAN_HALT & man->flags)); - n = man_node_alloc(m, sp->line, 0, MAN_TBL, MAN_MAX); + n = man_node_alloc(man, sp->line, 0, MAN_TBL, MAN_MAX); n->span = sp; - if ( ! man_node_append(m, n)) + if ( ! man_node_append(man, n)) return(0); - m->next = MAN_NEXT_SIBLING; - return(man_descope(m, sp->line, 0)); + man->next = MAN_NEXT_SIBLING; + return(man_descope(man, sp->line, 0)); } static int -man_descope(struct man *m, int line, int offs) +man_descope(struct man *man, int line, int offs) { /* * Co-ordinate what happens with having a next-line scope open: @@ -396,32 +396,32 @@ man_descope(struct man *m, int line, int offs) * out the block scope (also if applicable). */ - if (MAN_ELINE & m->flags) { - m->flags &= ~MAN_ELINE; - if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX)) + if (MAN_ELINE & man->flags) { + man->flags &= ~MAN_ELINE; + if ( ! man_unscope(man, man->last->parent, MANDOCERR_MAX)) return(0); } - if ( ! (MAN_BLINE & m->flags)) + if ( ! (MAN_BLINE & man->flags)) return(1); - m->flags &= ~MAN_BLINE; + man->flags &= ~MAN_BLINE; - if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX)) + if ( ! man_unscope(man, man->last->parent, MANDOCERR_MAX)) return(0); - return(man_body_alloc(m, line, offs, m->last->tok)); + return(man_body_alloc(man, line, offs, man->last->tok)); } static int -man_ptext(struct man *m, int line, char *buf, int offs) +man_ptext(struct man *man, int line, char *buf, int offs) { int i; /* Literal free-form text whitespace is preserved. */ - if (MAN_LITERAL & m->flags) { - if ( ! man_word_alloc(m, line, offs, buf + offs)) + if (MAN_LITERAL & man->flags) { + if ( ! man_word_alloc(man, line, offs, buf + offs)) return(0); - return(man_descope(m, line, offs)); + return(man_descope(man, line, offs)); } /* Pump blank lines directly into the backend. */ @@ -431,9 +431,9 @@ man_ptext(struct man *m, int line, char *buf, int offs) if ('\0' == buf[i]) { /* Allocate a blank entry. */ - if ( ! man_elem_alloc(m, line, offs, MAN_sp)) + if ( ! man_elem_alloc(man, line, offs, MAN_sp)) return(0); - m->next = MAN_NEXT_SIBLING; + man->next = MAN_NEXT_SIBLING; return(1); } @@ -447,7 +447,7 @@ man_ptext(struct man *m, int line, char *buf, int offs) if (' ' == buf[i - 1] || '\t' == buf[i - 1]) { if (i > 1 && '\\' != buf[i - 2]) - man_pmsg(m, line, i - 1, MANDOCERR_EOLNSPACE); + man_pmsg(man, line, i - 1, MANDOCERR_EOLNSPACE); for (--i; i && ' ' == buf[i]; i--) /* Spin back to non-space. */ ; @@ -458,7 +458,7 @@ man_ptext(struct man *m, int line, char *buf, int offs) buf[i] = '\0'; } - if ( ! man_word_alloc(m, line, offs, buf + offs)) + if ( ! man_word_alloc(man, line, offs, buf + offs)) return(0); /* @@ -469,13 +469,13 @@ man_ptext(struct man *m, int line, char *buf, int offs) assert(i); if (mandoc_eos(buf, (size_t)i, 0)) - m->last->flags |= MAN_EOS; + man->last->flags |= MAN_EOS; - return(man_descope(m, line, offs)); + return(man_descope(man, line, offs)); } static int -man_pmacro(struct man *m, int ln, char *buf, int offs) +man_pmacro(struct man *man, int ln, char *buf, int offs) { int i, ppos; enum mant tok; @@ -483,7 +483,7 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) struct man_node *n; if ('"' == buf[offs]) { - man_pmsg(m, ln, offs, MANDOCERR_BADCOMMENT); + man_pmsg(man, ln, offs, MANDOCERR_BADCOMMENT); return(1); } else if ('\0' == buf[offs]) return(1); @@ -505,7 +505,7 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) tok = (i > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX; if (MAN_MAX == tok) { - mandoc_vmsg(MANDOCERR_MACRO, m->parse, ln, + mandoc_vmsg(MANDOCERR_MACRO, man->parse, ln, ppos, "%s", buf + ppos - 1); return(1); } @@ -521,7 +521,7 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) */ if ('\0' == buf[offs] && ' ' == buf[offs - 1]) - man_pmsg(m, ln, offs - 1, MANDOCERR_EOLNSPACE); + man_pmsg(man, ln, offs - 1, MANDOCERR_EOLNSPACE); /* * Remove prior ELINE macro, as it's being clobbered by a new @@ -530,8 +530,8 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) */ if ( ! (MAN_NSCOPED & man_macros[tok].flags) && - m->flags & MAN_ELINE) { - n = m->last; + man->flags & MAN_ELINE) { + n = man->last; assert(MAN_TEXT != n->type); /* Remove repeated NSCOPED macros causing ELINE. */ @@ -539,20 +539,20 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) if (MAN_NSCOPED & man_macros[n->tok].flags) n = n->parent; - mandoc_vmsg(MANDOCERR_LINESCOPE, m->parse, n->line, + mandoc_vmsg(MANDOCERR_LINESCOPE, man->parse, n->line, n->pos, "%s breaks %s", man_macronames[tok], man_macronames[n->tok]); - man_node_delete(m, n); - m->flags &= ~MAN_ELINE; + man_node_delete(man, n); + man->flags &= ~MAN_ELINE; } /* * Remove prior BLINE macro that is being clobbered. */ - if ((m->flags & MAN_BLINE) && + if ((man->flags & MAN_BLINE) && (MAN_BSCOPE & man_macros[tok].flags)) { - n = m->last; + n = man->last; /* Might be a text node like 8 in * .TP 8 @@ -570,12 +570,12 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) assert(MAN_BLOCK == n->type); assert(MAN_SCOPED & man_macros[n->tok].flags); - mandoc_vmsg(MANDOCERR_LINESCOPE, m->parse, n->line, + mandoc_vmsg(MANDOCERR_LINESCOPE, man->parse, n->line, n->pos, "%s breaks %s", man_macronames[tok], man_macronames[n->tok]); - man_node_delete(m, n); - m->flags &= ~MAN_BLINE; + man_node_delete(man, n); + man->flags &= ~MAN_BLINE; } /* @@ -584,13 +584,13 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) * when they exit. */ - if (MAN_BLINE & m->flags) - m->flags |= MAN_BPLINE; + if (MAN_BLINE & man->flags) + man->flags |= MAN_BPLINE; /* Call to handler... */ assert(man_macros[tok].fp); - if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &offs, buf)) + if ( ! (*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf)) goto err; /* @@ -598,19 +598,19 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) * above-parsed macro, so return. */ - if ( ! (MAN_BPLINE & m->flags)) { - m->flags &= ~MAN_ILINE; + if ( ! (MAN_BPLINE & man->flags)) { + man->flags &= ~MAN_ILINE; return(1); } - m->flags &= ~MAN_BPLINE; + man->flags &= ~MAN_BPLINE; /* * If we're in a block scope, then allow this macro to slip by * without closing scope around it. */ - if (MAN_ILINE & m->flags) { - m->flags &= ~MAN_ILINE; + if (MAN_ILINE & man->flags) { + man->flags &= ~MAN_ILINE; return(1); } @@ -619,30 +619,30 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) * now, as the next line will close out the block scope. */ - if (MAN_ELINE & m->flags) + if (MAN_ELINE & man->flags) return(1); /* Close out the block scope opened in the prior line. */ - assert(MAN_BLINE & m->flags); - m->flags &= ~MAN_BLINE; + assert(MAN_BLINE & man->flags); + man->flags &= ~MAN_BLINE; - if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX)) + if ( ! man_unscope(man, man->last->parent, MANDOCERR_MAX)) return(0); - return(man_body_alloc(m, ln, ppos, m->last->tok)); + return(man_body_alloc(man, ln, ppos, man->last->tok)); err: /* Error out. */ - m->flags |= MAN_HALT; + man->flags |= MAN_HALT; return(0); } /* - * Unlink a node from its context. If "m" is provided, the last parse + * Unlink a node from its context. If "man" is provided, the last parse * point will also be adjusted accordingly. */ static void -man_node_unlink(struct man *m, struct man_node *n) +man_node_unlink(struct man *man, struct man_node *n) { /* Adjust siblings. */ @@ -662,26 +662,26 @@ man_node_unlink(struct man *m, struct man_node *n) /* Adjust parse point, if applicable. */ - if (m && m->last == n) { + if (man && man->last == n) { /*XXX: this can occur when bailing from validation. */ /*assert(NULL == n->next);*/ if (n->prev) { - m->last = n->prev; - m->next = MAN_NEXT_SIBLING; + man->last = n->prev; + man->next = MAN_NEXT_SIBLING; } else { - m->last = n->parent; - m->next = MAN_NEXT_CHILD; + man->last = n->parent; + man->next = MAN_NEXT_CHILD; } } - if (m && m->first == n) - m->first = NULL; + if (man && man->first == n) + man->first = NULL; } const struct mparse * -man_mparse(const struct man *m) +man_mparse(const struct man *man) { - assert(m && m->parse); - return(m->parse); + assert(man && man->parse); + return(man->parse); } diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index e79f976549b..b9791f43b29 100644 --- a/usr.bin/mandoc/man_html.c +++ b/usr.bin/mandoc/man_html.c @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.47 2012/06/02 20:07:09 schwarze Exp $ */ +/* $Id: man_html.c,v 1.48 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -33,7 +33,7 @@ #define INDENT 5 -#define MAN_ARGS const struct man_meta *m, \ +#define MAN_ARGS const struct man_meta *man, \ const struct man_node *n, \ struct mhtml *mh, \ struct html *h @@ -137,12 +137,12 @@ print_bvspace(struct html *h, const struct man_node *n) } void -html_man(void *arg, const struct man *m) +html_man(void *arg, const struct man *man) { struct mhtml mh; memset(&mh, 0, sizeof(struct mhtml)); - print_man(man_meta(m), man_node(m), &mh, (struct html *)arg); + print_man(man_meta(man), man_node(man), &mh, (struct html *)arg); putchar('\n'); } @@ -158,14 +158,14 @@ print_man(MAN_ARGS) print_gen_decls(h); t = print_otag(h, TAG_HTML, 0, NULL); tt = print_otag(h, TAG_HEAD, 0, NULL); - print_man_head(m, n, mh, h); + print_man_head(man, n, mh, h); print_tagq(h, tt); print_otag(h, TAG_BODY, 0, NULL); print_otag(h, TAG_DIV, 1, &tag); } else t = print_otag(h, TAG_DIV, 1, &tag); - print_man_nodelist(m, n, mh, h); + print_man_nodelist(man, n, mh, h); print_tagq(h, t); } @@ -176,9 +176,9 @@ print_man_head(MAN_ARGS) { print_gen_head(h); - assert(m->title); - assert(m->msec); - bufcat_fmt(h, "%s(%s)", m->title, m->msec); + assert(man->title); + assert(man->msec); + bufcat_fmt(h, "%s(%s)", man->title, man->msec); print_otag(h, TAG_TITLE, 0, NULL); print_text(h, h->buf); } @@ -188,9 +188,9 @@ static void print_man_nodelist(MAN_ARGS) { - print_man_node(m, n, mh, h); + print_man_node(man, n, mh, h); if (n->next) - print_man_nodelist(m, n->next, mh, h); + print_man_nodelist(man, n->next, mh, h); } @@ -205,7 +205,7 @@ print_man_node(MAN_ARGS) switch (n->type) { case (MAN_ROOT): - man_root_pre(m, n, mh, h); + man_root_pre(man, n, mh, h); break; case (MAN_TEXT): /* @@ -256,25 +256,25 @@ print_man_node(MAN_ARGS) t = h->tags.head; } if (mans[n->tok].pre) - child = (*mans[n->tok].pre)(m, n, mh, h); + child = (*mans[n->tok].pre)(man, n, mh, h); break; } if (child && n->child) - print_man_nodelist(m, n->child, mh, h); + print_man_nodelist(man, n->child, mh, h); /* This will automatically close out any font scope. */ print_stagq(h, t); switch (n->type) { case (MAN_ROOT): - man_root_post(m, n, mh, h); + man_root_post(man, n, mh, h); break; case (MAN_EQN): break; default: if (mans[n->tok].post) - (*mans[n->tok].post)(m, n, mh, h); + (*mans[n->tok].post)(man, n, mh, h); break; } } @@ -302,12 +302,12 @@ man_root_pre(MAN_ARGS) char b[BUFSIZ], title[BUFSIZ]; b[0] = 0; - if (m->vol) - (void)strlcat(b, m->vol, BUFSIZ); + if (man->vol) + (void)strlcat(b, man->vol, BUFSIZ); - assert(m->title); - assert(m->msec); - snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec); + assert(man->title); + assert(man->msec); + snprintf(title, BUFSIZ - 1, "%s(%s)", man->title, man->msec); PAIR_SUMMARY_INIT(&tag[0], "Document Header"); PAIR_CLASS_INIT(&tag[1], "head"); @@ -361,16 +361,16 @@ man_root_post(MAN_ARGS) PAIR_CLASS_INIT(&tag[0], "foot-date"); print_otag(h, TAG_TD, 1, tag); - assert(m->date); - print_text(h, m->date); + assert(man->date); + print_text(h, man->date); print_stagq(h, tt); PAIR_CLASS_INIT(&tag[0], "foot-os"); PAIR_INIT(&tag[1], ATTR_ALIGN, "right"); print_otag(h, TAG_TD, 2, tag); - if (m->source) - print_text(h, m->source); + if (man->source) + print_text(h, man->source); print_tagq(h, t); } @@ -466,7 +466,7 @@ man_alt_pre(MAN_ARGS) if (TAG_MAX != fp) t = print_otag(h, fp, 0, NULL); - print_man_node(m, nn, mh, h); + print_man_node(man, nn, mh, h); if (t) print_tagq(h, t); @@ -541,14 +541,14 @@ man_IP_pre(MAN_ARGS) /* For IP, only print the first header element. */ if (MAN_IP == n->tok && n->child) - print_man_node(m, n->child, mh, h); + print_man_node(man, n->child, mh, h); /* For TP, only print next-line header elements. */ if (MAN_TP == n->tok) for (nn = n->child; nn; nn = nn->next) if (nn->line > n->line) - print_man_node(m, nn, mh, h); + print_man_node(man, nn, mh, h); return(0); } diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index 07f298c0ee9..fd6bc082996 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.37 2012/07/07 17:39:05 schwarze Exp $ */ +/* $Id: man_macro.c,v 1.38 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -93,7 +93,7 @@ const struct man_macro * const man_macros = __man_macros; * Warn when "n" is an explicit non-roff macro. */ static void -rew_warn(struct man *m, struct man_node *n, enum mandocerr er) +rew_warn(struct man *man, struct man_node *n, enum mandocerr er) { if (er == MANDOCERR_MAX || MAN_BLOCK != n->type) @@ -104,7 +104,7 @@ rew_warn(struct man *m, struct man_node *n, enum mandocerr er) return; assert(er < MANDOCERR_FATAL); - man_nmsg(m, n, er); + man_nmsg(man, n, er); } @@ -113,33 +113,33 @@ rew_warn(struct man *m, struct man_node *n, enum mandocerr er) * will be used if an explicit block scope is being closed out. */ int -man_unscope(struct man *m, const struct man_node *to, +man_unscope(struct man *man, const struct man_node *to, enum mandocerr er) { struct man_node *n; assert(to); - m->next = MAN_NEXT_SIBLING; + man->next = MAN_NEXT_SIBLING; /* LINTED */ - while (m->last != to) { + while (man->last != to) { /* * Save the parent here, because we may delete the - * m->last node in the post-validation phase and reset - * it to m->last->parent, causing a step in the closing + * man->last node in the post-validation phase and reset + * it to man->last->parent, causing a step in the closing * out to be lost. */ - n = m->last->parent; - rew_warn(m, m->last, er); - if ( ! man_valid_post(m)) + n = man->last->parent; + rew_warn(man, man->last, er); + if ( ! man_valid_post(man)) return(0); - m->last = n; - assert(m->last); + man->last = n; + assert(man->last); } - rew_warn(m, m->last, er); - if ( ! man_valid_post(m)) + rew_warn(man, man->last, er); + if ( ! man_valid_post(man)) return(0); return(1); @@ -237,13 +237,13 @@ rew_dohalt(enum mant tok, enum man_type type, const struct man_node *n) * scopes. When a scope is closed, it must be validated and actioned. */ static int -rew_scope(enum man_type type, struct man *m, enum mant tok) +rew_scope(enum man_type type, struct man *man, enum mant tok) { struct man_node *n; enum rew c; /* LINTED */ - for (n = m->last; n; n = n->parent) { + for (n = man->last; n; n = n->parent) { /* * Whether we should stop immediately (REW_HALT), stop * and rewind until this point (REW_REWIND), or keep @@ -262,7 +262,7 @@ rew_scope(enum man_type type, struct man *m, enum mant tok) */ assert(n); - return(man_unscope(m, n, MANDOCERR_MAX)); + return(man_unscope(man, n, MANDOCERR_MAX)); } @@ -285,14 +285,14 @@ blk_close(MACRO_PROT_ARGS) /* NOTREACHED */ } - for (nn = m->last->parent; nn; nn = nn->parent) + for (nn = man->last->parent; nn; nn = nn->parent) if (ntok == nn->tok && MAN_BLOCK == nn->type) break; if (NULL != nn) - man_unscope(m, nn, MANDOCERR_MAX); + man_unscope(man, nn, MANDOCERR_MAX); else - man_pmsg(m, line, ppos, MANDOCERR_NOSCOPE); + man_pmsg(man, line, ppos, MANDOCERR_NOSCOPE); return(1); } @@ -308,34 +308,34 @@ blk_exp(MACRO_PROT_ARGS) /* Close out prior implicit scopes. */ - if ( ! rew_scope(MAN_BLOCK, m, tok)) + if ( ! rew_scope(MAN_BLOCK, man, tok)) return(0); - if ( ! man_block_alloc(m, line, ppos, tok)) + if ( ! man_block_alloc(man, line, ppos, tok)) return(0); - if ( ! man_head_alloc(m, line, ppos, tok)) + if ( ! man_head_alloc(man, line, ppos, tok)) return(0); for (;;) { la = *pos; - if ( ! man_args(m, line, pos, buf, &p)) + if ( ! man_args(man, line, pos, buf, &p)) break; - if ( ! man_word_alloc(m, line, la, p)) + if ( ! man_word_alloc(man, line, la, p)) return(0); } - assert(m); + assert(man); assert(tok != MAN_MAX); - for (n = m->last; n; n = n->parent) { + for (n = man->last; n; n = n->parent) { if (n->tok != tok) continue; assert(MAN_HEAD == n->type); - man_unscope(m, n, MANDOCERR_MAX); + man_unscope(man, n, MANDOCERR_MAX); break; } - return(man_body_alloc(m, line, ppos, tok)); + return(man_body_alloc(man, line, ppos, tok)); } @@ -356,27 +356,27 @@ blk_imp(MACRO_PROT_ARGS) /* Close out prior scopes. */ - if ( ! rew_scope(MAN_BODY, m, tok)) + if ( ! rew_scope(MAN_BODY, man, tok)) return(0); - if ( ! rew_scope(MAN_BLOCK, m, tok)) + if ( ! rew_scope(MAN_BLOCK, man, tok)) return(0); /* Allocate new block & head scope. */ - if ( ! man_block_alloc(m, line, ppos, tok)) + if ( ! man_block_alloc(man, line, ppos, tok)) return(0); - if ( ! man_head_alloc(m, line, ppos, tok)) + if ( ! man_head_alloc(man, line, ppos, tok)) return(0); - n = m->last; + n = man->last; /* Add line arguments. */ for (;;) { la = *pos; - if ( ! man_args(m, line, pos, buf, &p)) + if ( ! man_args(man, line, pos, buf, &p)) break; - if ( ! man_word_alloc(m, line, la, p)) + if ( ! man_word_alloc(man, line, la, p)) return(0); } @@ -385,17 +385,17 @@ blk_imp(MACRO_PROT_ARGS) if (MAN_SCOPED & man_macros[tok].flags) { /* If we're forcing scope (`TP'), keep it open. */ if (MAN_FSCOPED & man_macros[tok].flags) { - m->flags |= MAN_BLINE; + man->flags |= MAN_BLINE; return(1); - } else if (n == m->last) { - m->flags |= MAN_BLINE; + } else if (n == man->last) { + man->flags |= MAN_BLINE; return(1); } } - if ( ! rew_scope(MAN_HEAD, m, tok)) + if ( ! rew_scope(MAN_HEAD, man, tok)) return(0); - return(man_body_alloc(m, line, ppos, tok)); + return(man_body_alloc(man, line, ppos, tok)); } @@ -407,16 +407,16 @@ in_line_eoln(MACRO_PROT_ARGS) char *p; struct man_node *n; - if ( ! man_elem_alloc(m, line, ppos, tok)) + if ( ! man_elem_alloc(man, line, ppos, tok)) return(0); - n = m->last; + n = man->last; for (;;) { la = *pos; - if ( ! man_args(m, line, pos, buf, &p)) + if ( ! man_args(man, line, pos, buf, &p)) break; - if ( ! man_word_alloc(m, line, la, p)) + if ( ! man_word_alloc(man, line, la, p)) return(0); } @@ -426,9 +426,9 @@ in_line_eoln(MACRO_PROT_ARGS) * waiting for terms to load into our context. */ - if (n == m->last && MAN_SCOPED & man_macros[tok].flags) { + if (n == man->last && MAN_SCOPED & man_macros[tok].flags) { assert( ! (MAN_NSCOPED & man_macros[tok].flags)); - m->flags |= MAN_ELINE; + man->flags |= MAN_ELINE; return(1); } @@ -436,11 +436,11 @@ in_line_eoln(MACRO_PROT_ARGS) if (MAN_NSCOPED & man_macros[tok].flags) { assert( ! (MAN_SCOPED & man_macros[tok].flags)); - m->flags |= MAN_ILINE; + man->flags |= MAN_ILINE; } - assert(MAN_ROOT != m->last->type); - m->next = MAN_NEXT_SIBLING; + assert(MAN_ROOT != man->last->type); + man->next = MAN_NEXT_SIBLING; /* * Rewind our element scope. Note that when TH is pruned, we'll @@ -448,22 +448,22 @@ in_line_eoln(MACRO_PROT_ARGS) * its sibling. */ - for ( ; m->last; m->last = m->last->parent) { - if (m->last == n) + for ( ; man->last; man->last = man->last->parent) { + if (man->last == n) break; - if (m->last->type == MAN_ROOT) + if (man->last->type == MAN_ROOT) break; - if ( ! man_valid_post(m)) + if ( ! man_valid_post(man)) return(0); } - assert(m->last); + assert(man->last); /* * Same here regarding whether we're back at the root. */ - if (m->last->type != MAN_ROOT && ! man_valid_post(m)) + if (man->last->type != MAN_ROOT && ! man_valid_post(man)) return(0); return(1); @@ -471,14 +471,14 @@ in_line_eoln(MACRO_PROT_ARGS) int -man_macroend(struct man *m) +man_macroend(struct man *man) { - return(man_unscope(m, m->first, MANDOCERR_SCOPEEXIT)); + return(man_unscope(man, man->first, MANDOCERR_SCOPEEXIT)); } static int -man_args(struct man *m, int line, int *pos, char *buf, char **v) +man_args(struct man *man, int line, int *pos, char *buf, char **v) { char *start; @@ -489,6 +489,6 @@ man_args(struct man *m, int line, int *pos, char *buf, char **v) if ('\0' == *start) return(0); - *v = mandoc_getarg(m->parse, v, line, pos); + *v = mandoc_getarg(man->parse, v, line, pos); return(1); } diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 5b4defd22ab..f408f824cf6 100644 --- a/usr.bin/mandoc/man_term.c +++ b/usr.bin/mandoc/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.88 2012/07/29 12:35:05 schwarze Exp $ */ +/* $Id: man_term.c,v 1.89 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -44,7 +44,7 @@ struct mtermp { #define DECL_ARGS struct termp *p, \ struct mtermp *mt, \ const struct man_node *n, \ - const struct man_meta *m + const struct man_meta *meta struct termact { int (*pre)(DECL_ARGS); @@ -134,7 +134,7 @@ terminal_man(void *arg, const struct man *man) { struct termp *p; const struct man_node *n; - const struct man_meta *m; + const struct man_meta *meta; struct mtermp mt; p = (struct termp *)arg; @@ -150,9 +150,9 @@ terminal_man(void *arg, const struct man *man) p->symtab = mchars_alloc(); n = man_node(man); - m = man_meta(man); + meta = man_meta(man); - term_begin(p, print_man_head, print_man_foot, m); + term_begin(p, print_man_head, print_man_foot, meta); p->flags |= TERMP_NOSPACE; memset(&mt, 0, sizeof(struct mtermp)); @@ -162,7 +162,7 @@ terminal_man(void *arg, const struct man *man) mt.pardist = 1; if (n->child) - print_man_nodelist(p, &mt, n->child, m); + print_man_nodelist(p, &mt, n->child, meta); term_end(p); } @@ -323,7 +323,7 @@ pre_alternate(DECL_ARGS) term_fontrepl(p, font[i]); if (savelit && NULL == nn->next) mt->fl |= MANT_LITERAL; - print_man_node(p, mt, nn, m); + print_man_node(p, mt, nn, meta); if (nn->next) p->flags |= TERMP_NOSPACE; } @@ -640,7 +640,7 @@ pre_IP(DECL_ARGS) mt->fl &= ~MANT_LITERAL; if (n->child) - print_man_node(p, mt, n->child, m); + print_man_node(p, mt, n->child, meta); if (savelit) mt->fl |= MANT_LITERAL; @@ -725,7 +725,7 @@ pre_TP(DECL_ARGS) /* Don't print same-line elements. */ for (nn = n->child; nn; nn = nn->next) if (nn->line > n->line) - print_man_node(p, mt, nn, m); + print_man_node(p, mt, nn, meta); if (savelit) mt->fl |= MANT_LITERAL; @@ -978,13 +978,13 @@ print_man_node(DECL_ARGS) c = 1; if (termacts[n->tok].pre) - c = (*termacts[n->tok].pre)(p, mt, n, m); + c = (*termacts[n->tok].pre)(p, mt, n, meta); if (c && n->child) - print_man_nodelist(p, mt, n->child, m); + print_man_nodelist(p, mt, n->child, meta); if (termacts[n->tok].post) - (*termacts[n->tok].post)(p, mt, n, m); + (*termacts[n->tok].post)(p, mt, n, meta); if ( ! (MAN_NOTEXT & termacts[n->tok].flags)) term_fontrepl(p, TERMFONT_NONE); @@ -1022,10 +1022,10 @@ static void print_man_nodelist(DECL_ARGS) { - print_man_node(p, mt, n, m); + print_man_node(p, mt, n, meta); if ( ! n->next) return; - print_man_nodelist(p, mt, n->next, m); + print_man_nodelist(p, mt, n->next, meta); } @@ -1100,21 +1100,21 @@ print_man_head(struct termp *p, const void *arg) { char buf[BUFSIZ], title[BUFSIZ]; size_t buflen, titlen; - const struct man_meta *m; + const struct man_meta *meta; - m = (const struct man_meta *)arg; - assert(m->title); - assert(m->msec); + meta = (const struct man_meta *)arg; + assert(meta->title); + assert(meta->msec); - if (m->vol) - strlcpy(buf, m->vol, BUFSIZ); + if (meta->vol) + strlcpy(buf, meta->vol, BUFSIZ); else buf[0] = '\0'; buflen = term_strlen(p, buf); /* Top left corner: manual title and section. */ - snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec); + snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); titlen = term_strlen(p, title); p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index 97e4e75f163..ea80779516c 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.56 2012/07/29 12:35:05 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.57 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -31,7 +31,7 @@ #include "libman.h" #include "libmandoc.h" -#define CHKARGS struct man *m, struct man_node *n +#define CHKARGS struct man *man, struct man_node *n typedef int (*v_check)(CHKARGS); @@ -119,7 +119,7 @@ static const struct man_valid man_valids[MAN_MAX] = { int -man_valid_pre(struct man *m, struct man_node *n) +man_valid_pre(struct man *man, struct man_node *n) { v_check *cp; @@ -139,27 +139,27 @@ man_valid_pre(struct man *m, struct man_node *n) if (NULL == (cp = man_valids[n->tok].pres)) return(1); for ( ; *cp; cp++) - if ( ! (*cp)(m, n)) + if ( ! (*cp)(man, n)) return(0); return(1); } int -man_valid_post(struct man *m) +man_valid_post(struct man *man) { v_check *cp; - if (MAN_VALID & m->last->flags) + if (MAN_VALID & man->last->flags) return(1); - m->last->flags |= MAN_VALID; + man->last->flags |= MAN_VALID; - switch (m->last->type) { + switch (man->last->type) { case (MAN_TEXT): - check_text(m, m->last); + check_text(man, man->last); return(1); case (MAN_ROOT): - return(check_root(m, m->last)); + return(check_root(man, man->last)); case (MAN_EQN): /* FALLTHROUGH */ case (MAN_TBL): @@ -168,10 +168,10 @@ man_valid_post(struct man *m) break; } - if (NULL == (cp = man_valids[m->last->tok].posts)) + if (NULL == (cp = man_valids[man->last->tok].posts)) return(1); for ( ; *cp; cp++) - if ( ! (*cp)(m, m->last)) + if ( ! (*cp)(man, man->last)) return(0); return(1); @@ -182,29 +182,29 @@ static int check_root(CHKARGS) { - if (MAN_BLINE & m->flags) - man_nmsg(m, n, MANDOCERR_SCOPEEXIT); - else if (MAN_ELINE & m->flags) - man_nmsg(m, n, MANDOCERR_SCOPEEXIT); + if (MAN_BLINE & man->flags) + man_nmsg(man, n, MANDOCERR_SCOPEEXIT); + else if (MAN_ELINE & man->flags) + man_nmsg(man, n, MANDOCERR_SCOPEEXIT); - m->flags &= ~MAN_BLINE; - m->flags &= ~MAN_ELINE; + man->flags &= ~MAN_BLINE; + man->flags &= ~MAN_ELINE; - if (NULL == m->first->child) { - man_nmsg(m, n, MANDOCERR_NODOCBODY); + if (NULL == man->first->child) { + man_nmsg(man, n, MANDOCERR_NODOCBODY); return(0); - } else if (NULL == m->meta.title) { - man_nmsg(m, n, MANDOCERR_NOTITLE); + } else if (NULL == man->meta.title) { + man_nmsg(man, n, MANDOCERR_NOTITLE); /* * If a title hasn't been set, do so now (by * implication, date and section also aren't set). */ - m->meta.title = mandoc_strdup("unknown"); - m->meta.msec = mandoc_strdup("1"); - m->meta.date = mandoc_normdate - (m->parse, NULL, n->line, n->pos); + man->meta.title = mandoc_strdup("unknown"); + man->meta.msec = mandoc_strdup("1"); + man->meta.date = mandoc_normdate + (man->parse, NULL, n->line, n->pos); } return(1); @@ -215,12 +215,12 @@ check_text(CHKARGS) { char *cp, *p; - if (MAN_LITERAL & m->flags) + if (MAN_LITERAL & man->flags) return; cp = n->string; for (p = cp; NULL != (p = strchr(p, '\t')); p++) - man_pmsg(m, n->line, (int)(p - cp), MANDOCERR_BADTAB); + man_pmsg(man, n->line, (int)(p - cp), MANDOCERR_BADTAB); } #define INEQ_DEFINE(x, ineq, name) \ @@ -229,7 +229,7 @@ check_##name(CHKARGS) \ { \ if (n->nchild ineq (x)) \ return(1); \ - mandoc_vmsg(MANDOCERR_ARGCOUNT, m->parse, n->line, n->pos, \ + mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line, n->pos, \ "line arguments %s %d (have %d)", \ #ineq, (x), n->nchild); \ return(1); \ @@ -283,14 +283,14 @@ post_ft(CHKARGS) if (0 == ok) { mandoc_vmsg - (MANDOCERR_BADFONT, m->parse, + (MANDOCERR_BADFONT, man->parse, n->line, n->pos, "%s", cp); *cp = '\0'; } if (1 < n->nchild) mandoc_vmsg - (MANDOCERR_ARGCOUNT, m->parse, n->line, + (MANDOCERR_ARGCOUNT, man->parse, n->line, n->pos, "want one child (have %d)", n->nchild); @@ -302,7 +302,7 @@ pre_sec(CHKARGS) { if (MAN_BLOCK == n->type) - m->flags &= ~MAN_LITERAL; + man->flags &= ~MAN_LITERAL; return(1); } @@ -313,7 +313,7 @@ post_sec(CHKARGS) if ( ! (MAN_HEAD == n->type && 0 == n->nchild)) return(1); - man_nmsg(m, n, MANDOCERR_SYNTARGCOUNT); + man_nmsg(man, n, MANDOCERR_SYNTARGCOUNT); return(0); } @@ -322,7 +322,7 @@ check_part(CHKARGS) { if (MAN_BODY == n->type && 0 == n->nchild) - mandoc_msg(MANDOCERR_ARGCWARN, m->parse, n->line, + mandoc_msg(MANDOCERR_ARGCWARN, man->parse, n->line, n->pos, "want children (have none)"); return(1); @@ -336,15 +336,15 @@ check_par(CHKARGS) switch (n->type) { case (MAN_BLOCK): if (0 == n->body->nchild) - man_node_delete(m, n); + man_node_delete(man, n); break; case (MAN_BODY): if (0 == n->nchild) - man_nmsg(m, n, MANDOCERR_IGNPAR); + man_nmsg(man, n, MANDOCERR_IGNPAR); break; case (MAN_HEAD): if (n->nchild) - man_nmsg(m, n, MANDOCERR_ARGSLOST); + man_nmsg(man, n, MANDOCERR_ARGSLOST); break; default: break; @@ -360,11 +360,11 @@ post_IP(CHKARGS) switch (n->type) { case (MAN_BLOCK): if (0 == n->head->nchild && 0 == n->body->nchild) - man_node_delete(m, n); + man_node_delete(man, n); break; case (MAN_BODY): if (0 == n->parent->head->nchild && 0 == n->nchild) - man_nmsg(m, n, MANDOCERR_IGNPAR); + man_nmsg(man, n, MANDOCERR_IGNPAR); break; default: break; @@ -378,21 +378,16 @@ post_TH(CHKARGS) const char *p; int line, pos; - if (m->meta.title) - free(m->meta.title); - if (m->meta.vol) - free(m->meta.vol); - if (m->meta.source) - free(m->meta.source); - if (m->meta.msec) - free(m->meta.msec); - if (m->meta.date) - free(m->meta.date); + free(man->meta.title); + free(man->meta.vol); + free(man->meta.source); + free(man->meta.msec); + free(man->meta.date); line = n->line; pos = n->pos; - m->meta.title = m->meta.vol = m->meta.date = - m->meta.msec = m->meta.source = NULL; + man->meta.title = man->meta.vol = man->meta.date = + man->meta.msec = man->meta.source = NULL; /* ->TITLE<- MSEC DATE SOURCE VOL */ @@ -402,22 +397,22 @@ post_TH(CHKARGS) /* Only warn about this once... */ if (isalpha((unsigned char)*p) && ! isupper((unsigned char)*p)) { - man_nmsg(m, n, MANDOCERR_UPPERCASE); + man_nmsg(man, n, MANDOCERR_UPPERCASE); break; } } - m->meta.title = mandoc_strdup(n->string); + man->meta.title = mandoc_strdup(n->string); } else - m->meta.title = mandoc_strdup(""); + man->meta.title = mandoc_strdup(""); /* TITLE ->MSEC<- DATE SOURCE VOL */ if (n) n = n->next; if (n && n->string) - m->meta.msec = mandoc_strdup(n->string); + man->meta.msec = mandoc_strdup(n->string); else - m->meta.msec = mandoc_strdup(""); + man->meta.msec = mandoc_strdup(""); /* TITLE MSEC ->DATE<- SOURCE VOL */ @@ -425,30 +420,30 @@ post_TH(CHKARGS) n = n->next; if (n && n->string && '\0' != n->string[0]) { pos = n->pos; - m->meta.date = mandoc_normdate - (m->parse, n->string, line, pos); + man->meta.date = mandoc_normdate + (man->parse, n->string, line, pos); } else - m->meta.date = mandoc_strdup(""); + man->meta.date = mandoc_strdup(""); /* TITLE MSEC DATE ->SOURCE<- VOL */ if (n && (n = n->next)) - m->meta.source = mandoc_strdup(n->string); + man->meta.source = mandoc_strdup(n->string); /* TITLE MSEC DATE SOURCE ->VOL<- */ /* If missing, use the default VOL name for MSEC. */ if (n && (n = n->next)) - m->meta.vol = mandoc_strdup(n->string); - else if ('\0' != m->meta.msec[0] && - (NULL != (p = mandoc_a2msec(m->meta.msec)))) - m->meta.vol = mandoc_strdup(p); + man->meta.vol = mandoc_strdup(n->string); + else if ('\0' != man->meta.msec[0] && + (NULL != (p = mandoc_a2msec(man->meta.msec)))) + man->meta.vol = mandoc_strdup(p); /* * Remove the `TH' node after we've processed it for our * meta-data. */ - man_node_delete(m, m->last); + man_node_delete(man, man->last); return(1); } @@ -456,10 +451,10 @@ static int post_nf(CHKARGS) { - if (MAN_LITERAL & m->flags) - man_nmsg(m, n, MANDOCERR_SCOPEREP); + if (MAN_LITERAL & man->flags) + man_nmsg(man, n, MANDOCERR_SCOPEREP); - m->flags |= MAN_LITERAL; + man->flags |= MAN_LITERAL; return(1); } @@ -467,10 +462,10 @@ static int post_fi(CHKARGS) { - if ( ! (MAN_LITERAL & m->flags)) - man_nmsg(m, n, MANDOCERR_WNOSCOPE); + if ( ! (MAN_LITERAL & man->flags)) + man_nmsg(man, n, MANDOCERR_WNOSCOPE); - m->flags &= ~MAN_LITERAL; + man->flags &= ~MAN_LITERAL; return(1); } @@ -507,10 +502,8 @@ post_UC(CHKARGS) p = bsd_versions[0]; } - if (m->meta.source) - free(m->meta.source); - - m->meta.source = mandoc_strdup(p); + free(man->meta.source); + man->meta.source = mandoc_strdup(p); return(1); } @@ -547,10 +540,8 @@ post_AT(CHKARGS) p = unix_versions[0]; } - if (m->meta.source) - free(m->meta.source); - - m->meta.source = mandoc_strdup(p); + free(man->meta.source); + man->meta.source = mandoc_strdup(p); return(1); } @@ -565,14 +556,14 @@ post_vs(CHKARGS) case (MAN_SH): /* FALLTHROUGH */ case (MAN_SS): - man_nmsg(m, n, MANDOCERR_IGNPAR); + man_nmsg(man, n, MANDOCERR_IGNPAR); /* FALLTHROUGH */ case (MAN_MAX): /* * Don't warn about this because it occurs in pod2man * and would cause considerable (unfixable) warnage. */ - man_node_delete(m, n); + man_node_delete(man, n); break; default: break; diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index c5171c49d66..ec356f8b66f 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.92 2012/11/16 13:25:34 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.93 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -100,20 +100,20 @@ static int mdoc_ptext(struct mdoc *, int, char *, int); static int mdoc_pmacro(struct mdoc *, int, char *, int); const struct mdoc_node * -mdoc_node(const struct mdoc *m) +mdoc_node(const struct mdoc *mdoc) { - assert( ! (MDOC_HALT & m->flags)); - return(m->first); + assert( ! (MDOC_HALT & mdoc->flags)); + return(mdoc->first); } const struct mdoc_meta * -mdoc_meta(const struct mdoc *m) +mdoc_meta(const struct mdoc *mdoc) { - assert( ! (MDOC_HALT & m->flags)); - return(&m->meta); + assert( ! (MDOC_HALT & mdoc->flags)); + return(&mdoc->meta); } @@ -214,61 +214,61 @@ mdoc_alloc(struct roff *roff, struct mparse *parse, char *defos) * through to macro_end() in macro.c. */ int -mdoc_endparse(struct mdoc *m) +mdoc_endparse(struct mdoc *mdoc) { - assert( ! (MDOC_HALT & m->flags)); - if (mdoc_macroend(m)) + assert( ! (MDOC_HALT & mdoc->flags)); + if (mdoc_macroend(mdoc)) return(1); - m->flags |= MDOC_HALT; + mdoc->flags |= MDOC_HALT; return(0); } int -mdoc_addeqn(struct mdoc *m, const struct eqn *ep) +mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep) { struct mdoc_node *n; - assert( ! (MDOC_HALT & m->flags)); + assert( ! (MDOC_HALT & mdoc->flags)); /* No text before an initial macro. */ - if (SEC_NONE == m->lastnamed) { - mdoc_pmsg(m, ep->ln, ep->pos, MANDOCERR_NOTEXT); + if (SEC_NONE == mdoc->lastnamed) { + mdoc_pmsg(mdoc, ep->ln, ep->pos, MANDOCERR_NOTEXT); return(1); } - n = node_alloc(m, ep->ln, ep->pos, MDOC_MAX, MDOC_EQN); + n = node_alloc(mdoc, ep->ln, ep->pos, MDOC_MAX, MDOC_EQN); n->eqn = ep; - if ( ! node_append(m, n)) + if ( ! node_append(mdoc, n)) return(0); - m->next = MDOC_NEXT_SIBLING; + mdoc->next = MDOC_NEXT_SIBLING; return(1); } int -mdoc_addspan(struct mdoc *m, const struct tbl_span *sp) +mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp) { struct mdoc_node *n; - assert( ! (MDOC_HALT & m->flags)); + assert( ! (MDOC_HALT & mdoc->flags)); /* No text before an initial macro. */ - if (SEC_NONE == m->lastnamed) { - mdoc_pmsg(m, sp->line, 0, MANDOCERR_NOTEXT); + if (SEC_NONE == mdoc->lastnamed) { + mdoc_pmsg(mdoc, sp->line, 0, MANDOCERR_NOTEXT); return(1); } - n = node_alloc(m, sp->line, 0, MDOC_MAX, MDOC_TBL); + n = node_alloc(mdoc, sp->line, 0, MDOC_MAX, MDOC_TBL); n->span = sp; - if ( ! node_append(m, n)) + if ( ! node_append(mdoc, n)) return(0); - m->next = MDOC_NEXT_SIBLING; + mdoc->next = MDOC_NEXT_SIBLING; return(1); } @@ -278,12 +278,12 @@ mdoc_addspan(struct mdoc *m, const struct tbl_span *sp) * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()). */ int -mdoc_parseln(struct mdoc *m, int ln, char *buf, int offs) +mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs) { - assert( ! (MDOC_HALT & m->flags)); + assert( ! (MDOC_HALT & mdoc->flags)); - m->flags |= MDOC_NEWLINE; + mdoc->flags |= MDOC_NEWLINE; /* * Let the roff nS register switch SYNOPSIS mode early, @@ -291,16 +291,16 @@ mdoc_parseln(struct mdoc *m, int ln, char *buf, int offs) * whether this mode is on or off. * Note that this mode is also switched by the Sh macro. */ - if (roff_regisset(m->roff, REG_nS)) { - if (roff_regget(m->roff, REG_nS)) - m->flags |= MDOC_SYNOPSIS; + if (roff_regisset(mdoc->roff, REG_nS)) { + if (roff_regget(mdoc->roff, REG_nS)) + mdoc->flags |= MDOC_SYNOPSIS; else - m->flags &= ~MDOC_SYNOPSIS; + mdoc->flags &= ~MDOC_SYNOPSIS; } - return(roff_getcontrol(m->roff, buf, &offs) ? - mdoc_pmacro(m, ln, buf, offs) : - mdoc_ptext(m, ln, buf, offs)); + return(roff_getcontrol(mdoc->roff, buf, &offs) ? + mdoc_pmacro(mdoc, ln, buf, offs) : + mdoc_ptext(mdoc, ln, buf, offs)); } int @@ -311,31 +311,31 @@ mdoc_macro(MACRO_PROT_ARGS) /* If we're in the body, deny prologue calls. */ if (MDOC_PROLOGUE & mdoc_macros[tok].flags && - MDOC_PBODY & m->flags) { - mdoc_pmsg(m, line, ppos, MANDOCERR_BADBODY); + MDOC_PBODY & mdoc->flags) { + mdoc_pmsg(mdoc, line, ppos, MANDOCERR_BADBODY); return(1); } /* If we're in the prologue, deny "body" macros. */ if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) && - ! (MDOC_PBODY & m->flags)) { - mdoc_pmsg(m, line, ppos, MANDOCERR_BADPROLOG); - if (NULL == m->meta.msec) - m->meta.msec = mandoc_strdup("1"); - if (NULL == m->meta.title) - m->meta.title = mandoc_strdup("UNKNOWN"); - if (NULL == m->meta.vol) - m->meta.vol = mandoc_strdup("LOCAL"); - if (NULL == m->meta.os) - m->meta.os = mandoc_strdup("LOCAL"); - if (NULL == m->meta.date) - m->meta.date = mandoc_normdate - (m->parse, NULL, line, ppos); - m->flags |= MDOC_PBODY; + ! (MDOC_PBODY & mdoc->flags)) { + mdoc_pmsg(mdoc, line, ppos, MANDOCERR_BADPROLOG); + if (NULL == mdoc->meta.msec) + mdoc->meta.msec = mandoc_strdup("1"); + if (NULL == mdoc->meta.title) + mdoc->meta.title = mandoc_strdup("UNKNOWN"); + if (NULL == mdoc->meta.vol) + mdoc->meta.vol = mandoc_strdup("LOCAL"); + if (NULL == mdoc->meta.os) + mdoc->meta.os = mandoc_strdup("LOCAL"); + if (NULL == mdoc->meta.date) + mdoc->meta.date = mandoc_normdate + (mdoc->parse, NULL, line, ppos); + mdoc->flags |= MDOC_PBODY; } - return((*mdoc_macros[tok].fp)(m, tok, line, ppos, pos, buf)); + return((*mdoc_macros[tok].fp)(mdoc, tok, line, ppos, pos, buf)); } @@ -423,13 +423,13 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p) static struct mdoc_node * -node_alloc(struct mdoc *m, int line, int pos, +node_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok, enum mdoc_type type) { struct mdoc_node *p; p = mandoc_calloc(1, sizeof(struct mdoc_node)); - p->sec = m->lastsec; + p->sec = mdoc->lastsec; p->line = line; p->pos = pos; p->tok = tok; @@ -437,84 +437,84 @@ node_alloc(struct mdoc *m, int line, int pos, /* Flag analysis. */ - if (MDOC_SYNOPSIS & m->flags) + if (MDOC_SYNOPSIS & mdoc->flags) p->flags |= MDOC_SYNPRETTY; else p->flags &= ~MDOC_SYNPRETTY; - if (MDOC_NEWLINE & m->flags) + if (MDOC_NEWLINE & mdoc->flags) p->flags |= MDOC_LINE; - m->flags &= ~MDOC_NEWLINE; + mdoc->flags &= ~MDOC_NEWLINE; return(p); } int -mdoc_tail_alloc(struct mdoc *m, int line, int pos, enum mdoct tok) +mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok) { struct mdoc_node *p; - p = node_alloc(m, line, pos, tok, MDOC_TAIL); - if ( ! node_append(m, p)) + p = node_alloc(mdoc, line, pos, tok, MDOC_TAIL); + if ( ! node_append(mdoc, p)) return(0); - m->next = MDOC_NEXT_CHILD; + mdoc->next = MDOC_NEXT_CHILD; return(1); } int -mdoc_head_alloc(struct mdoc *m, int line, int pos, enum mdoct tok) +mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok) { struct mdoc_node *p; - assert(m->first); - assert(m->last); + assert(mdoc->first); + assert(mdoc->last); - p = node_alloc(m, line, pos, tok, MDOC_HEAD); - if ( ! node_append(m, p)) + p = node_alloc(mdoc, line, pos, tok, MDOC_HEAD); + if ( ! node_append(mdoc, p)) return(0); - m->next = MDOC_NEXT_CHILD; + mdoc->next = MDOC_NEXT_CHILD; return(1); } int -mdoc_body_alloc(struct mdoc *m, int line, int pos, enum mdoct tok) +mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok) { struct mdoc_node *p; - p = node_alloc(m, line, pos, tok, MDOC_BODY); - if ( ! node_append(m, p)) + p = node_alloc(mdoc, line, pos, tok, MDOC_BODY); + if ( ! node_append(mdoc, p)) return(0); - m->next = MDOC_NEXT_CHILD; + mdoc->next = MDOC_NEXT_CHILD; return(1); } int -mdoc_endbody_alloc(struct mdoc *m, int line, int pos, enum mdoct tok, +mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok, struct mdoc_node *body, enum mdoc_endbody end) { struct mdoc_node *p; - p = node_alloc(m, line, pos, tok, MDOC_BODY); + p = node_alloc(mdoc, line, pos, tok, MDOC_BODY); p->pending = body; p->norm = body->norm; p->end = end; - if ( ! node_append(m, p)) + if ( ! node_append(mdoc, p)) return(0); - m->next = MDOC_NEXT_SIBLING; + mdoc->next = MDOC_NEXT_SIBLING; return(1); } int -mdoc_block_alloc(struct mdoc *m, int line, int pos, +mdoc_block_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok, struct mdoc_arg *args) { struct mdoc_node *p; - p = node_alloc(m, line, pos, tok, MDOC_BLOCK); + p = node_alloc(mdoc, line, pos, tok, MDOC_BLOCK); p->args = args; if (p->args) (args->refcnt)++; @@ -533,20 +533,20 @@ mdoc_block_alloc(struct mdoc *m, int line, int pos, break; } - if ( ! node_append(m, p)) + if ( ! node_append(mdoc, p)) return(0); - m->next = MDOC_NEXT_CHILD; + mdoc->next = MDOC_NEXT_CHILD; return(1); } int -mdoc_elem_alloc(struct mdoc *m, int line, int pos, +mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok, struct mdoc_arg *args) { struct mdoc_node *p; - p = node_alloc(m, line, pos, tok, MDOC_ELEM); + p = node_alloc(mdoc, line, pos, tok, MDOC_ELEM); p->args = args; if (p->args) (args->refcnt)++; @@ -559,24 +559,24 @@ mdoc_elem_alloc(struct mdoc *m, int line, int pos, break; } - if ( ! node_append(m, p)) + if ( ! node_append(mdoc, p)) return(0); - m->next = MDOC_NEXT_CHILD; + mdoc->next = MDOC_NEXT_CHILD; return(1); } int -mdoc_word_alloc(struct mdoc *m, int line, int pos, const char *p) +mdoc_word_alloc(struct mdoc *mdoc, int line, int pos, const char *p) { struct mdoc_node *n; - n = node_alloc(m, line, pos, MDOC_MAX, MDOC_TEXT); - n->string = roff_strdup(m->roff, p); + n = node_alloc(mdoc, line, pos, MDOC_MAX, MDOC_TEXT); + n->string = roff_strdup(mdoc->roff, p); - if ( ! node_append(m, n)) + if ( ! node_append(mdoc, n)) return(0); - m->next = MDOC_NEXT_SIBLING; + mdoc->next = MDOC_NEXT_SIBLING; return(1); } @@ -596,7 +596,7 @@ mdoc_node_free(struct mdoc_node *p) static void -mdoc_node_unlink(struct mdoc *m, struct mdoc_node *n) +mdoc_node_unlink(struct mdoc *mdoc, struct mdoc_node *n) { /* Adjust siblings. */ @@ -618,41 +618,41 @@ mdoc_node_unlink(struct mdoc *m, struct mdoc_node *n) /* Adjust parse point, if applicable. */ - if (m && m->last == n) { + if (mdoc && mdoc->last == n) { if (n->prev) { - m->last = n->prev; - m->next = MDOC_NEXT_SIBLING; + mdoc->last = n->prev; + mdoc->next = MDOC_NEXT_SIBLING; } else { - m->last = n->parent; - m->next = MDOC_NEXT_CHILD; + mdoc->last = n->parent; + mdoc->next = MDOC_NEXT_CHILD; } } - if (m && m->first == n) - m->first = NULL; + if (mdoc && mdoc->first == n) + mdoc->first = NULL; } void -mdoc_node_delete(struct mdoc *m, struct mdoc_node *p) +mdoc_node_delete(struct mdoc *mdoc, struct mdoc_node *p) { while (p->child) { assert(p->nchild); - mdoc_node_delete(m, p->child); + mdoc_node_delete(mdoc, p->child); } assert(0 == p->nchild); - mdoc_node_unlink(m, p); + mdoc_node_unlink(mdoc, p); mdoc_node_free(p); } int -mdoc_node_relink(struct mdoc *m, struct mdoc_node *p) +mdoc_node_relink(struct mdoc *mdoc, struct mdoc_node *p) { - mdoc_node_unlink(m, p); - return(node_append(m, p)); + mdoc_node_unlink(mdoc, p); + return(node_append(mdoc, p)); } #if 0 @@ -666,7 +666,7 @@ mdoc_node_relink(struct mdoc *m, struct mdoc_node *p) * the end-of-line, i.e., will re-enter in the next roff parse. */ static int -mdoc_preptext(struct mdoc *m, int line, char *buf, int offs) +mdoc_preptext(struct mdoc *mdoc, int line, char *buf, int offs) { char *start, *end; char delim; @@ -674,12 +674,12 @@ mdoc_preptext(struct mdoc *m, int line, char *buf, int offs) while ('\0' != buf[offs]) { /* Mark starting position if eqn is set. */ start = NULL; - if ('\0' != (delim = roff_eqndelim(m->roff))) + if ('\0' != (delim = roff_eqndelim(mdoc->roff))) if (NULL != (start = strchr(buf + offs, delim))) *start++ = '\0'; /* Parse text as normal. */ - if ( ! mdoc_ptext(m, line, buf, offs)) + if ( ! mdoc_ptext(mdoc, line, buf, offs)) return(0); /* Continue only if an equation exists. */ @@ -696,11 +696,11 @@ mdoc_preptext(struct mdoc *m, int line, char *buf, int offs) } /* Parse the equation itself. */ - roff_openeqn(m->roff, NULL, line, offs, buf); + roff_openeqn(mdoc->roff, NULL, line, offs, buf); /* Process a finished equation? */ - if (roff_closeeqn(m->roff)) - if ( ! mdoc_addeqn(m, roff_eqn(m->roff))) + if (roff_closeeqn(mdoc->roff)) + if ( ! mdoc_addeqn(mdoc, roff_eqn(mdoc->roff))) return(0); offs += (end - (buf + offs)); } @@ -714,20 +714,20 @@ mdoc_preptext(struct mdoc *m, int line, char *buf, int offs) * control character. */ static int -mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) +mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs) { char *c, *ws, *end; struct mdoc_node *n; /* No text before an initial macro. */ - if (SEC_NONE == m->lastnamed) { - mdoc_pmsg(m, line, offs, MANDOCERR_NOTEXT); + if (SEC_NONE == mdoc->lastnamed) { + mdoc_pmsg(mdoc, line, offs, MANDOCERR_NOTEXT); return(1); } - assert(m->last); - n = m->last; + assert(mdoc->last); + n = mdoc->last; /* * Divert directly to list processing if we're encountering a @@ -739,8 +739,8 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) if (MDOC_Bl == n->tok && MDOC_BODY == n->type && LIST_column == n->norm->Bl.type) { /* `Bl' is open without any children. */ - m->flags |= MDOC_FREECOL; - return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); + mdoc->flags |= MDOC_FREECOL; + return(mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf)); } if (MDOC_It == n->tok && MDOC_BLOCK == n->type && @@ -748,8 +748,8 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) MDOC_Bl == n->parent->tok && LIST_column == n->parent->norm->Bl.type) { /* `Bl' has block-level `It' children. */ - m->flags |= MDOC_FREECOL; - return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); + mdoc->flags |= MDOC_FREECOL; + return(mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf)); } /* @@ -777,7 +777,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) * Strip trailing tabs in literal context only; * outside, they affect the next line. */ - if (MDOC_LITERAL & m->flags) + if (MDOC_LITERAL & mdoc->flags) continue; break; case '\\': @@ -794,28 +794,28 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) *end = '\0'; if (ws) - mdoc_pmsg(m, line, (int)(ws-buf), MANDOCERR_EOLNSPACE); + mdoc_pmsg(mdoc, line, (int)(ws-buf), MANDOCERR_EOLNSPACE); - if ('\0' == buf[offs] && ! (MDOC_LITERAL & m->flags)) { - mdoc_pmsg(m, line, (int)(c-buf), MANDOCERR_NOBLANKLN); + if ('\0' == buf[offs] && ! (MDOC_LITERAL & mdoc->flags)) { + mdoc_pmsg(mdoc, line, (int)(c-buf), MANDOCERR_NOBLANKLN); /* * Insert a `sp' in the case of a blank line. Technically, * blank lines aren't allowed, but enough manuals assume this * behaviour that we want to work around it. */ - if ( ! mdoc_elem_alloc(m, line, offs, MDOC_sp, NULL)) + if ( ! mdoc_elem_alloc(mdoc, line, offs, MDOC_sp, NULL)) return(0); - m->next = MDOC_NEXT_SIBLING; + mdoc->next = MDOC_NEXT_SIBLING; - return(mdoc_valid_post(m)); + return(mdoc_valid_post(mdoc)); } - if ( ! mdoc_word_alloc(m, line, offs, buf+offs)) + if ( ! mdoc_word_alloc(mdoc, line, offs, buf+offs)) return(0); - if (MDOC_LITERAL & m->flags) + if (MDOC_LITERAL & mdoc->flags) return(1); /* @@ -827,7 +827,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) assert(buf < end); if (mandoc_eos(buf+offs, (size_t)(end-buf-offs), 0)) - m->last->flags |= MDOC_EOS; + mdoc->last->flags |= MDOC_EOS; return(1); } @@ -838,7 +838,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) * character. */ static int -mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) +mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs) { enum mdoct tok; int i, sv; @@ -848,7 +848,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) /* Empty post-control lines are ignored. */ if ('"' == buf[offs]) { - mdoc_pmsg(m, ln, offs, MANDOCERR_BADCOMMENT); + mdoc_pmsg(mdoc, ln, offs, MANDOCERR_BADCOMMENT); return(1); } else if ('\0' == buf[offs]) return(1); @@ -870,7 +870,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) tok = (i > 1 || i < 4) ? mdoc_hash_find(mac) : MDOC_MAX; if (MDOC_MAX == tok) { - mandoc_vmsg(MANDOCERR_MACRO, m->parse, + mandoc_vmsg(MANDOCERR_MACRO, mdoc->parse, ln, sv, "%s", buf + sv - 1); return(1); } @@ -891,21 +891,21 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) */ if ('\0' == buf[offs] && ' ' == buf[offs - 1]) - mdoc_pmsg(m, ln, offs - 1, MANDOCERR_EOLNSPACE); + mdoc_pmsg(mdoc, ln, offs - 1, MANDOCERR_EOLNSPACE); /* * If an initial macro or a list invocation, divert directly * into macro processing. */ - if (NULL == m->last || MDOC_It == tok || MDOC_El == tok) { - if ( ! mdoc_macro(m, tok, ln, sv, &offs, buf)) + if (NULL == mdoc->last || MDOC_It == tok || MDOC_El == tok) { + if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf)) goto err; return(1); } - n = m->last; - assert(m->last); + n = mdoc->last; + assert(mdoc->last); /* * If the first macro of a `Bl -column', open an `It' block @@ -914,8 +914,8 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) if (MDOC_Bl == n->tok && MDOC_BODY == n->type && LIST_column == n->norm->Bl.type) { - m->flags |= MDOC_FREECOL; - if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) + mdoc->flags |= MDOC_FREECOL; + if ( ! mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf)) goto err; return(1); } @@ -930,22 +930,22 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) NULL != n->parent && MDOC_Bl == n->parent->tok && LIST_column == n->parent->norm->Bl.type) { - m->flags |= MDOC_FREECOL; - if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) + mdoc->flags |= MDOC_FREECOL; + if ( ! mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf)) goto err; return(1); } /* Normal processing of a macro. */ - if ( ! mdoc_macro(m, tok, ln, sv, &offs, buf)) + if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf)) goto err; return(1); err: /* Error out. */ - m->flags |= MDOC_HALT; + mdoc->flags |= MDOC_HALT; return(0); } diff --git a/usr.bin/mandoc/mdoc_argv.c b/usr.bin/mandoc/mdoc_argv.c index 11cba1fefd7..05448c7aa25 100644 --- a/usr.bin/mandoc/mdoc_argv.c +++ b/usr.bin/mandoc/mdoc_argv.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_argv.c,v 1.41 2012/11/16 18:40:39 schwarze Exp $ */ +/* $Id: mdoc_argv.c,v 1.42 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -271,7 +271,7 @@ static const struct mdocarg mdocargs[MDOC_MAX] = { * one mandatory value, an optional single value, or no value. */ enum margverr -mdoc_argv(struct mdoc *m, int line, enum mdoct tok, +mdoc_argv(struct mdoc *mdoc, int line, enum mdoct tok, struct mdoc_arg **v, int *pos, char *buf) { char *p, sv; @@ -338,11 +338,11 @@ mdoc_argv(struct mdoc *m, int line, enum mdoct tok, switch (argvflags[tmp.arg]) { case (ARGV_SINGLE): - if ( ! argv_single(m, line, &tmp, pos, buf)) + if ( ! argv_single(mdoc, line, &tmp, pos, buf)) return(ARGV_ERROR); break; case (ARGV_MULTI): - if ( ! argv_multi(m, line, &tmp, pos, buf)) + if ( ! argv_multi(mdoc, line, &tmp, pos, buf)) return(ARGV_ERROR); break; case (ARGV_NONE): @@ -403,14 +403,14 @@ argn_free(struct mdoc_arg *p, int iarg) } enum margserr -mdoc_zargs(struct mdoc *m, int line, int *pos, char *buf, char **v) +mdoc_zargs(struct mdoc *mdoc, int line, int *pos, char *buf, char **v) { - return(args(m, line, pos, buf, ARGSFL_NONE, v)); + return(args(mdoc, line, pos, buf, ARGSFL_NONE, v)); } enum margserr -mdoc_args(struct mdoc *m, int line, int *pos, +mdoc_args(struct mdoc *mdoc, int line, int *pos, char *buf, enum mdoct tok, char **v) { enum argsflag fl; @@ -419,7 +419,7 @@ mdoc_args(struct mdoc *m, int line, int *pos, fl = mdocargs[tok].flags; if (MDOC_It != tok) - return(args(m, line, pos, buf, fl, v)); + return(args(mdoc, line, pos, buf, fl, v)); /* * We know that we're in an `It', so it's reasonable to expect @@ -428,35 +428,35 @@ mdoc_args(struct mdoc *m, int line, int *pos, * safe fall-back into the default behaviour. */ - for (n = m->last; n; n = n->parent) + for (n = mdoc->last; n; n = n->parent) if (MDOC_Bl == n->tok) if (LIST_column == n->norm->Bl.type) { fl = ARGSFL_TABSEP; break; } - return(args(m, line, pos, buf, fl, v)); + return(args(mdoc, line, pos, buf, fl, v)); } static enum margserr -args(struct mdoc *m, int line, int *pos, +args(struct mdoc *mdoc, int line, int *pos, char *buf, enum argsflag fl, char **v) { char *p, *pp; enum margserr rc; if ('\0' == buf[*pos]) { - if (MDOC_PPHRASE & m->flags) + if (MDOC_PPHRASE & mdoc->flags) return(ARGS_EOLN); /* * If we're not in a partial phrase and the flag for * being a phrase literal is still set, the punctuation * is unterminated. */ - if (MDOC_PHRASELIT & m->flags) - mdoc_pmsg(m, line, *pos, MANDOCERR_BADQUOTE); + if (MDOC_PHRASELIT & mdoc->flags) + mdoc_pmsg(mdoc, line, *pos, MANDOCERR_BADQUOTE); - m->flags &= ~MDOC_PHRASELIT; + mdoc->flags &= ~MDOC_PHRASELIT; return(ARGS_EOLN); } @@ -479,7 +479,7 @@ args(struct mdoc *m, int line, int *pos, pp = NULL; /* Scan ahead to unescaped `Ta'. */ - if ( ! (MDOC_PHRASELIT & m->flags)) + if ( ! (MDOC_PHRASELIT & mdoc->flags)) for (pp = *v; ; pp++) { if (NULL == (pp = strstr(pp, "Ta"))) break; @@ -513,7 +513,7 @@ args(struct mdoc *m, int line, int *pos, /* Whitespace check for eoln case... */ if ('\0' == *p && ' ' == *(p - 1)) - mdoc_pmsg(m, line, *pos, MANDOCERR_EOLNSPACE); + mdoc_pmsg(mdoc, line, *pos, MANDOCERR_EOLNSPACE); *pos += (int)(p - *v); @@ -539,12 +539,12 @@ args(struct mdoc *m, int line, int *pos, * Whitespace is NOT involved in literal termination. */ - if (MDOC_PHRASELIT & m->flags || '\"' == buf[*pos]) { - if ( ! (MDOC_PHRASELIT & m->flags)) + if (MDOC_PHRASELIT & mdoc->flags || '\"' == buf[*pos]) { + if ( ! (MDOC_PHRASELIT & mdoc->flags)) *v = &buf[++(*pos)]; - if (MDOC_PPHRASE & m->flags) - m->flags |= MDOC_PHRASELIT; + if (MDOC_PPHRASE & mdoc->flags) + mdoc->flags |= MDOC_PHRASELIT; for ( ; buf[*pos]; (*pos)++) { if ('\"' != buf[*pos]) @@ -555,13 +555,13 @@ args(struct mdoc *m, int line, int *pos, } if ('\0' == buf[*pos]) { - if (MDOC_PPHRASE & m->flags) + if (MDOC_PPHRASE & mdoc->flags) return(ARGS_QWORD); - mdoc_pmsg(m, line, *pos, MANDOCERR_BADQUOTE); + mdoc_pmsg(mdoc, line, *pos, MANDOCERR_BADQUOTE); return(ARGS_QWORD); } - m->flags &= ~MDOC_PHRASELIT; + mdoc->flags &= ~MDOC_PHRASELIT; buf[(*pos)++] = '\0'; if ('\0' == buf[*pos]) @@ -571,13 +571,13 @@ args(struct mdoc *m, int line, int *pos, (*pos)++; if ('\0' == buf[*pos]) - mdoc_pmsg(m, line, *pos, MANDOCERR_EOLNSPACE); + mdoc_pmsg(mdoc, line, *pos, MANDOCERR_EOLNSPACE); return(ARGS_QWORD); } p = &buf[*pos]; - *v = mandoc_getarg(m->parse, &p, line, pos); + *v = mandoc_getarg(mdoc->parse, &p, line, pos); return(ARGS_WORD); } @@ -633,7 +633,7 @@ args_checkpunct(const char *buf, int i) } static int -argv_multi(struct mdoc *m, int line, +argv_multi(struct mdoc *mdoc, int line, struct mdoc_argv *v, int *pos, char *buf) { enum margserr ac; @@ -642,7 +642,7 @@ argv_multi(struct mdoc *m, int line, for (v->sz = 0; ; v->sz++) { if ('-' == buf[*pos]) break; - ac = args(m, line, pos, buf, ARGSFL_NONE, &p); + ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p); if (ARGS_ERROR == ac) return(0); else if (ARGS_EOLN == ac) @@ -659,13 +659,13 @@ argv_multi(struct mdoc *m, int line, } static int -argv_single(struct mdoc *m, int line, +argv_single(struct mdoc *mdoc, int line, struct mdoc_argv *v, int *pos, char *buf) { enum margserr ac; char *p; - ac = args(m, line, pos, buf, ARGSFL_NONE, &p); + ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p); if (ARGS_ERROR == ac) return(0); if (ARGS_EOLN == ac) diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index 137eacdf2a0..d1c544e177a 100644 --- a/usr.bin/mandoc/mdoc_html.c +++ b/usr.bin/mandoc/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.66 2012/08/12 06:04:09 matthew Exp $ */ +/* $Id: mdoc_html.c,v 1.67 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -31,7 +31,7 @@ #define INDENT 5 -#define MDOC_ARGS const struct mdoc_meta *m, \ +#define MDOC_ARGS const struct mdoc_meta *meta, \ const struct mdoc_node *n, \ struct html *h @@ -256,10 +256,11 @@ static const char * const lists[LIST_MAX] = { }; void -html_mdoc(void *arg, const struct mdoc *m) +html_mdoc(void *arg, const struct mdoc *mdoc) { - print_mdoc(mdoc_meta(m), mdoc_node(m), (struct html *)arg); + print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc), + (struct html *)arg); putchar('\n'); } @@ -357,14 +358,14 @@ print_mdoc(MDOC_ARGS) print_gen_decls(h); t = print_otag(h, TAG_HTML, 0, NULL); tt = print_otag(h, TAG_HEAD, 0, NULL); - print_mdoc_head(m, n, h); + print_mdoc_head(meta, n, h); print_tagq(h, tt); print_otag(h, TAG_BODY, 0, NULL); print_otag(h, TAG_DIV, 1, &tag); } else t = print_otag(h, TAG_DIV, 1, &tag); - print_mdoc_nodelist(m, n, h); + print_mdoc_nodelist(meta, n, h); print_tagq(h, t); } @@ -376,10 +377,10 @@ print_mdoc_head(MDOC_ARGS) print_gen_head(h); bufinit(h); - bufcat_fmt(h, "%s(%s)", m->title, m->msec); + bufcat_fmt(h, "%s(%s)", meta->title, meta->msec); - if (m->arch) - bufcat_fmt(h, " (%s)", m->arch); + if (meta->arch) + bufcat_fmt(h, " (%s)", meta->arch); print_otag(h, TAG_TITLE, 0, NULL); print_text(h, h->buf); @@ -390,9 +391,9 @@ static void print_mdoc_nodelist(MDOC_ARGS) { - print_mdoc_node(m, n, h); + print_mdoc_node(meta, n, h); if (n->next) - print_mdoc_nodelist(m, n->next, h); + print_mdoc_nodelist(meta, n->next, h); } @@ -407,7 +408,7 @@ print_mdoc_node(MDOC_ARGS) switch (n->type) { case (MDOC_ROOT): - child = mdoc_root_pre(m, n, h); + child = mdoc_root_pre(meta, n, h); break; case (MDOC_TEXT): /* No tables in this mode... */ @@ -450,7 +451,7 @@ print_mdoc_node(MDOC_ARGS) assert(NULL == h->tblt); if (mdocs[n->tok].pre && ENDBODY_NOT == n->end) - child = (*mdocs[n->tok].pre)(m, n, h); + child = (*mdocs[n->tok].pre)(meta, n, h); break; } @@ -467,19 +468,19 @@ print_mdoc_node(MDOC_ARGS) } if (child && n->child) - print_mdoc_nodelist(m, n->child, h); + print_mdoc_nodelist(meta, n->child, h); print_stagq(h, t); switch (n->type) { case (MDOC_ROOT): - mdoc_root_post(m, n, h); + mdoc_root_post(meta, n, h); break; case (MDOC_EQN): break; default: if (mdocs[n->tok].post && ENDBODY_NOT == n->end) - (*mdocs[n->tok].post)(m, n, h); + (*mdocs[n->tok].post)(meta, n, h); break; } } @@ -505,13 +506,13 @@ mdoc_root_post(MDOC_ARGS) PAIR_CLASS_INIT(&tag[0], "foot-date"); print_otag(h, TAG_TD, 1, tag); - print_text(h, m->date); + print_text(h, meta->date); print_stagq(h, tt); PAIR_CLASS_INIT(&tag[0], "foot-os"); PAIR_INIT(&tag[1], ATTR_ALIGN, "right"); print_otag(h, TAG_TD, 2, tag); - print_text(h, m->os); + print_text(h, meta->os); print_tagq(h, t); } @@ -524,15 +525,15 @@ mdoc_root_pre(MDOC_ARGS) struct tag *t, *tt; char b[BUFSIZ], title[BUFSIZ]; - strlcpy(b, m->vol, BUFSIZ); + strlcpy(b, meta->vol, BUFSIZ); - if (m->arch) { + if (meta->arch) { strlcat(b, " (", BUFSIZ); - strlcat(b, m->arch, BUFSIZ); + strlcat(b, meta->arch, BUFSIZ); strlcat(b, ")", BUFSIZ); } - snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec); + snprintf(title, BUFSIZ - 1, "%s(%s)", meta->title, meta->msec); PAIR_SUMMARY_INIT(&tag[0], "Document Header"); PAIR_CLASS_INIT(&tag[1], "head"); @@ -685,13 +686,13 @@ mdoc_nm_pre(MDOC_ARGS) synopsis_pre(h, n); PAIR_CLASS_INIT(&tag, "name"); print_otag(h, TAG_B, 1, &tag); - if (NULL == n->child && m->name) - print_text(h, m->name); + if (NULL == n->child && meta->name) + print_text(h, meta->name); return(1); case (MDOC_HEAD): print_otag(h, TAG_TD, 0, NULL); - if (NULL == n->child && m->name) - print_text(h, m->name); + if (NULL == n->child && meta->name) + print_text(h, meta->name); return(1); case (MDOC_BODY): print_otag(h, TAG_TD, 0, NULL); @@ -708,8 +709,8 @@ mdoc_nm_pre(MDOC_ARGS) if (MDOC_TEXT == n->type) len += html_strlen(n->string); - if (0 == len && m->name) - len = html_strlen(m->name); + if (0 == len && meta->name) + len = html_strlen(meta->name); SCALE_HS_INIT(&su, (double)len); bufinit(h); @@ -1221,7 +1222,7 @@ mdoc_bd_pre(MDOC_ARGS) h->flags |= HTML_LITERAL; for (nn = n->child; nn; nn = nn->next) { - print_mdoc_node(m, nn, h); + print_mdoc_node(meta, nn, h); /* * If the printed node flushes its own line, then we * needn't do it here as well. This is hacky, but the diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 18493ae5282..4600b4e499f 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.75 2012/11/16 13:25:34 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.76 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -199,22 +199,23 @@ const struct mdoc_macro * const mdoc_macros = __mdoc_macros; * are errors. */ int -mdoc_macroend(struct mdoc *m) +mdoc_macroend(struct mdoc *mdoc) { struct mdoc_node *n; /* Scan for open explicit scopes. */ - n = MDOC_VALID & m->last->flags ? m->last->parent : m->last; + n = MDOC_VALID & mdoc->last->flags ? + mdoc->last->parent : mdoc->last; for ( ; n; n = n->parent) if (MDOC_BLOCK == n->type && MDOC_EXPLICIT & mdoc_macros[n->tok].flags) - mdoc_nmsg(m, n, MANDOCERR_SCOPEEXIT); + mdoc_nmsg(mdoc, n, MANDOCERR_SCOPEEXIT); /* Rewind to the first. */ - return(rew_last(m, m->first)); + return(rew_last(mdoc, mdoc->first)); } @@ -259,8 +260,8 @@ rew_last(struct mdoc *mdoc, const struct mdoc_node *to) while (mdoc->last != to) { /* * Save the parent here, because we may delete the - * m->last node in the post-validation phase and reset - * it to m->last->parent, causing a step in the closing + * mdoc->last node in the post-validation phase and reset + * it to mdoc->last->parent, causing a step in the closing * out to be lost. */ np = mdoc->last->parent; @@ -456,7 +457,7 @@ rew_elem(struct mdoc *mdoc, enum mdoct tok) */ static int make_pending(struct mdoc_node *broken, enum mdoct tok, - struct mdoc *m, int line, int ppos) + struct mdoc *mdoc, int line, int ppos) { struct mdoc_node *breaker; @@ -511,7 +512,7 @@ make_pending(struct mdoc_node *broken, enum mdoct tok, taker->pending = broken->pending; } broken->pending = breaker; - mandoc_vmsg(MANDOCERR_SCOPENEST, m->parse, line, ppos, + mandoc_vmsg(MANDOCERR_SCOPENEST, mdoc->parse, line, ppos, "%s breaks %s", mdoc_macronames[tok], mdoc_macronames[broken->tok]); return(1); @@ -526,12 +527,12 @@ make_pending(struct mdoc_node *broken, enum mdoct tok, static int -rew_sub(enum mdoc_type t, struct mdoc *m, +rew_sub(enum mdoc_type t, struct mdoc *mdoc, enum mdoct tok, int line, int ppos) { struct mdoc_node *n; - n = m->last; + n = mdoc->last; while (n) { switch (rew_dohalt(tok, t, n)) { case (REWIND_NONE): @@ -539,7 +540,7 @@ rew_sub(enum mdoc_type t, struct mdoc *m, case (REWIND_THIS): break; case (REWIND_FORCE): - mandoc_vmsg(MANDOCERR_SCOPEBROKEN, m->parse, + mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse, line, ppos, "%s breaks %s", mdoc_macronames[tok], mdoc_macronames[n->tok]); @@ -548,19 +549,19 @@ rew_sub(enum mdoc_type t, struct mdoc *m, n = n->parent; continue; case (REWIND_LATER): - if (make_pending(n, tok, m, line, ppos) || + if (make_pending(n, tok, mdoc, line, ppos) || MDOC_BLOCK != t) return(1); /* FALLTHROUGH */ case (REWIND_ERROR): - mdoc_pmsg(m, line, ppos, MANDOCERR_NOSCOPE); + mdoc_pmsg(mdoc, line, ppos, MANDOCERR_NOSCOPE); return(1); } break; } assert(n); - if ( ! rew_last(m, n)) + if ( ! rew_last(mdoc, n)) return(0); /* @@ -568,10 +569,10 @@ rew_sub(enum mdoc_type t, struct mdoc *m, * Now that the current block ends, close the enclosing block, too. */ while (NULL != (n = n->pending)) { - if ( ! rew_last(m, n)) + if ( ! rew_last(mdoc, n)) return(0); if (MDOC_HEAD == n->type && - ! mdoc_body_alloc(m, n->line, n->pos, n->tok)) + ! mdoc_body_alloc(mdoc, n->line, n->pos, n->tok)) return(0); } @@ -583,18 +584,18 @@ rew_sub(enum mdoc_type t, struct mdoc *m, * Punctuation consists of those tokens found in mdoc_isdelim(). */ static int -dword(struct mdoc *m, int line, +dword(struct mdoc *mdoc, int line, int col, const char *p, enum mdelim d) { if (DELIM_MAX == d) d = mdoc_isdelim(p); - if ( ! mdoc_word_alloc(m, line, col, p)) + if ( ! mdoc_word_alloc(mdoc, line, col, p)) return(0); if (DELIM_OPEN == d) - m->last->flags |= MDOC_DELIMO; + mdoc->last->flags |= MDOC_DELIMO; /* * Closing delimiters only suppress the preceding space @@ -606,15 +607,15 @@ dword(struct mdoc *m, int line, * and solve this in the code related to `No'! */ - else if (DELIM_CLOSE == d && m->last->prev && - m->last->prev->tok != MDOC_No) - m->last->flags |= MDOC_DELIMC; + else if (DELIM_CLOSE == d && mdoc->last->prev && + mdoc->last->prev->tok != MDOC_No) + mdoc->last->flags |= MDOC_DELIMC; return(1); } static int -append_delims(struct mdoc *m, int line, int *pos, char *buf) +append_delims(struct mdoc *mdoc, int line, int *pos, char *buf) { int la; enum margserr ac; @@ -625,14 +626,14 @@ append_delims(struct mdoc *m, int line, int *pos, char *buf) for (;;) { la = *pos; - ac = mdoc_zargs(m, line, pos, buf, &p); + ac = mdoc_zargs(mdoc, line, pos, buf, &p); if (ARGS_ERROR == ac) return(0); else if (ARGS_EOLN == ac) break; - dword(m, line, la, p, DELIM_MAX); + dword(mdoc, line, la, p, DELIM_MAX); /* * If we encounter end-of-sentence symbols, then trigger @@ -646,7 +647,7 @@ append_delims(struct mdoc *m, int line, int *pos, char *buf) * example, `. ;' shouldn't propagate the double-space. */ if (mandoc_eos(p, strlen(p), 0)) - m->last->flags |= MDOC_EOS; + mdoc->last->flags |= MDOC_EOS; } return(1); @@ -668,7 +669,7 @@ blk_exp_close(MACRO_PROT_ARGS) enum mdoct atok, ntok; char *p; - nl = MDOC_NEWLINE & m->flags; + nl = MDOC_NEWLINE & mdoc->flags; switch (tok) { case (MDOC_Ec): @@ -685,7 +686,7 @@ blk_exp_close(MACRO_PROT_ARGS) */ atok = rew_alt(tok); body = later = NULL; - for (n = m->last; n; n = n->parent) { + for (n = mdoc->last; n; n = n->parent) { if (MDOC_VALID & n->flags) continue; @@ -714,13 +715,13 @@ blk_exp_close(MACRO_PROT_ARGS) * postpone closing out the current block * until the rew_sub() closing out the sub-block. */ - make_pending(later, tok, m, line, ppos); + make_pending(later, tok, mdoc, line, ppos); /* * Mark the place where the formatting - but not * the scope - of the current block ends. */ - if ( ! mdoc_endbody_alloc(m, line, ppos, + if ( ! mdoc_endbody_alloc(mdoc, line, ppos, atok, body, ENDBODY_SPACE)) return(0); break; @@ -741,30 +742,30 @@ blk_exp_close(MACRO_PROT_ARGS) if ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags)) { /* FIXME: do this in validate */ if (buf[*pos]) - mdoc_pmsg(m, line, ppos, MANDOCERR_ARGSLOST); + mdoc_pmsg(mdoc, line, ppos, MANDOCERR_ARGSLOST); - if ( ! rew_sub(MDOC_BODY, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos)) return(0); - return(rew_sub(MDOC_BLOCK, m, tok, line, ppos)); + return(rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)); } - if ( ! rew_sub(MDOC_BODY, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos)) return(0); if (NULL == later && maxargs > 0) - if ( ! mdoc_tail_alloc(m, line, ppos, rew_alt(tok))) + if ( ! mdoc_tail_alloc(mdoc, line, ppos, rew_alt(tok))) return(0); for (flushed = j = 0; ; j++) { lastarg = *pos; if (j == maxargs && ! flushed) { - if ( ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)) return(0); flushed = 1; } - ac = mdoc_args(m, line, pos, buf, tok, &p); + ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ARGS_ERROR == ac) return(0); @@ -776,27 +777,27 @@ blk_exp_close(MACRO_PROT_ARGS) ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); if (MDOC_MAX == ntok) { - if ( ! dword(m, line, lastarg, p, DELIM_MAX)) + if ( ! dword(mdoc, line, lastarg, p, DELIM_MAX)) return(0); continue; } if ( ! flushed) { - if ( ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)) return(0); flushed = 1; } - if ( ! mdoc_macro(m, ntok, line, lastarg, pos, buf)) + if ( ! mdoc_macro(mdoc, ntok, line, lastarg, pos, buf)) return(0); break; } - if ( ! flushed && ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) + if ( ! flushed && ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)) return(0); if ( ! nl) return(1); - return(append_delims(m, line, pos, buf)); + return(append_delims(mdoc, line, pos, buf)); } @@ -811,7 +812,7 @@ in_line(MACRO_PROT_ARGS) struct mdoc_arg *arg; char *p; - nl = MDOC_NEWLINE & m->flags; + nl = MDOC_NEWLINE & mdoc->flags; /* * Whether we allow ignored elements (those without content, @@ -839,7 +840,7 @@ in_line(MACRO_PROT_ARGS) for (arg = NULL;; ) { la = *pos; - av = mdoc_argv(m, line, tok, &arg, pos, buf); + av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); if (ARGV_WORD == av) { *pos = la; @@ -856,7 +857,7 @@ in_line(MACRO_PROT_ARGS) for (cnt = scope = 0;; ) { la = *pos; - ac = mdoc_args(m, line, pos, buf, tok, &p); + ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ARGS_ERROR == ac) return(0); @@ -875,23 +876,25 @@ in_line(MACRO_PROT_ARGS) */ if (MDOC_MAX != ntok) { - if (scope && ! rew_elem(m, tok)) + if (scope && ! rew_elem(mdoc, tok)) return(0); if (nc && 0 == cnt) { - if ( ! mdoc_elem_alloc(m, line, ppos, tok, arg)) + if ( ! mdoc_elem_alloc(mdoc, line, + ppos, tok, arg)) return(0); - if ( ! rew_last(m, m->last)) + if ( ! rew_last(mdoc, mdoc->last)) return(0); } else if ( ! nc && 0 == cnt) { mdoc_argv_free(arg); - mdoc_pmsg(m, line, ppos, MANDOCERR_MACROEMPTY); + mdoc_pmsg(mdoc, line, ppos, + MANDOCERR_MACROEMPTY); } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) return(0); if ( ! nl) return(1); - return(append_delims(m, line, pos, buf)); + return(append_delims(mdoc, line, pos, buf)); } /* @@ -913,7 +916,8 @@ in_line(MACRO_PROT_ARGS) */ if (0 == cnt && (nc || MDOC_Li == tok) && DELIM_CLOSE == d && ! scope) { - if ( ! mdoc_elem_alloc(m, line, ppos, tok, arg)) + if ( ! mdoc_elem_alloc(mdoc, line, + ppos, tok, arg)) return(0); if (MDOC_Ar == tok || MDOC_Li == tok || MDOC_Fl == tok) @@ -924,11 +928,11 @@ in_line(MACRO_PROT_ARGS) * Close out our scope, if one is open, before * any punctuation. */ - if (scope && ! rew_elem(m, tok)) + if (scope && ! rew_elem(mdoc, tok)) return(0); scope = 0; } else if ( ! scope) { - if ( ! mdoc_elem_alloc(m, line, ppos, tok, arg)) + if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg)) return(0); scope = 1; } @@ -936,7 +940,7 @@ in_line(MACRO_PROT_ARGS) if (DELIM_NONE == d) cnt++; - if ( ! dword(m, line, la, p, d)) + if ( ! dword(mdoc, line, la, p, d)) return(0); /* @@ -945,13 +949,13 @@ in_line(MACRO_PROT_ARGS) * having to parse out spaces. */ if (scope && MDOC_Fl == tok) { - if ( ! rew_elem(m, tok)) + if ( ! rew_elem(mdoc, tok)) return(0); scope = 0; } } - if (scope && ! rew_elem(m, tok)) + if (scope && ! rew_elem(mdoc, tok)) return(0); /* @@ -961,18 +965,18 @@ in_line(MACRO_PROT_ARGS) */ if (nc && 0 == cnt) { - if ( ! mdoc_elem_alloc(m, line, ppos, tok, arg)) + if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg)) return(0); - if ( ! rew_last(m, m->last)) + if ( ! rew_last(mdoc, mdoc->last)) return(0); } else if ( ! nc && 0 == cnt) { mdoc_argv_free(arg); - mdoc_pmsg(m, line, ppos, MANDOCERR_MACROEMPTY); + mdoc_pmsg(mdoc, line, ppos, MANDOCERR_MACROEMPTY); } if ( ! nl) return(1); - return(append_delims(m, line, pos, buf)); + return(append_delims(mdoc, line, pos, buf)); } @@ -990,14 +994,14 @@ blk_full(MACRO_PROT_ARGS) enum margverr av; char *p; - nl = MDOC_NEWLINE & m->flags; + nl = MDOC_NEWLINE & mdoc->flags; /* Close out prior implicit scope. */ if ( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)) { - if ( ! rew_sub(MDOC_BODY, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos)) return(0); - if ( ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)) return(0); } @@ -1012,7 +1016,7 @@ blk_full(MACRO_PROT_ARGS) for (arg = NULL;; ) { la = *pos; - av = mdoc_argv(m, line, tok, &arg, pos, buf); + av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); if (ARGV_WORD == av) { *pos = la; @@ -1028,7 +1032,7 @@ blk_full(MACRO_PROT_ARGS) return(0); } - if ( ! mdoc_block_alloc(m, line, ppos, tok, arg)) + if ( ! mdoc_block_alloc(mdoc, line, ppos, tok, arg)) return(0); head = body = NULL; @@ -1038,8 +1042,8 @@ blk_full(MACRO_PROT_ARGS) * parsed, even though `It' macros in general are parsed. */ nparsed = MDOC_It == tok && - MDOC_Bl == m->last->parent->tok && - LIST_diag == m->last->parent->norm->Bl.type; + MDOC_Bl == mdoc->last->parent->tok && + LIST_diag == mdoc->last->parent->norm->Bl.type; /* * The `Nd' macro has all arguments in its body: it's a hybrid @@ -1047,14 +1051,14 @@ blk_full(MACRO_PROT_ARGS) */ if (MDOC_Nd == tok) { - if ( ! mdoc_head_alloc(m, line, ppos, tok)) + if ( ! mdoc_head_alloc(mdoc, line, ppos, tok)) return(0); - head = m->last; - if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) + head = mdoc->last; + if ( ! rew_sub(MDOC_HEAD, mdoc, tok, line, ppos)) return(0); - if ( ! mdoc_body_alloc(m, line, ppos, tok)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) return(0); - body = m->last; + body = mdoc->last; } ac = ARGS_ERROR; @@ -1063,7 +1067,7 @@ blk_full(MACRO_PROT_ARGS) la = *pos; /* Initialise last-phrase-type with ARGS_PEND. */ lac = ARGS_ERROR == ac ? ARGS_PEND : ac; - ac = mdoc_args(m, line, pos, buf, tok, &p); + ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ARGS_PUNCT == ac) break; @@ -1081,11 +1085,11 @@ blk_full(MACRO_PROT_ARGS) * reopen our scope if the last parse was a * phrase or partial phrase. */ - if ( ! rew_sub(MDOC_BODY, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos)) return(0); - if ( ! mdoc_body_alloc(m, line, ppos, tok)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) return(0); - body = m->last; + body = mdoc->last; break; } @@ -1100,7 +1104,7 @@ blk_full(MACRO_PROT_ARGS) ARGS_PPHRASE != ac && ARGS_QWORD != ac && DELIM_OPEN == mdoc_isdelim(p)) { - if ( ! dword(m, line, la, p, DELIM_OPEN)) + if ( ! dword(mdoc, line, la, p, DELIM_OPEN)) return(0); continue; } @@ -1108,9 +1112,9 @@ blk_full(MACRO_PROT_ARGS) /* Open a head if one hasn't been opened. */ if (NULL == head) { - if ( ! mdoc_head_alloc(m, line, ppos, tok)) + if ( ! mdoc_head_alloc(mdoc, line, ppos, tok)) return(0); - head = m->last; + head = mdoc->last; } if (ARGS_PHRASE == ac || @@ -1122,14 +1126,14 @@ blk_full(MACRO_PROT_ARGS) */ mtt = body ? MDOC_BODY : MDOC_HEAD; - if ( ! rew_sub(mtt, m, tok, line, ppos)) + if ( ! rew_sub(mtt, mdoc, tok, line, ppos)) return(0); /* Then allocate our body context. */ - if ( ! mdoc_body_alloc(m, line, ppos, tok)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) return(0); - body = m->last; + body = mdoc->last; /* * Process phrases: set whether we're in a @@ -1138,14 +1142,14 @@ blk_full(MACRO_PROT_ARGS) */ if (ARGS_PPHRASE == ac) - m->flags |= MDOC_PPHRASE; + mdoc->flags |= MDOC_PPHRASE; if (ARGS_PEND == ac && ARGS_PPHRASE == lac) - m->flags |= MDOC_PPHRASE; + mdoc->flags |= MDOC_PPHRASE; - if ( ! phrase(m, line, la, buf)) + if ( ! phrase(mdoc, line, la, buf)) return(0); - m->flags &= ~MDOC_PPHRASE; + mdoc->flags &= ~MDOC_PPHRASE; continue; } @@ -1153,23 +1157,23 @@ blk_full(MACRO_PROT_ARGS) MDOC_MAX : lookup(tok, p); if (MDOC_MAX == ntok) { - if ( ! dword(m, line, la, p, DELIM_MAX)) + if ( ! dword(mdoc, line, la, p, DELIM_MAX)) return(0); continue; } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) return(0); break; } if (NULL == head) { - if ( ! mdoc_head_alloc(m, line, ppos, tok)) + if ( ! mdoc_head_alloc(mdoc, line, ppos, tok)) return(0); - head = m->last; + head = mdoc->last; } - if (nl && ! append_delims(m, line, pos, buf)) + if (nl && ! append_delims(mdoc, line, pos, buf)) return(0); /* If we've already opened our body, exit now. */ @@ -1183,7 +1187,7 @@ blk_full(MACRO_PROT_ARGS) * head to body until the rew_sub() call closing out that * sub-block. */ - for (n = m->last; n && n != head; n = n->parent) { + for (n = mdoc->last; n && n != head; n = n->parent) { if (MDOC_BLOCK == n->type && MDOC_EXPLICIT & mdoc_macros[n->tok].flags && ! (MDOC_VALID & n->flags)) { @@ -1194,21 +1198,21 @@ blk_full(MACRO_PROT_ARGS) /* Close out scopes to remain in a consistent state. */ - if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_HEAD, mdoc, tok, line, ppos)) return(0); - if ( ! mdoc_body_alloc(m, line, ppos, tok)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) return(0); out: - if ( ! (MDOC_FREECOL & m->flags)) + if ( ! (MDOC_FREECOL & mdoc->flags)) return(1); - if ( ! rew_sub(MDOC_BODY, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos)) return(0); - if ( ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)) return(0); - m->flags &= ~MDOC_FREECOL; + mdoc->flags &= ~MDOC_FREECOL; return(1); } @@ -1224,7 +1228,7 @@ blk_part_imp(MACRO_PROT_ARGS) struct mdoc_node *body; /* saved body context */ struct mdoc_node *n; - nl = MDOC_NEWLINE & m->flags; + nl = MDOC_NEWLINE & mdoc->flags; /* * A macro that spans to the end of the line. This is generally @@ -1235,14 +1239,14 @@ blk_part_imp(MACRO_PROT_ARGS) * or more closing punctuation nodes. */ - if ( ! mdoc_block_alloc(m, line, ppos, tok, NULL)) + if ( ! mdoc_block_alloc(mdoc, line, ppos, tok, NULL)) return(0); - blk = m->last; + blk = mdoc->last; - if ( ! mdoc_head_alloc(m, line, ppos, tok)) + if ( ! mdoc_head_alloc(mdoc, line, ppos, tok)) return(0); - if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_HEAD, mdoc, tok, line, ppos)) return(0); /* @@ -1253,7 +1257,7 @@ blk_part_imp(MACRO_PROT_ARGS) for (body = NULL; ; ) { la = *pos; - ac = mdoc_args(m, line, pos, buf, tok, &p); + ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ARGS_ERROR == ac) return(0); @@ -1264,26 +1268,26 @@ blk_part_imp(MACRO_PROT_ARGS) if (NULL == body && ARGS_QWORD != ac && DELIM_OPEN == mdoc_isdelim(p)) { - if ( ! dword(m, line, la, p, DELIM_OPEN)) + if ( ! dword(mdoc, line, la, p, DELIM_OPEN)) return(0); continue; } if (NULL == body) { - if ( ! mdoc_body_alloc(m, line, ppos, tok)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) return(0); - body = m->last; + body = mdoc->last; } ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); if (MDOC_MAX == ntok) { - if ( ! dword(m, line, la, p, DELIM_MAX)) + if ( ! dword(mdoc, line, la, p, DELIM_MAX)) return(0); continue; } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) return(0); break; } @@ -1291,9 +1295,9 @@ blk_part_imp(MACRO_PROT_ARGS) /* Clean-ups to leave in a consistent state. */ if (NULL == body) { - if ( ! mdoc_body_alloc(m, line, ppos, tok)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) return(0); - body = m->last; + body = mdoc->last; } for (n = body->child; n && n->next; n = n->next) @@ -1320,12 +1324,13 @@ blk_part_imp(MACRO_PROT_ARGS) * postpone closing out the current block * until the rew_sub() call closing out the sub-block. */ - for (n = m->last; n && n != body && n != blk->parent; n = n->parent) { + for (n = mdoc->last; n && n != body && n != blk->parent; + n = n->parent) { if (MDOC_BLOCK == n->type && MDOC_EXPLICIT & mdoc_macros[n->tok].flags && ! (MDOC_VALID & n->flags)) { - make_pending(n, tok, m, line, ppos); - if ( ! mdoc_endbody_alloc(m, line, ppos, + make_pending(n, tok, mdoc, line, ppos); + if ( ! mdoc_endbody_alloc(mdoc, line, ppos, tok, body, ENDBODY_NOSPACE)) return(0); return(1); @@ -1339,20 +1344,20 @@ blk_part_imp(MACRO_PROT_ARGS) * crufty use of `Op' breakage. */ if (n != body) - mandoc_vmsg(MANDOCERR_SCOPENEST, m->parse, line, ppos, + mandoc_vmsg(MANDOCERR_SCOPENEST, mdoc->parse, line, ppos, "%s broken", mdoc_macronames[tok]); - if (n && ! rew_sub(MDOC_BODY, m, tok, line, ppos)) + if (n && ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos)) return(0); /* Standard appending of delimiters. */ - if (nl && ! append_delims(m, line, pos, buf)) + if (nl && ! append_delims(mdoc, line, pos, buf)) return(0); /* Rewind scope, if applicable. */ - if (n && ! rew_sub(MDOC_BLOCK, m, tok, line, ppos)) + if (n && ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)) return(0); /* Move trailing .Ns out of scope. */ @@ -1360,7 +1365,7 @@ blk_part_imp(MACRO_PROT_ARGS) for (n = body->child; n && n->next; n = n->next) /* Do nothing. */ ; if (n && MDOC_Ns == n->tok) - mdoc_node_relink(m, n); + mdoc_node_relink(mdoc, n); return(1); } @@ -1376,7 +1381,7 @@ blk_part_exp(MACRO_PROT_ARGS) char *p; enum mdoct ntok; - nl = MDOC_NEWLINE & m->flags; + nl = MDOC_NEWLINE & mdoc->flags; /* * The opening of an explicit macro having zero or more leading @@ -1384,12 +1389,12 @@ blk_part_exp(MACRO_PROT_ARGS) * case of `Eo'); and a body that may be empty. */ - if ( ! mdoc_block_alloc(m, line, ppos, tok, NULL)) + if ( ! mdoc_block_alloc(mdoc, line, ppos, tok, NULL)) return(0); for (head = body = NULL; ; ) { la = *pos; - ac = mdoc_args(m, line, pos, buf, tok, &p); + ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ARGS_ERROR == ac) return(0); @@ -1403,16 +1408,16 @@ blk_part_exp(MACRO_PROT_ARGS) if (NULL == head && ARGS_QWORD != ac && DELIM_OPEN == mdoc_isdelim(p)) { assert(NULL == body); - if ( ! dword(m, line, la, p, DELIM_OPEN)) + if ( ! dword(mdoc, line, la, p, DELIM_OPEN)) return(0); continue; } if (NULL == head) { assert(NULL == body); - if ( ! mdoc_head_alloc(m, line, ppos, tok)) + if ( ! mdoc_head_alloc(mdoc, line, ppos, tok)) return(0); - head = m->last; + head = mdoc->last; } /* @@ -1424,14 +1429,14 @@ blk_part_exp(MACRO_PROT_ARGS) assert(head); /* No check whether it's a macro! */ if (MDOC_Eo == tok) - if ( ! dword(m, line, la, p, DELIM_MAX)) + if ( ! dword(mdoc, line, la, p, DELIM_MAX)) return(0); - if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_HEAD, mdoc, tok, line, ppos)) return(0); - if ( ! mdoc_body_alloc(m, line, ppos, tok)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) return(0); - body = m->last; + body = mdoc->last; if (MDOC_Eo == tok) continue; @@ -1442,12 +1447,12 @@ blk_part_exp(MACRO_PROT_ARGS) ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); if (MDOC_MAX == ntok) { - if ( ! dword(m, line, la, p, DELIM_MAX)) + if ( ! dword(mdoc, line, la, p, DELIM_MAX)) return(0); continue; } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) return(0); break; } @@ -1455,13 +1460,13 @@ blk_part_exp(MACRO_PROT_ARGS) /* Clean-up to leave in a consistent state. */ if (NULL == head) - if ( ! mdoc_head_alloc(m, line, ppos, tok)) + if ( ! mdoc_head_alloc(mdoc, line, ppos, tok)) return(0); if (NULL == body) { - if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) + if ( ! rew_sub(MDOC_HEAD, mdoc, tok, line, ppos)) return(0); - if ( ! mdoc_body_alloc(m, line, ppos, tok)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) return(0); } @@ -1469,7 +1474,7 @@ blk_part_exp(MACRO_PROT_ARGS) if ( ! nl) return(1); - return(append_delims(m, line, pos, buf)); + return(append_delims(mdoc, line, pos, buf)); } @@ -1484,7 +1489,7 @@ in_line_argn(MACRO_PROT_ARGS) char *p; enum mdoct ntok; - nl = MDOC_NEWLINE & m->flags; + nl = MDOC_NEWLINE & mdoc->flags; /* * A line macro that has a fixed number of arguments (maxargs). @@ -1516,7 +1521,7 @@ in_line_argn(MACRO_PROT_ARGS) for (arg = NULL; ; ) { la = *pos; - av = mdoc_argv(m, line, tok, &arg, pos, buf); + av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); if (ARGV_WORD == av) { *pos = la; @@ -1534,7 +1539,7 @@ in_line_argn(MACRO_PROT_ARGS) for (flushed = j = 0; ; ) { la = *pos; - ac = mdoc_args(m, line, pos, buf, tok, &p); + ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ARGS_ERROR == ac) return(0); @@ -1546,15 +1551,15 @@ in_line_argn(MACRO_PROT_ARGS) if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && ARGS_QWORD != ac && 0 == j && DELIM_OPEN == mdoc_isdelim(p)) { - if ( ! dword(m, line, la, p, DELIM_OPEN)) + if ( ! dword(mdoc, line, la, p, DELIM_OPEN)) return(0); continue; } else if (0 == j) - if ( ! mdoc_elem_alloc(m, line, la, tok, arg)) + if ( ! mdoc_elem_alloc(mdoc, line, la, tok, arg)) return(0); if (j == maxargs && ! flushed) { - if ( ! rew_elem(m, tok)) + if ( ! rew_elem(mdoc, tok)) return(0); flushed = 1; } @@ -1562,10 +1567,10 @@ in_line_argn(MACRO_PROT_ARGS) ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); if (MDOC_MAX != ntok) { - if ( ! flushed && ! rew_elem(m, tok)) + if ( ! flushed && ! rew_elem(mdoc, tok)) return(0); flushed = 1; - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) return(0); j++; break; @@ -1575,26 +1580,26 @@ in_line_argn(MACRO_PROT_ARGS) ARGS_QWORD != ac && ! flushed && DELIM_NONE != mdoc_isdelim(p)) { - if ( ! rew_elem(m, tok)) + if ( ! rew_elem(mdoc, tok)) return(0); flushed = 1; } - if ( ! dword(m, line, la, p, DELIM_MAX)) + if ( ! dword(mdoc, line, la, p, DELIM_MAX)) return(0); j++; } - if (0 == j && ! mdoc_elem_alloc(m, line, la, tok, arg)) + if (0 == j && ! mdoc_elem_alloc(mdoc, line, la, tok, arg)) return(0); /* Close out in a consistent state. */ - if ( ! flushed && ! rew_elem(m, tok)) + if ( ! flushed && ! rew_elem(mdoc, tok)) return(0); if ( ! nl) return(1); - return(append_delims(m, line, pos, buf)); + return(append_delims(mdoc, line, pos, buf)); } @@ -1611,13 +1616,13 @@ in_line_eoln(MACRO_PROT_ARGS) assert( ! (MDOC_PARSED & mdoc_macros[tok].flags)); if (tok == MDOC_Pp) - rew_sub(MDOC_BLOCK, m, MDOC_Nm, line, ppos); + rew_sub(MDOC_BLOCK, mdoc, MDOC_Nm, line, ppos); /* Parse macro arguments. */ for (arg = NULL; ; ) { la = *pos; - av = mdoc_argv(m, line, tok, &arg, pos, buf); + av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); if (ARGV_WORD == av) { *pos = la; @@ -1634,14 +1639,14 @@ in_line_eoln(MACRO_PROT_ARGS) /* Open element scope. */ - if ( ! mdoc_elem_alloc(m, line, ppos, tok, arg)) + if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg)) return(0); /* Parse argument terms. */ for (;;) { la = *pos; - ac = mdoc_args(m, line, pos, buf, tok, &p); + ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ARGS_ERROR == ac) return(0); @@ -1651,19 +1656,19 @@ in_line_eoln(MACRO_PROT_ARGS) ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); if (MDOC_MAX == ntok) { - if ( ! dword(m, line, la, p, DELIM_MAX)) + if ( ! dword(mdoc, line, la, p, DELIM_MAX)) return(0); continue; } - if ( ! rew_elem(m, tok)) + if ( ! rew_elem(mdoc, tok)) return(0); - return(mdoc_macro(m, ntok, line, la, pos, buf)); + return(mdoc_macro(mdoc, ntok, line, la, pos, buf)); } /* Close out (no delimiters). */ - return(rew_elem(m, tok)); + return(rew_elem(mdoc, tok)); } @@ -1673,15 +1678,15 @@ ctx_synopsis(MACRO_PROT_ARGS) { int nl; - nl = MDOC_NEWLINE & m->flags; + nl = MDOC_NEWLINE & mdoc->flags; /* If we're not in the SYNOPSIS, go straight to in-line. */ - if ( ! (MDOC_SYNOPSIS & m->flags)) - return(in_line(m, tok, line, ppos, pos, buf)); + if ( ! (MDOC_SYNOPSIS & mdoc->flags)) + return(in_line(mdoc, tok, line, ppos, pos, buf)); /* If we're a nested call, same place. */ if ( ! nl) - return(in_line(m, tok, line, ppos, pos, buf)); + return(in_line(mdoc, tok, line, ppos, pos, buf)); /* * XXX: this will open a block scope; however, if later we end @@ -1689,9 +1694,9 @@ ctx_synopsis(MACRO_PROT_ARGS) * the formatting. Be careful. */ if (MDOC_Nm == tok) - return(blk_full(m, tok, line, ppos, pos, buf)); + return(blk_full(mdoc, tok, line, ppos, pos, buf)); assert(MDOC_Vt == tok); - return(blk_part_imp(m, tok, line, ppos, pos, buf)); + return(blk_part_imp(mdoc, tok, line, ppos, pos, buf)); } @@ -1700,7 +1705,7 @@ static int obsolete(MACRO_PROT_ARGS) { - mdoc_pmsg(m, line, ppos, MANDOCERR_MACROOBS); + mdoc_pmsg(mdoc, line, ppos, MANDOCERR_MACROOBS); return(1); } @@ -1711,7 +1716,7 @@ obsolete(MACRO_PROT_ARGS) * macro is encountered. */ static int -phrase(struct mdoc *m, int line, int ppos, char *buf) +phrase(struct mdoc *mdoc, int line, int ppos, char *buf) { int la, pos; enum margserr ac; @@ -1721,7 +1726,7 @@ phrase(struct mdoc *m, int line, int ppos, char *buf) for (pos = ppos; ; ) { la = pos; - ac = mdoc_zargs(m, line, &pos, buf, &p); + ac = mdoc_zargs(mdoc, line, &pos, buf, &p); if (ARGS_ERROR == ac) return(0); @@ -1731,14 +1736,14 @@ phrase(struct mdoc *m, int line, int ppos, char *buf) ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); if (MDOC_MAX == ntok) { - if ( ! dword(m, line, la, p, DELIM_MAX)) + if ( ! dword(mdoc, line, la, p, DELIM_MAX)) return(0); continue; } - if ( ! mdoc_macro(m, ntok, line, la, &pos, buf)) + if ( ! mdoc_macro(mdoc, ntok, line, la, &pos, buf)) return(0); - return(append_delims(m, line, &pos, buf)); + return(append_delims(mdoc, line, &pos, buf)); } return(1); @@ -1759,14 +1764,14 @@ phrase_ta(MACRO_PROT_ARGS) * it should simply error out with ARGSLOST. */ - if ( ! rew_sub(MDOC_BODY, m, MDOC_It, line, ppos)) + if ( ! rew_sub(MDOC_BODY, mdoc, MDOC_It, line, ppos)) return(0); - if ( ! mdoc_body_alloc(m, line, ppos, MDOC_It)) + if ( ! mdoc_body_alloc(mdoc, line, ppos, MDOC_It)) return(0); for (;;) { la = *pos; - ac = mdoc_zargs(m, line, pos, buf, &p); + ac = mdoc_zargs(mdoc, line, pos, buf, &p); if (ARGS_ERROR == ac) return(0); @@ -1776,14 +1781,14 @@ phrase_ta(MACRO_PROT_ARGS) ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); if (MDOC_MAX == ntok) { - if ( ! dword(m, line, la, p, DELIM_MAX)) + if ( ! dword(mdoc, line, la, p, DELIM_MAX)) return(0); continue; } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) return(0); - return(append_delims(m, line, pos, buf)); + return(append_delims(mdoc, line, pos, buf)); } return(1); diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c index 4e9bef5d9f8..7716852c6ed 100644 --- a/usr.bin/mandoc/mdoc_man.c +++ b/usr.bin/mandoc/mdoc_man.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.41 2012/07/29 16:31:44 millert Exp $ */ +/* $Id: mdoc_man.c,v 1.42 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org> * @@ -24,7 +24,7 @@ #include "mdoc.h" #include "main.h" -#define DECL_ARGS const struct mdoc_meta *m, \ +#define DECL_ARGS const struct mdoc_meta *meta, \ const struct mdoc_node *n struct manact { @@ -465,14 +465,15 @@ man_man(void *arg, const struct man *man) void man_mdoc(void *arg, const struct mdoc *mdoc) { - const struct mdoc_meta *m; + const struct mdoc_meta *meta; const struct mdoc_node *n; - m = mdoc_meta(mdoc); + meta = mdoc_meta(mdoc); n = mdoc_node(mdoc); printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n", - m->title, m->msec, m->date, m->os, m->vol); + meta->title, meta->msec, meta->date, + meta->os, meta->vol); /* Disable hyphenation and if nroff, disable justification. */ printf(".nh\n.if n .ad l"); @@ -483,7 +484,7 @@ man_mdoc(void *arg, const struct mdoc *mdoc) fontqueue.head = fontqueue.tail = mandoc_malloc(8); *fontqueue.tail = 'R'; } - print_node(m, n); + print_node(meta, n); putchar('\n'); } @@ -524,9 +525,9 @@ print_node(DECL_ARGS) * node. */ act = manacts + n->tok; - cond = NULL == act->cond || (*act->cond)(m, n); + cond = NULL == act->cond || (*act->cond)(meta, n); if (cond && act->pre) - do_sub = (*act->pre)(m, n); + do_sub = (*act->pre)(meta, n); } /* @@ -536,13 +537,13 @@ print_node(DECL_ARGS) */ if (do_sub) for (sub = n->child; sub; sub = sub->next) - print_node(m, sub); + print_node(meta, sub); /* * Lastly, conditionally run the post-node handler. */ if (cond && act->post) - (*act->post)(m, n); + (*act->post)(meta, n); } static int @@ -633,7 +634,7 @@ post__t(DECL_ARGS) putchar('\"'); } else font_pop(); - post_percent(m, n); + post_percent(meta, n); } /* @@ -936,7 +937,7 @@ pre_fa(DECL_ARGS) while (NULL != n) { font_push('I'); - print_node(m, n); + print_node(meta, n); font_pop(); if (NULL != (n = n->next)) print_word(","); @@ -1000,7 +1001,7 @@ pre_fn(DECL_ARGS) return(0); font_push('B'); - print_node(m, n); + print_node(meta, n); font_pop(); outflags &= ~MMAN_spc; print_word("("); @@ -1008,7 +1009,7 @@ pre_fn(DECL_ARGS) n = n->next; if (NULL != n) - pre_fa(m, n); + pre_fa(meta, n); return(0); } @@ -1054,7 +1055,7 @@ post_fo(DECL_ARGS) font_pop(); break; case (MDOC_BODY): - post_fn(m, n); + post_fn(meta, n); break; default: break; @@ -1253,7 +1254,7 @@ pre_nm(DECL_ARGS) pre_syn(n); if (MDOC_ELEM != n->type && MDOC_HEAD != n->type) return(1); - name = n->child ? n->child->string : m->name; + name = n->child ? n->child->string : meta->name; if (NULL == name) return(0); if (MDOC_HEAD == n->type) { @@ -1265,7 +1266,7 @@ pre_nm(DECL_ARGS) } font_push('B'); if (NULL == n->child) - print_word(m->name); + print_word(meta->name); return(1); } @@ -1397,13 +1398,13 @@ pre_xr(DECL_ARGS) n = n->child; if (NULL == n) return(0); - print_node(m, n); + print_node(meta, n); n = n->next; if (NULL == n) return(0); outflags &= ~MMAN_spc; print_word("("); - print_node(m, n); + print_node(meta, n); print_word(")"); return(0); } diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 43f61a708b4..ee01fd3ad3a 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.146 2012/11/16 17:16:29 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.147 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -37,7 +37,7 @@ struct termpair { #define DECL_ARGS struct termp *p, \ struct termpair *pair, \ - const struct mdoc_meta *m, \ + const struct mdoc_meta *meta, \ struct mdoc_node *n struct termact { @@ -247,7 +247,7 @@ void terminal_mdoc(void *arg, const struct mdoc *mdoc) { const struct mdoc_node *n; - const struct mdoc_meta *m; + const struct mdoc_meta *meta; struct termp *p; p = (struct termp *)arg; @@ -263,12 +263,12 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc) p->symtab = mchars_alloc(); n = mdoc_node(mdoc); - m = mdoc_meta(mdoc); + meta = mdoc_meta(mdoc); - term_begin(p, print_mdoc_head, print_mdoc_foot, m); + term_begin(p, print_mdoc_head, print_mdoc_foot, meta); if (n->child) - print_mdoc_nodelist(p, NULL, m, n->child); + print_mdoc_nodelist(p, NULL, meta, n->child); term_end(p); } @@ -278,9 +278,9 @@ static void print_mdoc_nodelist(DECL_ARGS) { - print_mdoc_node(p, pair, m, n); + print_mdoc_node(p, pair, meta, n); if (n->next) - print_mdoc_nodelist(p, pair, m, n->next); + print_mdoc_nodelist(p, pair, meta, n->next); } @@ -354,12 +354,12 @@ print_mdoc_node(DECL_ARGS) default: if (termacts[n->tok].pre && ENDBODY_NOT == n->end) chld = (*termacts[n->tok].pre) - (p, &npair, m, n); + (p, &npair, meta, n); break; } if (chld && n->child) - print_mdoc_nodelist(p, &npair, m, n->child); + print_mdoc_nodelist(p, &npair, meta, n->child); term_fontpopq(p, (ENDBODY_NOT == n->end ? n : n->pending)->prev_font); @@ -374,7 +374,7 @@ print_mdoc_node(DECL_ARGS) default: if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags) break; - (void)(*termacts[n->tok].post)(p, &npair, m, n); + (void)(*termacts[n->tok].post)(p, &npair, meta, n); /* * Explicit end tokens not only call the post @@ -405,9 +405,9 @@ print_mdoc_node(DECL_ARGS) static void print_mdoc_foot(struct termp *p, const void *arg) { - const struct mdoc_meta *m; + const struct mdoc_meta *meta; - m = (const struct mdoc_meta *)arg; + meta = (const struct mdoc_meta *)arg; term_fontrepl(p, TERMFONT_NONE); @@ -423,17 +423,17 @@ print_mdoc_foot(struct termp *p, const void *arg) p->offset = 0; p->rmargin = (p->maxrmargin - - term_strlen(p, m->date) + term_len(p, 1)) / 2; + term_strlen(p, meta->date) + term_len(p, 1)) / 2; p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; - term_word(p, m->os); + term_word(p, meta->os); term_flushln(p); p->offset = p->rmargin; - p->rmargin = p->maxrmargin - term_strlen(p, m->os); + p->rmargin = p->maxrmargin - term_strlen(p, meta->os); p->flags |= TERMP_NOSPACE; - term_word(p, m->date); + term_word(p, meta->date); term_flushln(p); p->offset = p->rmargin; @@ -441,7 +441,7 @@ print_mdoc_foot(struct termp *p, const void *arg) p->flags &= ~TERMP_NOBREAK; p->flags |= TERMP_NOSPACE; - term_word(p, m->os); + term_word(p, meta->os); term_flushln(p); p->offset = 0; @@ -455,9 +455,9 @@ print_mdoc_head(struct termp *p, const void *arg) { char buf[BUFSIZ], title[BUFSIZ]; size_t buflen, titlen; - const struct mdoc_meta *m; + const struct mdoc_meta *meta; - m = (const struct mdoc_meta *)arg; + meta = (const struct mdoc_meta *)arg; /* * The header is strange. It has three components, which are @@ -475,17 +475,17 @@ print_mdoc_head(struct termp *p, const void *arg) p->offset = 0; p->rmargin = p->maxrmargin; - assert(m->vol); - strlcpy(buf, m->vol, BUFSIZ); + assert(meta->vol); + strlcpy(buf, meta->vol, BUFSIZ); buflen = term_strlen(p, buf); - if (m->arch) { + if (meta->arch) { strlcat(buf, " (", BUFSIZ); - strlcat(buf, m->arch, BUFSIZ); + strlcat(buf, meta->arch, BUFSIZ); strlcat(buf, ")", BUFSIZ); } - snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec); + snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); titlen = term_strlen(p, title); p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; @@ -1007,14 +1007,15 @@ termp_nm_pre(DECL_ARGS) return(0); p->flags |= TERMP_NOSPACE; p->offset += term_len(p, 1) + - (NULL == n->prev->child ? term_strlen(p, m->name) : + (NULL == n->prev->child ? + term_strlen(p, meta->name) : MDOC_TEXT == n->prev->child->type ? - term_strlen(p, n->prev->child->string) : + term_strlen(p, n->prev->child->string) : term_len(p, 5)); return(1); } - if (NULL == n->child && NULL == m->name) + if (NULL == n->child && NULL == meta->name) return(0); if (MDOC_HEAD == n->type) @@ -1024,7 +1025,7 @@ termp_nm_pre(DECL_ARGS) p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; p->rmargin = p->offset + term_len(p, 1); if (NULL == n->child) { - p->rmargin += term_strlen(p, m->name); + p->rmargin += term_strlen(p, meta->name); } else if (MDOC_TEXT == n->child->type) { p->rmargin += term_strlen(p, n->child->string); if (n->child->next) @@ -1037,7 +1038,7 @@ termp_nm_pre(DECL_ARGS) term_fontpush(p, TERMFONT_BOLD); if (NULL == n->child) - term_word(p, m->name); + term_word(p, meta->name); return(1); } @@ -1375,14 +1376,14 @@ termp_vt_pre(DECL_ARGS) if (MDOC_ELEM == n->type) { synopsis_pre(p, n); - return(termp_under_pre(p, pair, m, n)); + return(termp_under_pre(p, pair, meta, n)); } else if (MDOC_BLOCK == n->type) { synopsis_pre(p, n); return(1); } else if (MDOC_HEAD == n->type) return(0); - return(termp_under_pre(p, pair, m, n)); + return(termp_under_pre(p, pair, meta, n)); } @@ -1402,7 +1403,7 @@ termp_fd_pre(DECL_ARGS) { synopsis_pre(p, n); - return(termp_bold_pre(p, pair, m, n)); + return(termp_bold_pre(p, pair, meta, n)); } @@ -1634,7 +1635,7 @@ termp_bd_pre(DECL_ARGS) p->rmargin = p->maxrmargin = TERM_MAXMARGIN; for (nn = n->child; nn; nn = nn->next) { - print_mdoc_node(p, pair, m, nn); + print_mdoc_node(p, pair, meta, nn); /* * If the printed node flushes its own line, then we * needn't do it here as well. This is hacky, but the @@ -2224,9 +2225,9 @@ termp__t_post(DECL_ARGS) */ if (n->parent && MDOC_Rs == n->parent->tok && n->parent->norm->Rs.quote_T) - termp_quote_post(p, pair, m, n); + termp_quote_post(p, pair, meta, n); - termp____post(p, pair, m, n); + termp____post(p, pair, meta, n); } /* ARGSUSED */ @@ -2240,7 +2241,7 @@ termp__t_pre(DECL_ARGS) */ if (n->parent && MDOC_Rs == n->parent->tok && n->parent->norm->Rs.quote_T) - return(termp_quote_pre(p, pair, m, n)); + return(termp_quote_pre(p, pair, meta, n)); term_fontpush(p, TERMFONT_UNDER); return(1); diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 102c8d8d673..bbf4fa4b365 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.108 2012/11/16 22:20:40 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.109 2012/11/17 00:25:20 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -412,29 +412,29 @@ mdoc_valid_post(struct mdoc *mdoc) } static int -check_count(struct mdoc *m, enum mdoc_type type, +check_count(struct mdoc *mdoc, enum mdoc_type type, enum check_lvl lvl, enum check_ineq ineq, int val) { const char *p; enum mandocerr t; - if (m->last->type != type) + if (mdoc->last->type != type) return(1); switch (ineq) { case (CHECK_LT): p = "less than "; - if (m->last->nchild < val) + if (mdoc->last->nchild < val) return(1); break; case (CHECK_GT): p = "more than "; - if (m->last->nchild > val) + if (mdoc->last->nchild > val) return(1); break; case (CHECK_EQ): p = ""; - if (val == m->last->nchild) + if (val == mdoc->last->nchild) return(1); break; default: @@ -443,9 +443,9 @@ check_count(struct mdoc *m, enum mdoc_type type, } t = lvl == CHECK_WARN ? MANDOCERR_ARGCWARN : MANDOCERR_ARGCOUNT; - mandoc_vmsg(t, m->parse, m->last->line, m->last->pos, + mandoc_vmsg(t, mdoc->parse, mdoc->last->line, mdoc->last->pos, "want %s%d children (have %d)", - p, val, m->last->nchild); + p, val, mdoc->last->nchild); return(1); } @@ -511,7 +511,7 @@ hwarn_le1(POST_ARGS) } static void -check_args(struct mdoc *m, struct mdoc_node *n) +check_args(struct mdoc *mdoc, struct mdoc_node *n) { int i; @@ -520,34 +520,34 @@ check_args(struct mdoc *m, struct mdoc_node *n) assert(n->args->argc); for (i = 0; i < (int)n->args->argc; i++) - check_argv(m, n, &n->args->argv[i]); + check_argv(mdoc, n, &n->args->argv[i]); } static void -check_argv(struct mdoc *m, struct mdoc_node *n, struct mdoc_argv *v) +check_argv(struct mdoc *mdoc, struct mdoc_node *n, struct mdoc_argv *v) { int i; for (i = 0; i < (int)v->sz; i++) - check_text(m, v->line, v->pos, v->value[i]); + check_text(mdoc, v->line, v->pos, v->value[i]); /* FIXME: move to post_std(). */ if (MDOC_Std == v->arg) - if ( ! (v->sz || m->meta.name)) - mdoc_nmsg(m, n, MANDOCERR_NONAME); + if ( ! (v->sz || mdoc->meta.name)) + mdoc_nmsg(mdoc, n, MANDOCERR_NONAME); } static void -check_text(struct mdoc *m, int ln, int pos, char *p) +check_text(struct mdoc *mdoc, int ln, int pos, char *p) { char *cp; - if (MDOC_LITERAL & m->flags) + if (MDOC_LITERAL & mdoc->flags) return; for (cp = p; NULL != (p = strchr(p, '\t')); p++) - mdoc_pmsg(m, ln, pos + (int)(p - cp), MANDOCERR_BADTAB); + mdoc_pmsg(mdoc, ln, pos + (int)(p - cp), MANDOCERR_BADTAB); } static int |