diff options
-rw-r--r-- | cgi.c | 4 | ||||
-rw-r--r-- | demandoc.c | 4 | ||||
-rw-r--r-- | libman.h | 43 | ||||
-rw-r--r-- | libmandoc.h | 37 | ||||
-rw-r--r-- | libmdoc.h | 62 | ||||
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | main.h | 19 | ||||
-rw-r--r-- | man.c | 104 | ||||
-rw-r--r-- | man.h | 8 | ||||
-rw-r--r-- | man_html.c | 2 | ||||
-rw-r--r-- | man_macro.c | 16 | ||||
-rw-r--r-- | man_term.c | 2 | ||||
-rw-r--r-- | man_validate.c | 4 | ||||
-rw-r--r-- | mandoc.h | 11 | ||||
-rw-r--r-- | mandocdb.c | 4 | ||||
-rw-r--r-- | mdoc.c | 102 | ||||
-rw-r--r-- | mdoc.h | 6 | ||||
-rw-r--r-- | mdoc_argv.c | 18 | ||||
-rw-r--r-- | mdoc_html.c | 2 | ||||
-rw-r--r-- | mdoc_macro.c | 41 | ||||
-rw-r--r-- | mdoc_man.c | 4 | ||||
-rw-r--r-- | mdoc_term.c | 2 | ||||
-rw-r--r-- | mdoc_validate.c | 28 | ||||
-rw-r--r-- | read.c | 12 | ||||
-rw-r--r-- | roff.h | 36 | ||||
-rw-r--r-- | tree.c | 4 |
26 files changed, 283 insertions, 300 deletions
@@ -819,8 +819,8 @@ format(const struct req *req, const char *file) struct manoutput conf; struct mparse *mp; struct mchars *mchars; - struct mdoc *mdoc; - struct man *man; + struct roff_man *mdoc; + struct roff_man *man; void *vp; int fd; int usepath; @@ -110,8 +110,8 @@ usage(void) static void pmandoc(struct mparse *mp, int fd, const char *fn, int list) { - struct mdoc *mdoc; - struct man *man; + struct roff_man *mdoc; + struct roff_man *man; int line, col; mparse_readfd(mp, fd, fn); @@ -16,28 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -enum man_next { - MAN_NEXT_SIBLING = 0, - MAN_NEXT_CHILD -}; - -struct man { - struct mparse *parse; /* parse pointer */ - const char *defos; /* default OS argument for .TH */ - int quick; /* abort parse early */ - int flags; /* parse flags */ -#define MAN_ELINE (1 << 1) /* Next-line element scope. */ -#define MAN_BLINE (1 << 2) /* Next-line block scope. */ -#define MAN_LITERAL (1 << 4) /* Literal input. */ -#define MAN_NEWLINE (1 << 6) /* first macro/text in a line */ - enum man_next next; /* where to put the next node */ - struct roff_node *last; /* the last parsed node */ - struct roff_node *first; /* the first parsed node */ - struct roff_meta meta; /* document meta-data */ - struct roff *roff; -}; - -#define MACRO_PROT_ARGS struct man *man, \ +#define MACRO_PROT_ARGS struct roff_man *man, \ int tok, \ int line, \ int ppos, \ @@ -57,17 +36,17 @@ extern const struct man_macro *const man_macros; __BEGIN_DECLS -void man_word_alloc(struct man *, int, int, const char *); -void man_word_append(struct man *, const char *); -void man_block_alloc(struct man *, int, int, int); -void man_head_alloc(struct man *, int, int, int); -void man_body_alloc(struct man *, int, int, int); -void man_elem_alloc(struct man *, int, int, int); -void man_node_delete(struct man *, struct roff_node *); +void man_word_alloc(struct roff_man *, int, int, const char *); +void man_word_append(struct roff_man *, const char *); +void man_block_alloc(struct roff_man *, int, int, int); +void man_head_alloc(struct roff_man *, int, int, int); +void man_body_alloc(struct roff_man *, int, int, int); +void man_elem_alloc(struct roff_man *, int, int, int); +void man_node_delete(struct roff_man *, struct roff_node *); void man_hash_init(void); int man_hash_find(const char *); -void man_macroend(struct man *); -void man_valid_post(struct man *); -void man_unscope(struct man *, const struct roff_node *); +void man_macroend(struct roff_man *); +void man_valid_post(struct roff_man *); +void man_unscope(struct roff_man *, const struct roff_node *); __END_DECLS diff --git a/libmandoc.h b/libmandoc.h index f229466a..779e3c11 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -1,15 +1,15 @@ /* $Id$ */ /* * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF @@ -39,8 +39,7 @@ struct mchars; struct tbl_span; struct eqn; struct roff; -struct mdoc; -struct man; +struct roff_man; void mandoc_msg(enum mandocerr, struct mparse *, int, int, const char *); @@ -55,23 +54,23 @@ int mandoc_eos(const char *, size_t); int mandoc_strntoi(const char *, size_t, int); const char *mandoc_a2msec(const char*); -void mdoc_free(struct mdoc *); -struct mdoc *mdoc_alloc(struct roff *, struct mparse *, +void mdoc_free(struct roff_man *); +struct roff_man *mdoc_alloc(struct roff *, struct mparse *, const char *, int); -void mdoc_reset(struct mdoc *); -int mdoc_parseln(struct mdoc *, int, char *, int); -void mdoc_endparse(struct mdoc *); -void mdoc_addspan(struct mdoc *, const struct tbl_span *); -void mdoc_addeqn(struct mdoc *, const struct eqn *); +void mdoc_reset(struct roff_man *); +int mdoc_parseln(struct roff_man *, int, char *, int); +void mdoc_endparse(struct roff_man *); +void mdoc_addspan(struct roff_man *, const struct tbl_span *); +void mdoc_addeqn(struct roff_man *, const struct eqn *); -void man_free(struct man *); -struct man *man_alloc(struct roff *, struct mparse *, +void man_free(struct roff_man *); +struct roff_man *man_alloc(struct roff *, struct mparse *, const char *, int); -void man_reset(struct man *); -int man_parseln(struct man *, int, char *, int); -void man_endparse(struct man *); -void man_addspan(struct man *, const struct tbl_span *); -void man_addeqn(struct man *, const struct eqn *); +void man_reset(struct roff_man *); +int man_parseln(struct roff_man *, int, char *, int); +void man_endparse(struct roff_man *); +void man_addspan(struct roff_man *, const struct tbl_span *); +void man_addeqn(struct roff_man *, const struct eqn *); int preconv_cue(const struct buf *, size_t); int preconv_encode(struct buf *, size_t *, @@ -16,37 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -enum mdoc_next { - MDOC_NEXT_SIBLING = 0, - MDOC_NEXT_CHILD -}; - -struct mdoc { - struct mparse *parse; /* parse pointer */ - const char *defos; /* default argument for .Os */ - int quick; /* abort parse early */ - int flags; /* parse flags */ -#define MDOC_LITERAL (1 << 1) /* in a literal scope */ -#define MDOC_PBODY (1 << 2) /* in the document body */ -#define MDOC_NEWLINE (1 << 3) /* first macro/text in a line */ -#define MDOC_PHRASELIT (1 << 4) /* literal within a partila phrase */ -#define MDOC_PPHRASE (1 << 5) /* within a partial phrase */ -#define MDOC_FREECOL (1 << 6) /* `It' invocation should close */ -#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting */ -#define MDOC_KEEP (1 << 8) /* in a word keep */ -#define MDOC_SMOFF (1 << 9) /* spacing is off */ -#define MDOC_NODELIMC (1 << 10) /* disable closing delimiter handling */ - enum mdoc_next next; /* where to put the next node */ - struct roff_node *last; /* the last node parsed */ - struct roff_node *first; /* the first node parsed */ - struct roff_node *last_es; /* the most recent Es node */ - struct roff_meta meta; /* document meta-data */ - enum roff_sec lastnamed; - enum roff_sec lastsec; - struct roff *roff; -}; - -#define MACRO_PROT_ARGS struct mdoc *mdoc, \ +#define MACRO_PROT_ARGS struct roff_man *mdoc, \ int tok, \ int line, \ int ppos, \ @@ -97,33 +67,33 @@ extern const struct mdoc_macro *const mdoc_macros; __BEGIN_DECLS void mdoc_macro(MACRO_PROT_ARGS); -void mdoc_word_alloc(struct mdoc *, int, int, const char *); -void mdoc_word_append(struct mdoc *, const char *); -void mdoc_elem_alloc(struct mdoc *, int, int, +void mdoc_word_alloc(struct roff_man *, int, int, const char *); +void mdoc_word_append(struct roff_man *, const char *); +void mdoc_elem_alloc(struct roff_man *, int, int, int, struct mdoc_arg *); -struct roff_node *mdoc_block_alloc(struct mdoc *, int, int, +struct roff_node *mdoc_block_alloc(struct roff_man *, int, int, int, struct mdoc_arg *); -struct roff_node *mdoc_head_alloc(struct mdoc *, int, int, int); -void mdoc_tail_alloc(struct mdoc *, int, int, int); -struct roff_node *mdoc_body_alloc(struct mdoc *, int, int, int); -struct roff_node *mdoc_endbody_alloc(struct mdoc *, int, int, int, +struct roff_node *mdoc_head_alloc(struct roff_man *, int, int, int); +void mdoc_tail_alloc(struct roff_man *, int, int, int); +struct roff_node *mdoc_body_alloc(struct roff_man *, int, int, int); +struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int, int, struct roff_node *, enum mdoc_endbody); -void mdoc_node_delete(struct mdoc *, struct roff_node *); -void mdoc_node_relink(struct mdoc *, struct roff_node *); +void mdoc_node_delete(struct roff_man *, struct roff_node *); +void mdoc_node_relink(struct roff_man *, struct roff_node *); void mdoc_hash_init(void); int mdoc_hash_find(const char *); const char *mdoc_a2att(const char *); const char *mdoc_a2lib(const char *); const char *mdoc_a2st(const char *); const char *mdoc_a2arch(const char *); -void mdoc_valid_pre(struct mdoc *, struct roff_node *); -void mdoc_valid_post(struct mdoc *); -void mdoc_argv(struct mdoc *, int, int, +void mdoc_valid_pre(struct roff_man *, struct roff_node *); +void mdoc_valid_post(struct roff_man *); +void mdoc_argv(struct roff_man *, int, int, struct mdoc_arg **, int *, char *); void mdoc_argv_free(struct mdoc_arg *); -enum margserr mdoc_args(struct mdoc *, int, +enum margserr mdoc_args(struct roff_man *, int, int *, char *, int, char **); -void mdoc_macroend(struct mdoc *); +void mdoc_macroend(struct roff_man *); enum mdelim mdoc_isdelim(const char *); __END_DECLS @@ -58,8 +58,8 @@ enum outmode { OUTMODE_ONE }; -typedef void (*out_mdoc)(void *, const struct mdoc *); -typedef void (*out_man)(void *, const struct man *); +typedef void (*out_mdoc)(void *, const struct roff_man *); +typedef void (*out_man)(void *, const struct roff_man *); typedef void (*out_free)(void *); enum outt { @@ -632,8 +632,8 @@ static void parse(struct curparse *curp, int fd, const char *file) { enum mandoclevel rctmp; - struct mdoc *mdoc; - struct man *man; + struct roff_man *mdoc; + struct roff_man *man; /* Begin by parsing the file itself. */ @@ -21,8 +21,7 @@ __BEGIN_DECLS struct mchars; -struct mdoc; -struct man; +struct roff_man; struct manoutput; /* @@ -34,15 +33,15 @@ struct manoutput; void *html_alloc(const struct mchars *, const struct manoutput *); -void html_mdoc(void *, const struct mdoc *); -void html_man(void *, const struct man *); +void html_mdoc(void *, const struct roff_man *); +void html_man(void *, const struct roff_man *); void html_free(void *); -void tree_mdoc(void *, const struct mdoc *); -void tree_man(void *, const struct man *); +void tree_mdoc(void *, const struct roff_man *); +void tree_man(void *, const struct roff_man *); -void man_mdoc(void *, const struct mdoc *); -void man_man(void *, const struct man *); +void man_mdoc(void *, const struct roff_man *); +void man_man(void *, const struct roff_man *); void *locale_alloc(const struct mchars *, const struct manoutput *); @@ -59,7 +58,7 @@ void *ps_alloc(const struct mchars *, const struct manoutput *); void pspdf_free(void *); -void terminal_mdoc(void *, const struct mdoc *); -void terminal_man(void *, const struct man *); +void terminal_mdoc(void *, const struct roff_man *); +void terminal_man(void *, const struct roff_man *); __END_DECLS @@ -49,35 +49,37 @@ const char *const __man_macronames[MAN_MAX] = { const char * const *man_macronames = __man_macronames; -static void man_alloc1(struct man *); -static void man_breakscope(struct man *, int); -static void man_descope(struct man *, int, int); -static void man_free1(struct man *); -static struct roff_node *man_node_alloc(struct man *, int, int, +static void man_alloc1(struct roff_man *); +static void man_breakscope(struct roff_man *, int); +static void man_descope(struct roff_man *, int, int); +static void man_free1(struct roff_man *); +static struct roff_node *man_node_alloc(struct roff_man *, int, int, enum roff_type, int); -static void man_node_append(struct man *, struct roff_node *); +static void man_node_append(struct roff_man *, + struct roff_node *); static void man_node_free(struct roff_node *); -static void man_node_unlink(struct man *, struct roff_node *); -static int man_ptext(struct man *, int, char *, int); -static int man_pmacro(struct man *, int, char *, int); +static void man_node_unlink(struct roff_man *, + struct roff_node *); +static int man_ptext(struct roff_man *, int, char *, int); +static int man_pmacro(struct roff_man *, int, char *, int); const struct roff_node * -man_node(const struct man *man) +man_node(const struct roff_man *man) { return(man->first); } const struct roff_meta * -man_meta(const struct man *man) +man_meta(const struct roff_man *man) { return(&man->meta); } void -man_reset(struct man *man) +man_reset(struct roff_man *man) { man_free1(man); @@ -85,20 +87,20 @@ man_reset(struct man *man) } void -man_free(struct man *man) +man_free(struct roff_man *man) { man_free1(man); free(man); } -struct man * +struct roff_man * man_alloc(struct roff *roff, struct mparse *parse, const char *defos, int quick) { - struct man *p; + struct roff_man *p; - p = mandoc_calloc(1, sizeof(struct man)); + p = mandoc_calloc(1, sizeof(*p)); man_hash_init(); p->parse = parse; @@ -111,14 +113,14 @@ man_alloc(struct roff *roff, struct mparse *parse, } void -man_endparse(struct man *man) +man_endparse(struct roff_man *man) { man_macroend(man); } int -man_parseln(struct man *man, int ln, char *buf, int offs) +man_parseln(struct roff_man *man, int ln, char *buf, int offs) { if (man->last->type != ROFFT_EQN || ln > man->last->line) @@ -130,7 +132,7 @@ man_parseln(struct man *man, int ln, char *buf, int offs) } static void -man_free1(struct man *man) +man_free1(struct roff_man *man) { if (man->first) @@ -143,7 +145,7 @@ man_free1(struct man *man) } static void -man_alloc1(struct man *man) +man_alloc1(struct roff_man *man) { memset(&man->meta, 0, sizeof(man->meta)); @@ -152,12 +154,12 @@ man_alloc1(struct man *man) man->first = man->last; man->last->type = ROFFT_ROOT; man->last->tok = MAN_MAX; - man->next = MAN_NEXT_CHILD; + man->next = ROFF_NEXT_CHILD; } static void -man_node_append(struct man *man, struct roff_node *p) +man_node_append(struct roff_man *man, struct roff_node *p) { assert(man->last); @@ -165,12 +167,12 @@ man_node_append(struct man *man, struct roff_node *p) assert(p->type != ROFFT_ROOT); switch (man->next) { - case MAN_NEXT_SIBLING: + case ROFF_NEXT_SIBLING: man->last->next = p; p->prev = man->last; p->parent = man->last->parent; break; - case MAN_NEXT_CHILD: + case ROFF_NEXT_CHILD: man->last->child = p; p->parent = man->last; break; @@ -213,7 +215,7 @@ man_node_append(struct man *man, struct roff_node *p) } static struct roff_node * -man_node_alloc(struct man *man, int line, int pos, +man_node_alloc(struct roff_man *man, int line, int pos, enum roff_type type, int tok) { struct roff_node *p; @@ -231,58 +233,58 @@ man_node_alloc(struct man *man, int line, int pos, } void -man_elem_alloc(struct man *man, int line, int pos, int tok) +man_elem_alloc(struct roff_man *man, int line, int pos, int tok) { struct roff_node *p; p = man_node_alloc(man, line, pos, ROFFT_ELEM, tok); man_node_append(man, p); - man->next = MAN_NEXT_CHILD; + man->next = ROFF_NEXT_CHILD; } void -man_head_alloc(struct man *man, int line, int pos, int tok) +man_head_alloc(struct roff_man *man, int line, int pos, int tok) { struct roff_node *p; p = man_node_alloc(man, line, pos, ROFFT_HEAD, tok); man_node_append(man, p); - man->next = MAN_NEXT_CHILD; + man->next = ROFF_NEXT_CHILD; } void -man_body_alloc(struct man *man, int line, int pos, int tok) +man_body_alloc(struct roff_man *man, int line, int pos, int tok) { struct roff_node *p; p = man_node_alloc(man, line, pos, ROFFT_BODY, tok); man_node_append(man, p); - man->next = MAN_NEXT_CHILD; + man->next = ROFF_NEXT_CHILD; } void -man_block_alloc(struct man *man, int line, int pos, int tok) +man_block_alloc(struct roff_man *man, int line, int pos, int tok) { struct roff_node *p; p = man_node_alloc(man, line, pos, ROFFT_BLOCK, tok); man_node_append(man, p); - man->next = MAN_NEXT_CHILD; + man->next = ROFF_NEXT_CHILD; } void -man_word_alloc(struct man *man, int line, int pos, const char *word) +man_word_alloc(struct roff_man *man, int line, int pos, const char *word) { struct roff_node *n; n = man_node_alloc(man, line, pos, ROFFT_TEXT, MAN_MAX); n->string = roff_strdup(man->roff, word); man_node_append(man, n); - man->next = MAN_NEXT_SIBLING; + man->next = ROFF_NEXT_SIBLING; } void -man_word_append(struct man *man, const char *word) +man_word_append(struct roff_man *man, const char *word) { struct roff_node *n; char *addstr, *newstr; @@ -293,7 +295,7 @@ man_word_append(struct man *man, const char *word) free(addstr); free(n->string); n->string = newstr; - man->next = MAN_NEXT_SIBLING; + man->next = ROFF_NEXT_SIBLING; } /* @@ -309,7 +311,7 @@ man_node_free(struct roff_node *p) } void -man_node_delete(struct man *man, struct roff_node *p) +man_node_delete(struct roff_man *man, struct roff_node *p) { while (p->child) @@ -320,7 +322,7 @@ man_node_delete(struct man *man, struct roff_node *p) } void -man_addeqn(struct man *man, const struct eqn *ep) +man_addeqn(struct roff_man *man, const struct eqn *ep) { struct roff_node *n; @@ -329,12 +331,12 @@ man_addeqn(struct man *man, const struct eqn *ep) if (ep->ln > man->last->line) n->flags |= MAN_LINE; man_node_append(man, n); - man->next = MAN_NEXT_SIBLING; + man->next = ROFF_NEXT_SIBLING; man_descope(man, ep->ln, ep->pos); } void -man_addspan(struct man *man, const struct tbl_span *sp) +man_addspan(struct roff_man *man, const struct tbl_span *sp) { struct roff_node *n; @@ -342,12 +344,12 @@ man_addspan(struct man *man, const struct tbl_span *sp) n = man_node_alloc(man, sp->line, 0, ROFFT_TBL, MAN_MAX); n->span = sp; man_node_append(man, n); - man->next = MAN_NEXT_SIBLING; + man->next = ROFF_NEXT_SIBLING; man_descope(man, sp->line, 0); } static void -man_descope(struct man *man, int line, int offs) +man_descope(struct roff_man *man, int line, int offs) { /* * Co-ordinate what happens with having a next-line scope open: @@ -367,7 +369,7 @@ man_descope(struct man *man, int line, int offs) } static int -man_ptext(struct man *man, int line, char *buf, int offs) +man_ptext(struct roff_man *man, int line, char *buf, int offs) { int i; @@ -392,7 +394,7 @@ man_ptext(struct man *man, int line, char *buf, int offs) if (man->last->tok != MAN_SH && man->last->tok != MAN_SS) { man_elem_alloc(man, line, offs, MAN_sp); - man->next = MAN_NEXT_SIBLING; + man->next = ROFF_NEXT_SIBLING; } return(1); } @@ -435,7 +437,7 @@ man_ptext(struct man *man, int line, char *buf, int offs) } static int -man_pmacro(struct man *man, int ln, char *buf, int offs) +man_pmacro(struct roff_man *man, int ln, char *buf, int offs) { struct roff_node *n; const char *cp; @@ -535,7 +537,7 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) } void -man_breakscope(struct man *man, int tok) +man_breakscope(struct roff_man *man, int tok) { struct roff_node *n; @@ -595,7 +597,7 @@ man_breakscope(struct man *man, int tok) * point will also be adjusted accordingly. */ static void -man_node_unlink(struct man *man, struct roff_node *n) +man_node_unlink(struct roff_man *man, struct roff_node *n) { /* Adjust siblings. */ @@ -620,10 +622,10 @@ man_node_unlink(struct man *man, struct roff_node *n) /*assert(NULL == n->next);*/ if (n->prev) { man->last = n->prev; - man->next = MAN_NEXT_SIBLING; + man->next = ROFF_NEXT_SIBLING; } else { man->last = n->parent; - man->next = MAN_NEXT_CHILD; + man->next = ROFF_NEXT_CHILD; } } @@ -632,7 +634,7 @@ man_node_unlink(struct man *man, struct roff_node *n) } const struct mparse * -man_mparse(const struct man *man) +man_mparse(const struct roff_man *man) { assert(man && man->parse); @@ -61,11 +61,11 @@ extern const char *const *man_macronames; __BEGIN_DECLS -struct man; +struct roff_man; -const struct roff_node *man_node(const struct man *); -const struct roff_meta *man_meta(const struct man *); -const struct mparse *man_mparse(const struct man *); +const struct roff_node *man_node(const struct roff_man *); +const struct roff_meta *man_meta(const struct roff_man *); +const struct mparse *man_mparse(const struct roff_man *); void man_deroff(char **, const struct roff_node *); __END_DECLS @@ -145,7 +145,7 @@ print_bvspace(struct html *h, const struct roff_node *n) } void -html_man(void *arg, const struct man *man) +html_man(void *arg, const struct roff_man *man) { struct mhtml mh; diff --git a/man_macro.c b/man_macro.c index ffea89d1..52d88199 100644 --- a/man_macro.c +++ b/man_macro.c @@ -35,9 +35,9 @@ static void blk_close(MACRO_PROT_ARGS); static void blk_exp(MACRO_PROT_ARGS); static void blk_imp(MACRO_PROT_ARGS); static void in_line_eoln(MACRO_PROT_ARGS); -static int man_args(struct man *, int, +static int man_args(struct roff_man *, int, int *, char *, char **); -static void rew_scope(struct man *, int); +static void rew_scope(struct roff_man *, int); const struct man_macro __man_macros[MAN_MAX] = { { in_line_eoln, MAN_NSCOPED }, /* br */ @@ -84,7 +84,7 @@ const struct man_macro * const man_macros = __man_macros; void -man_unscope(struct man *man, const struct roff_node *to) +man_unscope(struct roff_man *man, const struct roff_node *to) { struct roff_node *n; @@ -140,7 +140,7 @@ man_unscope(struct man *man, const struct roff_node *to) */ man->next = (man->last == to) ? - MAN_NEXT_CHILD : MAN_NEXT_SIBLING; + ROFF_NEXT_CHILD : ROFF_NEXT_SIBLING; } /* @@ -149,7 +149,7 @@ man_unscope(struct man *man, const struct roff_node *to) * scopes. When a scope is closed, it must be validated and actioned. */ static void -rew_scope(struct man *man, int tok) +rew_scope(struct roff_man *man, int tok) { struct roff_node *n; @@ -377,7 +377,7 @@ in_line_eoln(MACRO_PROT_ARGS) } assert(man->last->type != ROFFT_ROOT); - man->next = MAN_NEXT_SIBLING; + man->next = ROFF_NEXT_SIBLING; /* * Rewind our element scope. Note that when TH is pruned, we'll @@ -405,14 +405,14 @@ in_line_eoln(MACRO_PROT_ARGS) void -man_macroend(struct man *man) +man_macroend(struct roff_man *man) { man_unscope(man, man->first); } static int -man_args(struct man *man, int line, int *pos, char *buf, char **v) +man_args(struct roff_man *man, int line, int *pos, char *buf, char **v) { char *start; @@ -138,7 +138,7 @@ static const struct termact termacts[MAN_MAX] = { void -terminal_man(void *arg, const struct man *man) +terminal_man(void *arg, const struct roff_man *man) { struct termp *p; const struct roff_meta *meta; diff --git a/man_validate.c b/man_validate.c index 3a695d00..ef45ce21 100644 --- a/man_validate.c +++ b/man_validate.c @@ -35,7 +35,7 @@ #include "libmandoc.h" #include "libman.h" -#define CHKARGS struct man *man, struct roff_node *n +#define CHKARGS struct roff_man *man, struct roff_node *n typedef void (*v_check)(CHKARGS); @@ -98,7 +98,7 @@ static v_check man_valids[MAN_MAX] = { void -man_valid_post(struct man *man) +man_valid_post(struct roff_man *man) { struct roff_node *n; v_check *cp; @@ -7,9 +7,9 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF @@ -412,8 +412,7 @@ __BEGIN_DECLS struct mparse; struct mchars; -struct mdoc; -struct man; +struct roff_man; enum mandoc_esc mandoc_escape(const char **, const char **, int *); struct mchars *mchars_alloc(void); @@ -434,8 +433,8 @@ enum mandoclevel mparse_readfd(struct mparse *, int, const char *); enum mandoclevel mparse_readmem(struct mparse *, void *, size_t, const char *); void mparse_reset(struct mparse *); -void mparse_result(struct mparse *, - struct mdoc **, struct man **, char **); +void mparse_result(struct mparse *, struct roff_man **, + struct roff_man **, char **); const char *mparse_getkeep(const struct mparse *); const char *mparse_strerror(enum mandocerr); const char *mparse_strlevel(enum mandoclevel); @@ -1107,8 +1107,8 @@ mpages_merge(struct mparse *mp) struct ohash_info str_info; struct mpage *mpage, *mpage_dest; struct mlink *mlink, *mlink_dest; - struct mdoc *mdoc; - struct man *man; + struct roff_man *mdoc; + struct roff_man *man; char *sodest; char *cp; int fd; @@ -84,26 +84,26 @@ const char * const *mdoc_macronames = __mdoc_macronames; const char * const *mdoc_argnames = __mdoc_argnames; static void mdoc_node_free(struct roff_node *); -static void mdoc_node_unlink(struct mdoc *, +static void mdoc_node_unlink(struct roff_man *, struct roff_node *); -static void mdoc_free1(struct mdoc *); -static void mdoc_alloc1(struct mdoc *); -static struct roff_node *node_alloc(struct mdoc *, int, int, +static void mdoc_free1(struct roff_man *); +static void mdoc_alloc1(struct roff_man *); +static struct roff_node *node_alloc(struct roff_man *, int, int, int, enum roff_type); -static void node_append(struct mdoc *, struct roff_node *); -static int mdoc_ptext(struct mdoc *, int, char *, int); -static int mdoc_pmacro(struct mdoc *, int, char *, int); +static void node_append(struct roff_man *, struct roff_node *); +static int mdoc_ptext(struct roff_man *, int, char *, int); +static int mdoc_pmacro(struct roff_man *, int, char *, int); const struct roff_node * -mdoc_node(const struct mdoc *mdoc) +mdoc_node(const struct roff_man *mdoc) { return(mdoc->first); } const struct roff_meta * -mdoc_meta(const struct mdoc *mdoc) +mdoc_meta(const struct roff_man *mdoc) { return(&mdoc->meta); @@ -113,7 +113,7 @@ mdoc_meta(const struct mdoc *mdoc) * Frees volatile resources (parse tree, meta-data, fields). */ static void -mdoc_free1(struct mdoc *mdoc) +mdoc_free1(struct roff_man *mdoc) { if (mdoc->first) @@ -131,7 +131,7 @@ mdoc_free1(struct mdoc *mdoc) * Allocate all volatile resources (parse tree, meta-data, fields). */ static void -mdoc_alloc1(struct mdoc *mdoc) +mdoc_alloc1(struct roff_man *mdoc) { memset(&mdoc->meta, 0, sizeof(mdoc->meta)); @@ -141,7 +141,7 @@ mdoc_alloc1(struct mdoc *mdoc) mdoc->first = mdoc->last; mdoc->last->type = ROFFT_ROOT; mdoc->last->tok = MDOC_MAX; - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; } /* @@ -151,7 +151,7 @@ mdoc_alloc1(struct mdoc *mdoc) * cross-parse non-volatile data is kept intact. */ void -mdoc_reset(struct mdoc *mdoc) +mdoc_reset(struct roff_man *mdoc) { mdoc_free1(mdoc); @@ -163,7 +163,7 @@ mdoc_reset(struct mdoc *mdoc) * After invocation, the pointer is no longer usable. */ void -mdoc_free(struct mdoc *mdoc) +mdoc_free(struct roff_man *mdoc) { mdoc_free1(mdoc); @@ -173,13 +173,13 @@ mdoc_free(struct mdoc *mdoc) /* * Allocate volatile and non-volatile parse resources. */ -struct mdoc * +struct roff_man * mdoc_alloc(struct roff *roff, struct mparse *parse, const char *defos, int quick) { - struct mdoc *p; + struct roff_man *p; - p = mandoc_calloc(1, sizeof(struct mdoc)); + p = mandoc_calloc(1, sizeof(*p)); p->parse = parse; p->defos = defos; @@ -192,14 +192,14 @@ mdoc_alloc(struct roff *roff, struct mparse *parse, } void -mdoc_endparse(struct mdoc *mdoc) +mdoc_endparse(struct roff_man *mdoc) { mdoc_macroend(mdoc); } void -mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep) +mdoc_addeqn(struct roff_man *mdoc, const struct eqn *ep) { struct roff_node *n; @@ -208,18 +208,18 @@ mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep) if (ep->ln > mdoc->last->line) n->flags |= MDOC_LINE; node_append(mdoc, n); - mdoc->next = MDOC_NEXT_SIBLING; + mdoc->next = ROFF_NEXT_SIBLING; } void -mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp) +mdoc_addspan(struct roff_man *mdoc, const struct tbl_span *sp) { struct roff_node *n; n = node_alloc(mdoc, sp->line, 0, MDOC_MAX, ROFFT_TBL); n->span = sp; node_append(mdoc, n); - mdoc->next = MDOC_NEXT_SIBLING; + mdoc->next = ROFF_NEXT_SIBLING; } /* @@ -227,7 +227,7 @@ mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp) * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()). */ int -mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs) +mdoc_parseln(struct roff_man *mdoc, int ln, char *buf, int offs) { if (mdoc->last->type != ROFFT_EQN || ln > mdoc->last->line) @@ -277,7 +277,7 @@ mdoc_macro(MACRO_PROT_ARGS) static void -node_append(struct mdoc *mdoc, struct roff_node *p) +node_append(struct roff_man *mdoc, struct roff_node *p) { assert(mdoc->last); @@ -285,12 +285,12 @@ node_append(struct mdoc *mdoc, struct roff_node *p) assert(p->type != ROFFT_ROOT); switch (mdoc->next) { - case MDOC_NEXT_SIBLING: + case ROFF_NEXT_SIBLING: mdoc->last->next = p; p->prev = mdoc->last; p->parent = mdoc->last->parent; break; - case MDOC_NEXT_CHILD: + case ROFF_NEXT_CHILD: mdoc->last->child = p; p->parent = mdoc->last; break; @@ -355,7 +355,7 @@ node_append(struct mdoc *mdoc, struct roff_node *p) } static struct roff_node * -node_alloc(struct mdoc *mdoc, int line, int pos, +node_alloc(struct roff_man *mdoc, int line, int pos, int tok, enum roff_type type) { struct roff_node *p; @@ -381,17 +381,17 @@ node_alloc(struct mdoc *mdoc, int line, int pos, } void -mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, int tok) +mdoc_tail_alloc(struct roff_man *mdoc, int line, int pos, int tok) { struct roff_node *p; p = node_alloc(mdoc, line, pos, tok, ROFFT_TAIL); node_append(mdoc, p); - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; } struct roff_node * -mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, int tok) +mdoc_head_alloc(struct roff_man *mdoc, int line, int pos, int tok) { struct roff_node *p; @@ -399,23 +399,23 @@ mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, int tok) assert(mdoc->last); p = node_alloc(mdoc, line, pos, tok, ROFFT_HEAD); node_append(mdoc, p); - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; return(p); } struct roff_node * -mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, int tok) +mdoc_body_alloc(struct roff_man *mdoc, int line, int pos, int tok) { struct roff_node *p; p = node_alloc(mdoc, line, pos, tok, ROFFT_BODY); node_append(mdoc, p); - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; return(p); } struct roff_node * -mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, int tok, +mdoc_endbody_alloc(struct roff_man *mdoc, int line, int pos, int tok, struct roff_node *body, enum mdoc_endbody end) { struct roff_node *p; @@ -427,12 +427,12 @@ mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, int tok, p->norm = body->norm; p->end = end; node_append(mdoc, p); - mdoc->next = MDOC_NEXT_SIBLING; + mdoc->next = ROFF_NEXT_SIBLING; return(p); } struct roff_node * -mdoc_block_alloc(struct mdoc *mdoc, int line, int pos, +mdoc_block_alloc(struct roff_man *mdoc, int line, int pos, int tok, struct mdoc_arg *args) { struct roff_node *p; @@ -458,12 +458,12 @@ mdoc_block_alloc(struct mdoc *mdoc, int line, int pos, break; } node_append(mdoc, p); - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; return(p); } void -mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos, +mdoc_elem_alloc(struct roff_man *mdoc, int line, int pos, int tok, struct mdoc_arg *args) { struct roff_node *p; @@ -481,22 +481,22 @@ mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos, break; } node_append(mdoc, p); - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; } void -mdoc_word_alloc(struct mdoc *mdoc, int line, int pos, const char *p) +mdoc_word_alloc(struct roff_man *mdoc, int line, int pos, const char *p) { struct roff_node *n; n = node_alloc(mdoc, line, pos, MDOC_MAX, ROFFT_TEXT); n->string = roff_strdup(mdoc->roff, p); node_append(mdoc, n); - mdoc->next = MDOC_NEXT_SIBLING; + mdoc->next = ROFF_NEXT_SIBLING; } void -mdoc_word_append(struct mdoc *mdoc, const char *p) +mdoc_word_append(struct roff_man *mdoc, const char *p) { struct roff_node *n; char *addstr, *newstr; @@ -507,7 +507,7 @@ mdoc_word_append(struct mdoc *mdoc, const char *p) free(addstr); free(n->string); n->string = newstr; - mdoc->next = MDOC_NEXT_SIBLING; + mdoc->next = ROFF_NEXT_SIBLING; } static void @@ -524,7 +524,7 @@ mdoc_node_free(struct roff_node *p) } static void -mdoc_node_unlink(struct mdoc *mdoc, struct roff_node *n) +mdoc_node_unlink(struct roff_man *mdoc, struct roff_node *n) { /* Adjust siblings. */ @@ -549,10 +549,10 @@ mdoc_node_unlink(struct mdoc *mdoc, struct roff_node *n) if (mdoc && mdoc->last == n) { if (n->prev) { mdoc->last = n->prev; - mdoc->next = MDOC_NEXT_SIBLING; + mdoc->next = ROFF_NEXT_SIBLING; } else { mdoc->last = n->parent; - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; } } @@ -561,7 +561,7 @@ mdoc_node_unlink(struct mdoc *mdoc, struct roff_node *n) } void -mdoc_node_delete(struct mdoc *mdoc, struct roff_node *p) +mdoc_node_delete(struct roff_man *mdoc, struct roff_node *p) { while (p->child) { @@ -575,7 +575,7 @@ mdoc_node_delete(struct mdoc *mdoc, struct roff_node *p) } void -mdoc_node_relink(struct mdoc *mdoc, struct roff_node *p) +mdoc_node_relink(struct roff_man *mdoc, struct roff_node *p) { mdoc_node_unlink(mdoc, p); @@ -587,7 +587,7 @@ mdoc_node_relink(struct mdoc *mdoc, struct roff_node *p) * control character. */ static int -mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs) +mdoc_ptext(struct roff_man *mdoc, int line, char *buf, int offs) { struct roff_node *n; char *c, *ws, *end; @@ -675,7 +675,7 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs) * behaviour that we want to work around it. */ mdoc_elem_alloc(mdoc, line, offs, MDOC_sp, NULL); - mdoc->next = MDOC_NEXT_SIBLING; + mdoc->next = ROFF_NEXT_SIBLING; mdoc_valid_post(mdoc); return(1); } @@ -703,7 +703,7 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs) * character. */ static int -mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs) +mdoc_pmacro(struct roff_man *mdoc, int ln, char *buf, int offs) { struct roff_node *n; const char *cp; @@ -282,10 +282,10 @@ extern const char *const *mdoc_argnames; __BEGIN_DECLS -struct mdoc; +struct roff_man; -const struct roff_node *mdoc_node(const struct mdoc *); -const struct roff_meta *mdoc_meta(const struct mdoc *); +const struct roff_node *mdoc_node(const struct roff_man *); +const struct roff_meta *mdoc_meta(const struct roff_man *); void mdoc_deroff(char **, const struct roff_node *); __END_DECLS diff --git a/mdoc_argv.c b/mdoc_argv.c index 519fb9d7..682dcd02 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -52,12 +52,12 @@ struct mdocarg { }; static void argn_free(struct mdoc_arg *, int); -static enum margserr args(struct mdoc *, int, int *, +static enum margserr args(struct roff_man *, int, int *, char *, enum argsflag, char **); static int args_checkpunct(const char *, int); -static void argv_multi(struct mdoc *, int, +static void argv_multi(struct roff_man *, int, struct mdoc_argv *, int *, char *); -static void argv_single(struct mdoc *, int, +static void argv_single(struct roff_man *, int, struct mdoc_argv *, int *, char *); static const enum argvflag argvflags[MDOC_ARG_MAX] = { @@ -276,7 +276,7 @@ static const struct mdocarg mdocargs[MDOC_MAX] = { * Some flags take no argument, some one, some multiple. */ void -mdoc_argv(struct mdoc *mdoc, int line, int tok, +mdoc_argv(struct roff_man *mdoc, int line, int tok, struct mdoc_arg **reta, int *pos, char *buf) { struct mdoc_argv tmpv; @@ -413,7 +413,7 @@ argn_free(struct mdoc_arg *p, int iarg) } enum margserr -mdoc_args(struct mdoc *mdoc, int line, int *pos, +mdoc_args(struct roff_man *mdoc, int line, int *pos, char *buf, int tok, char **v) { struct roff_node *n; @@ -444,7 +444,7 @@ mdoc_args(struct mdoc *mdoc, int line, int *pos, } static enum margserr -args(struct mdoc *mdoc, int line, int *pos, +args(struct roff_man *mdoc, int line, int *pos, char *buf, enum argsflag fl, char **v) { char *p, *pp; @@ -654,7 +654,7 @@ args_checkpunct(const char *buf, int i) } static void -argv_multi(struct mdoc *mdoc, int line, +argv_multi(struct roff_man *mdoc, int line, struct mdoc_argv *v, int *pos, char *buf) { enum margserr ac; @@ -676,7 +676,7 @@ argv_multi(struct mdoc *mdoc, int line, } static void -argv_single(struct mdoc *mdoc, int line, +argv_single(struct roff_man *mdoc, int line, struct mdoc_argv *v, int *pos, char *buf) { enum margserr ac; diff --git a/mdoc_html.c b/mdoc_html.c index 1646ce88..eec5361f 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -265,7 +265,7 @@ static const char * const lists[LIST_MAX] = { void -html_mdoc(void *arg, const struct mdoc *mdoc) +html_mdoc(void *arg, const struct roff_man *mdoc) { print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc)->child, diff --git a/mdoc_macro.c b/mdoc_macro.c index 763866da..360e6e64 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -42,18 +42,19 @@ static void in_line_argn(MACRO_PROT_ARGS); static void in_line(MACRO_PROT_ARGS); static void phrase_ta(MACRO_PROT_ARGS); -static void append_delims(struct mdoc *, int, int *, char *); -static void dword(struct mdoc *, int, int, const char *, +static void append_delims(struct roff_man *, int, int *, char *); +static void dword(struct roff_man *, int, int, const char *, enum mdelim, int); -static int find_pending(struct mdoc *, int, int, int, +static int find_pending(struct roff_man *, int, int, int, struct roff_node *); -static int lookup(struct mdoc *, int, int, int, const char *); +static int lookup(struct roff_man *, int, int, int, const char *); static int macro_or_word(MACRO_PROT_ARGS, int); -static int parse_rest(struct mdoc *, int, int, int *, char *); +static int parse_rest(struct roff_man *, int, int, int *, char *); static int rew_alt(int); -static void rew_elem(struct mdoc *, int); -static void rew_last(struct mdoc *, const struct roff_node *); -static void rew_pending(struct mdoc *, const struct roff_node *); +static void rew_elem(struct roff_man *, int); +static void rew_last(struct roff_man *, const struct roff_node *); +static void rew_pending(struct roff_man *, + const struct roff_node *); const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ap */ @@ -208,7 +209,7 @@ const struct mdoc_macro * const mdoc_macros = __mdoc_macros; * are errors. */ void -mdoc_macroend(struct mdoc *mdoc) +mdoc_macroend(struct roff_man *mdoc) { struct roff_node *n; @@ -233,7 +234,7 @@ mdoc_macroend(struct mdoc *mdoc) * or as a line macro if from == MDOC_MAX. */ static int -lookup(struct mdoc *mdoc, int from, int line, int ppos, const char *p) +lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p) { int res; @@ -254,14 +255,14 @@ lookup(struct mdoc *mdoc, int from, int line, int ppos, const char *p) * Rewind up to and including a specific node. */ static void -rew_last(struct mdoc *mdoc, const struct roff_node *to) +rew_last(struct roff_man *mdoc, const struct roff_node *to) { struct roff_node *n, *np; if (to->flags & MDOC_VALID) return; - mdoc->next = MDOC_NEXT_SIBLING; + mdoc->next = ROFF_NEXT_SIBLING; while (mdoc->last != to) { /* * Save the parent here, because we may delete the @@ -283,7 +284,7 @@ rew_last(struct mdoc *mdoc, const struct roff_node *to) * Rewind up to a specific block, including all blocks that broke it. */ static void -rew_pending(struct mdoc *mdoc, const struct roff_node *n) +rew_pending(struct roff_man *mdoc, const struct roff_node *n) { for (;;) { @@ -364,7 +365,7 @@ rew_alt(int tok) } static void -rew_elem(struct mdoc *mdoc, int tok) +rew_elem(struct roff_man *mdoc, int tok) { struct roff_node *n; @@ -382,7 +383,7 @@ rew_elem(struct mdoc *mdoc, int tok) * the rew_pending() call closing out the sub-block. */ static int -find_pending(struct mdoc *mdoc, int tok, int line, int ppos, +find_pending(struct roff_man *mdoc, int tok, int line, int ppos, struct roff_node *target) { struct roff_node *n; @@ -419,7 +420,7 @@ find_pending(struct mdoc *mdoc, int tok, int line, int ppos, * Punctuation consists of those tokens found in mdoc_isdelim(). */ static void -dword(struct mdoc *mdoc, int line, int col, const char *p, +dword(struct roff_man *mdoc, int line, int col, const char *p, enum mdelim d, int may_append) { @@ -453,7 +454,7 @@ dword(struct mdoc *mdoc, int line, int col, const char *p, } static void -append_delims(struct mdoc *mdoc, int line, int *pos, char *buf) +append_delims(struct roff_man *mdoc, int line, int *pos, char *buf) { char *p; int la; @@ -617,7 +618,7 @@ blk_exp_close(MACRO_PROT_ARGS) */ if (maxargs) - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; break; } @@ -1386,7 +1387,7 @@ in_line_eoln(MACRO_PROT_ARGS) if ((tok == MDOC_Pp || tok == MDOC_Lp) && ! (mdoc->flags & MDOC_SYNOPSIS)) { n = mdoc->last; - if (mdoc->next == MDOC_NEXT_SIBLING) + if (mdoc->next == ROFF_NEXT_SIBLING) n = n->parent; if (n->tok == MDOC_Nm) rew_last(mdoc, mdoc->last->parent); @@ -1412,7 +1413,7 @@ in_line_eoln(MACRO_PROT_ARGS) * or until the next macro, call that macro, and return 1. */ static int -parse_rest(struct mdoc *mdoc, int tok, int line, int *pos, char *buf) +parse_rest(struct roff_man *mdoc, int tok, int line, int *pos, char *buf) { int la; @@ -532,7 +532,7 @@ print_count(int *count) } void -man_man(void *arg, const struct man *man) +man_man(void *arg, const struct roff_man *man) { /* @@ -545,7 +545,7 @@ man_man(void *arg, const struct man *man) } void -man_mdoc(void *arg, const struct mdoc *mdoc) +man_mdoc(void *arg, const struct roff_man *mdoc) { const struct roff_meta *meta; struct roff_node *n; diff --git a/mdoc_term.c b/mdoc_term.c index c4745c29..68338ebd 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -251,7 +251,7 @@ static const struct termact termacts[MDOC_MAX] = { void -terminal_mdoc(void *arg, const struct mdoc *mdoc) +terminal_mdoc(void *arg, const struct roff_man *mdoc) { const struct roff_meta *meta; struct roff_node *n; diff --git a/mdoc_validate.c b/mdoc_validate.c index ccccbc41..21109bc1 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -40,8 +40,8 @@ /* FIXME: .Bl -diag can't have non-text children in HEAD. */ -#define PRE_ARGS struct mdoc *mdoc, struct roff_node *n -#define POST_ARGS struct mdoc *mdoc +#define PRE_ARGS struct roff_man *mdoc, struct roff_node *n +#define POST_ARGS struct roff_man *mdoc enum check_ineq { CHECK_LT, @@ -57,10 +57,10 @@ struct valids { v_post post; }; -static void check_text(struct mdoc *, int, int, char *); -static void check_argv(struct mdoc *, +static void check_text(struct roff_man *, int, int, char *); +static void check_argv(struct roff_man *, struct roff_node *, struct mdoc_argv *); -static void check_args(struct mdoc *, struct roff_node *); +static void check_args(struct roff_man *, struct roff_node *); static int child_an(const struct roff_node *); static enum roff_sec a2sec(const char *); static size_t macro2len(int); @@ -293,7 +293,7 @@ static const char * const secnames[SEC__MAX] = { void -mdoc_valid_pre(struct mdoc *mdoc, struct roff_node *n) +mdoc_valid_pre(struct roff_man *mdoc, struct roff_node *n) { v_pre p; @@ -319,7 +319,7 @@ mdoc_valid_pre(struct mdoc *mdoc, struct roff_node *n) } void -mdoc_valid_post(struct mdoc *mdoc) +mdoc_valid_post(struct roff_man *mdoc) { struct roff_node *n; v_post p; @@ -362,7 +362,7 @@ mdoc_valid_post(struct mdoc *mdoc) } static void -check_args(struct mdoc *mdoc, struct roff_node *n) +check_args(struct roff_man *mdoc, struct roff_node *n) { int i; @@ -375,7 +375,7 @@ check_args(struct mdoc *mdoc, struct roff_node *n) } static void -check_argv(struct mdoc *mdoc, struct roff_node *n, struct mdoc_argv *v) +check_argv(struct roff_man *mdoc, struct roff_node *n, struct mdoc_argv *v) { int i; @@ -384,7 +384,7 @@ check_argv(struct mdoc *mdoc, struct roff_node *n, struct mdoc_argv *v) } static void -check_text(struct mdoc *mdoc, int ln, int pos, char *p) +check_text(struct roff_man *mdoc, int ln, int pos, char *p) { char *cp; @@ -1046,7 +1046,7 @@ post_defaults(POST_ARGS) return; nn = mdoc->last; - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; switch (nn->tok) { case MDOC_Ar: @@ -1074,7 +1074,7 @@ post_at(POST_ARGS) n = mdoc->last; if (n->child == NULL) { - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; mdoc_word_alloc(mdoc, n->line, n->pos, "AT&T UNIX"); mdoc->last = n; return; @@ -1502,7 +1502,7 @@ post_bk(POST_ARGS) } static void -post_sm(struct mdoc *mdoc) +post_sm(struct roff_man *mdoc) { struct roff_node *nch; @@ -2313,7 +2313,7 @@ post_ex(POST_ARGS) return; } - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; mdoc_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name); mdoc->last = n; } @@ -47,10 +47,10 @@ #define REPARSE_LIMIT 1000 struct mparse { - struct man *pman; /* persistent man parser */ - struct mdoc *pmdoc; /* persistent mdoc parser */ - struct man *man; /* man parser */ - struct mdoc *mdoc; /* mdoc parser */ + struct roff_man *pman; /* persistent man parser */ + struct roff_man *pmdoc; /* persistent mdoc parser */ + struct roff_man *man; /* man parser */ + struct roff_man *mdoc; /* mdoc parser */ struct roff *roff; /* roff parser (!NULL) */ const struct mchars *mchars; /* character table */ char *sodest; /* filename pointed to by .so */ @@ -952,8 +952,8 @@ mparse_free(struct mparse *curp) } void -mparse_result(struct mparse *curp, - struct mdoc **mdoc, struct man **man, char **sodest) +mparse_result(struct mparse *curp, struct roff_man **mdoc, + struct roff_man **man, char **sodest) { if (sodest && NULL != (*sodest = curp->sodest)) { @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -58,6 +58,11 @@ enum roff_type { ROFFT_EQN }; +enum roff_next { + ROFF_NEXT_SIBLING = 0, + ROFF_NEXT_CHILD +}; + /* * Indicates that a BODY's formatting has ended, but * the scope is still open. Used for badly nested blocks. @@ -115,3 +120,32 @@ struct roff_meta { char *date; /* Normalized date. */ int hasbody; /* Document is not empty. */ }; + +struct roff_man { + struct roff_meta meta; /* Document meta-data. */ + struct mparse *parse; /* Parse pointer. */ + struct roff *roff; /* Roff parser state data. */ + const char *defos; /* Default operating system. */ + struct roff_node *first; /* The first node parsed. */ + struct roff_node *last; /* The last node parsed. */ + struct roff_node *last_es; /* The most recent Es node. */ + int quick; /* Abort parse early. */ + int flags; /* Parse flags. */ +#define MDOC_LITERAL (1 << 1) /* In a literal scope. */ +#define MDOC_PBODY (1 << 2) /* In the document body. */ +#define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */ +#define MDOC_PHRASELIT (1 << 4) /* Literal within a partial phrase. */ +#define MDOC_PPHRASE (1 << 5) /* Within a partial phrase. */ +#define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */ +#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */ +#define MDOC_KEEP (1 << 8) /* In a word keep. */ +#define MDOC_SMOFF (1 << 9) /* Spacing is off. */ +#define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */ +#define MAN_ELINE (1 << 11) /* Next-line element scope. */ +#define MAN_BLINE (1 << 12) /* Next-line block scope. */ +#define MAN_LITERAL MDOC_LITERAL +#define MAN_NEWLINE MDOC_NEWLINE + enum roff_sec lastsec; /* Last section seen. */ + enum roff_sec lastnamed; /* Last standard section seen. */ + enum roff_next next; /* Where to put the next node. */ +}; @@ -38,14 +38,14 @@ static void print_span(const struct tbl_span *, int); void -tree_mdoc(void *arg, const struct mdoc *mdoc) +tree_mdoc(void *arg, const struct roff_man *mdoc) { print_mdoc(mdoc_node(mdoc)->child, 0); } void -tree_man(void *arg, const struct man *man) +tree_man(void *arg, const struct roff_man *man) { print_man(man_node(man)->child, 0); |