diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2012-11-17 00:26:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2012-11-17 00:26:33 +0000 |
commit | 1f03d7beeffd15115d82eff4add4681db338cdd1 (patch) | |
tree | 8c5e843389db13e8454ff19ebd5ef27c415b51c9 | |
parent | fef2be9d4fbfa0fd7ac0a086c950c1ce9013a984 (diff) | |
download | mandoc-1f03d7beeffd15115d82eff4add4681db338cdd1.tar.gz |
Cleanup naming of local variables to make the code easier on the eye:
Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta"
and avoid the confusing "*m" which was sometimes this, sometimes that.
No functional change.
ok kristaps@ some time ago
-rw-r--r-- | libman.h | 10 | ||||
-rw-r--r-- | libmdoc.h | 15 | ||||
-rw-r--r-- | man.c | 250 | ||||
-rw-r--r-- | man_html.c | 54 | ||||
-rw-r--r-- | man_macro.c | 120 | ||||
-rw-r--r-- | man_term.c | 40 | ||||
-rw-r--r-- | man_validate.c | 151 | ||||
-rw-r--r-- | mdoc.c | 280 | ||||
-rw-r--r-- | mdoc_argv.c | 58 | ||||
-rw-r--r-- | mdoc_html.c | 57 | ||||
-rw-r--r-- | mdoc_macro.c | 355 | ||||
-rw-r--r-- | mdoc_man.c | 37 | ||||
-rw-r--r-- | mdoc_term.c | 73 | ||||
-rw-r--r-- | mdoc_validate.c | 32 |
14 files changed, 765 insertions, 767 deletions
@@ -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); @@ -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); @@ -60,20 +60,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); } @@ -112,28 +112,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)); } @@ -157,16 +157,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; } @@ -234,7 +234,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; @@ -245,89 +245,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); } @@ -347,52 +347,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: @@ -400,32 +400,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. */ @@ -435,9 +435,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); } @@ -451,7 +451,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. */ ; @@ -462,7 +462,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); /* @@ -473,13 +473,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; @@ -487,7 +487,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); @@ -509,7 +509,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); } @@ -525,7 +525,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 @@ -534,8 +534,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. */ @@ -543,20 +543,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 @@ -574,12 +574,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; } /* @@ -588,13 +588,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; /* @@ -602,19 +602,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); } @@ -623,30 +623,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. */ @@ -666,26 +666,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); } @@ -37,7 +37,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 @@ -141,12 +141,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'); } @@ -162,14 +162,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); } @@ -180,9 +180,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); } @@ -192,9 +192,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); } @@ -209,7 +209,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): /* @@ -260,25 +260,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; } } @@ -306,12 +306,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"); @@ -365,16 +365,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); } @@ -470,7 +470,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); @@ -545,14 +545,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/man_macro.c b/man_macro.c index 7ba1fca0..ab252b83 100644 --- a/man_macro.c +++ b/man_macro.c @@ -97,7 +97,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) @@ -108,7 +108,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); } @@ -117,33 +117,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); @@ -241,13 +241,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 @@ -266,7 +266,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)); } @@ -289,14 +289,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); } @@ -312,34 +312,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)); } @@ -360,27 +360,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); } @@ -389,17 +389,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)); } @@ -411,16 +411,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); } @@ -430,9 +430,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); } @@ -440,11 +440,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 @@ -452,22 +452,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); @@ -475,14 +475,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; @@ -493,6 +493,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); } @@ -48,7 +48,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); @@ -138,7 +138,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; @@ -154,9 +154,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)); @@ -166,7 +166,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); } @@ -327,7 +327,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; } @@ -644,7 +644,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; @@ -729,7 +729,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; @@ -982,13 +982,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); @@ -1026,10 +1026,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); } @@ -1104,21 +1104,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/man_validate.c b/man_validate.c index 06f2c88a..95e452bd 100644 --- a/man_validate.c +++ b/man_validate.c @@ -35,7 +35,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); @@ -123,7 +123,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; @@ -143,27 +143,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): @@ -172,10 +172,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); @@ -186,29 +186,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); @@ -219,12 +219,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) \ @@ -233,7 +233,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); \ @@ -287,14 +287,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); @@ -306,7 +306,7 @@ pre_sec(CHKARGS) { if (MAN_BLOCK == n->type) - m->flags &= ~MAN_LITERAL; + man->flags &= ~MAN_LITERAL; return(1); } @@ -317,7 +317,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); } @@ -326,7 +326,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); @@ -340,15 +340,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; @@ -364,11 +364,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; @@ -382,21 +382,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 */ @@ -406,22 +401,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 */ @@ -429,30 +424,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); } @@ -460,10 +455,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); } @@ -471,10 +466,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); } @@ -511,10 +506,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); } @@ -551,10 +544,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); } @@ -569,14 +560,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; @@ -104,20 +104,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); } @@ -218,61 +218,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); } @@ -282,12 +282,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, @@ -295,16 +295,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 @@ -315,31 +315,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)); } @@ -427,13 +427,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; @@ -441,84 +441,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)++; @@ -537,20 +537,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)++; @@ -563,24 +563,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); } @@ -600,7 +600,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. */ @@ -622,41 +622,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 @@ -670,7 +670,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; @@ -678,12 +678,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. */ @@ -700,11 +700,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)); } @@ -718,20 +718,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 @@ -743,8 +743,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 && @@ -752,8 +752,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)); } /* @@ -781,7 +781,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 '\\': @@ -798,28 +798,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); /* @@ -831,7 +831,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); } @@ -842,7 +842,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; @@ -852,7 +852,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); @@ -874,7 +874,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); } @@ -895,21 +895,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 @@ -918,8 +918,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); } @@ -934,22 +934,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/mdoc_argv.c b/mdoc_argv.c index f914118a..b9cff265 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -275,7 +275,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; @@ -342,11 +342,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): @@ -407,14 +407,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; @@ -423,7 +423,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 @@ -432,35 +432,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); } @@ -483,7 +483,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; @@ -517,7 +517,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); @@ -543,12 +543,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]) @@ -559,13 +559,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]) @@ -575,13 +575,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); } @@ -637,7 +637,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; @@ -646,7 +646,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) @@ -663,13 +663,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/mdoc_html.c b/mdoc_html.c index b6103e94..a5f3841d 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -35,7 +35,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 @@ -260,10 +260,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'); } @@ -361,14 +362,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); } @@ -380,10 +381,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); @@ -394,9 +395,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); } @@ -411,7 +412,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... */ @@ -454,7 +455,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; } @@ -471,19 +472,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; } } @@ -509,13 +510,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); } @@ -528,15 +529,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"); @@ -689,13 +690,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); @@ -712,8 +713,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); @@ -1225,7 +1226,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/mdoc_macro.c b/mdoc_macro.c index 29c6cff0..f8608764 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -203,22 +203,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)); } @@ -263,8 +264,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; @@ -460,7 +461,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; @@ -515,7 +516,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); @@ -530,12 +531,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): @@ -543,7 +544,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]); @@ -552,19 +553,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); /* @@ -572,10 +573,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); } @@ -587,18 +588,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 @@ -610,15 +611,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; @@ -629,14 +630,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 @@ -650,7 +651,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); @@ -672,7 +673,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): @@ -689,7 +690,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; @@ -718,13 +719,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; @@ -745,30 +746,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); @@ -780,27 +781,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)); } @@ -815,7 +816,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, @@ -843,7 +844,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; @@ -860,7 +861,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); @@ -879,23 +880,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)); } /* @@ -917,7 +920,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) @@ -928,11 +932,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; } @@ -940,7 +944,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); /* @@ -949,13 +953,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); /* @@ -965,18 +969,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)); } @@ -994,14 +998,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); } @@ -1016,7 +1020,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; @@ -1032,7 +1036,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; @@ -1042,8 +1046,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 @@ -1051,14 +1055,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; @@ -1067,7 +1071,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; @@ -1085,11 +1089,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; } @@ -1104,7 +1108,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; } @@ -1112,9 +1116,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 || @@ -1126,14 +1130,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 @@ -1142,14 +1146,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; } @@ -1157,23 +1161,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. */ @@ -1187,7 +1191,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)) { @@ -1198,21 +1202,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); } @@ -1228,7 +1232,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 @@ -1239,14 +1243,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); /* @@ -1257,7 +1261,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); @@ -1268,26 +1272,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; } @@ -1295,9 +1299,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) @@ -1324,12 +1328,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); @@ -1343,20 +1348,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. */ @@ -1364,7 +1369,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); } @@ -1380,7 +1385,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 @@ -1388,12 +1393,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); @@ -1407,16 +1412,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; } /* @@ -1428,14 +1433,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; @@ -1446,12 +1451,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; } @@ -1459,13 +1464,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); } @@ -1473,7 +1478,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)); } @@ -1488,7 +1493,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). @@ -1520,7 +1525,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; @@ -1538,7 +1543,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); @@ -1550,15 +1555,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; } @@ -1566,10 +1571,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; @@ -1579,26 +1584,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)); } @@ -1615,13 +1620,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; @@ -1638,14 +1643,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); @@ -1655,19 +1660,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)); } @@ -1677,15 +1682,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 @@ -1693,9 +1698,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)); } @@ -1704,7 +1709,7 @@ static int obsolete(MACRO_PROT_ARGS) { - mdoc_pmsg(m, line, ppos, MANDOCERR_MACROOBS); + mdoc_pmsg(mdoc, line, ppos, MANDOCERR_MACROOBS); return(1); } @@ -1715,7 +1720,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; @@ -1725,7 +1730,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); @@ -1735,14 +1740,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); @@ -1763,14 +1768,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); @@ -1780,14 +1785,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); @@ -28,7 +28,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 { @@ -471,14 +471,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\"", - m->title, m->msec, m->date, m->os, m->vol); + meta->title, meta->msec, meta->date, + meta->os, meta->vol); outflags = MMAN_nl | MMAN_Sm; if (0 == fontqueue.size) { @@ -486,7 +487,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'); } @@ -527,9 +528,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); } /* @@ -539,13 +540,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 @@ -636,7 +637,7 @@ post__t(DECL_ARGS) putchar('\"'); } else font_pop(); - post_percent(m, n); + post_percent(meta, n); } /* @@ -939,7 +940,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(","); @@ -1003,7 +1004,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("("); @@ -1011,7 +1012,7 @@ pre_fn(DECL_ARGS) n = n->next; if (NULL != n) - pre_fa(m, n); + pre_fa(meta, n); return(0); } @@ -1057,7 +1058,7 @@ post_fo(DECL_ARGS) font_pop(); break; case (MDOC_BODY): - post_fn(m, n); + post_fn(meta, n); break; default: break; @@ -1256,7 +1257,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) { @@ -1268,7 +1269,7 @@ pre_nm(DECL_ARGS) } font_push('B'); if (NULL == n->child) - print_word(m->name); + print_word(meta->name); return(1); } @@ -1400,13 +1401,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/mdoc_term.c b/mdoc_term.c index 85e659db..3f21bb75 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -41,7 +41,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 { @@ -251,7 +251,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; @@ -267,12 +267,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); } @@ -282,9 +282,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); } @@ -358,12 +358,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); @@ -378,7 +378,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 @@ -409,9 +409,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); @@ -427,17 +427,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; @@ -445,7 +445,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; @@ -459,9 +459,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 @@ -479,17 +479,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; @@ -1011,14 +1011,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) @@ -1028,7 +1029,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) @@ -1041,7 +1042,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); } @@ -1379,14 +1380,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)); } @@ -1406,7 +1407,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)); } @@ -1638,7 +1639,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 @@ -2228,9 +2229,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 */ @@ -2244,7 +2245,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/mdoc_validate.c b/mdoc_validate.c index 80808d93..54630d1b 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -416,29 +416,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: @@ -447,9 +447,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); } @@ -515,7 +515,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; @@ -524,34 +524,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 |