diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-06-26 16:07:08 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-06-26 16:07:08 +0000 |
commit | c5cf90497acc3621015972b85b9c079b43601342 (patch) | |
tree | 746bb9279cdca11169c3263e138d6798d88c4be5 | |
parent | 8ee307fc9980fbb248f1ed3b9c0da115e8c79440 (diff) | |
download | mandoc-c5cf90497acc3621015972b85b9c079b43601342.tar.gz |
Mechanical diff allowing the const struct regset to propogate through
libman and libmdoc.
-rw-r--r-- | libman.h | 9 | ||||
-rw-r--r-- | libmdoc.h | 9 | ||||
-rw-r--r-- | man.c | 11 | ||||
-rw-r--r-- | man_macro.c | 3 | ||||
-rw-r--r-- | mdoc.c | 42 | ||||
-rw-r--r-- | mdoc_macro.c | 33 |
6 files changed, 67 insertions, 40 deletions
@@ -42,8 +42,13 @@ struct man { struct man_meta meta; }; -#define MACRO_PROT_ARGS struct man *m, enum mant tok, int line, \ - int ppos, int *pos, char *buf +#define MACRO_PROT_ARGS struct man *m, \ + const struct regset *regs, \ + enum mant tok, \ + int line, \ + int ppos, \ + int *pos, \ + char *buf struct man_macro { int (*fp)(MACRO_PROT_ARGS); @@ -45,8 +45,13 @@ struct mdoc { enum mdoc_sec lastsec; }; -#define MACRO_PROT_ARGS struct mdoc *m, enum mdoct tok, \ - int line, int ppos, int *pos, char *buf +#define MACRO_PROT_ARGS struct mdoc *m, \ + const struct regset *regs, \ + enum mdoct tok, \ + int line, \ + int ppos, \ + int *pos, \ + char *buf struct mdoc_macro { int (*fp)(MACRO_PROT_ARGS); @@ -54,7 +54,9 @@ static void man_node_free(struct man_node *); static void man_node_unlink(struct man *, struct man_node *); static int man_ptext(struct man *, int, char *, int); -static int man_pmacro(struct man *, int, char *, int); +static int man_pmacro(struct man *, + const struct regset *regs, + int, char *, int); static void man_free1(struct man *); static void man_alloc1(struct man *); static int macrowarn(struct man *, int, const char *, int); @@ -133,7 +135,7 @@ man_parseln(struct man *m, const struct regset *regs, return(0); return(('.' == buf[offs] || '\'' == buf[offs]) ? - man_pmacro(m, ln, buf, offs) : + man_pmacro(m, regs, ln, buf, offs) : man_ptext(m, ln, buf, offs)); } @@ -449,7 +451,8 @@ macrowarn(struct man *m, int ln, const char *buf, int offs) int -man_pmacro(struct man *m, int ln, char *buf, int offs) +man_pmacro(struct man *m, const struct regset *regs, + int ln, char *buf, int offs) { int i, j, ppos; enum mant tok; @@ -574,7 +577,7 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) /* Call to handler... */ assert(man_macros[tok].fp); - if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf)) + if ( ! (*man_macros[tok].fp)(m, regs, tok, ln, ppos, &i, buf)) goto err; out: diff --git a/man_macro.c b/man_macro.c index c859e480..abac5f84 100644 --- a/man_macro.c +++ b/man_macro.c @@ -290,6 +290,7 @@ blk_close(MACRO_PROT_ARGS) } +/* ARGSUSED */ int blk_exp(MACRO_PROT_ARGS) { @@ -341,6 +342,7 @@ blk_exp(MACRO_PROT_ARGS) * scopes, such as `SH' closing out an `SS', are defined in the rew * routines. */ +/* ARGSUSED */ int blk_imp(MACRO_PROT_ARGS) { @@ -398,6 +400,7 @@ blk_imp(MACRO_PROT_ARGS) } +/* ARGSUSED */ int in_line_eoln(MACRO_PROT_ARGS) { @@ -97,8 +97,12 @@ static struct mdoc_node *node_alloc(struct mdoc *, int, int, enum mdoct, enum mdoc_type); static int node_append(struct mdoc *, struct mdoc_node *); -static int mdoc_ptext(struct mdoc *, int, char *, int); -static int mdoc_pmacro(struct mdoc *, int, char *, int); +static int mdoc_ptext(struct mdoc *, + const struct regset *, + int, char *, int); +static int mdoc_pmacro(struct mdoc *, + const struct regset *, + int, char *, int); static int macrowarn(struct mdoc *, int, const char *, int); @@ -239,8 +243,8 @@ mdoc_parseln(struct mdoc *m, const struct regset *regs, m->flags |= MDOC_NEWLINE; return(('.' == buf[offs] || '\'' == buf[offs]) ? - mdoc_pmacro(m, ln, buf, offs) : - mdoc_ptext(m, ln, buf, offs)); + mdoc_pmacro(m, regs, ln, buf, offs) : + mdoc_ptext(m, regs, ln, buf, offs)); } @@ -260,8 +264,7 @@ mdoc_vmsg(struct mdoc *mdoc, enum mandocerr t, int -mdoc_macro(struct mdoc *m, enum mdoct tok, - int ln, int pp, int *pos, char *buf) +mdoc_macro(MACRO_PROT_ARGS) { assert(tok < MDOC_MAX); @@ -269,13 +272,13 @@ mdoc_macro(struct mdoc *m, enum mdoct tok, if (MDOC_PROLOGUE & mdoc_macros[tok].flags && MDOC_PBODY & m->flags) - return(mdoc_pmsg(m, ln, pp, MANDOCERR_BADBODY)); + return(mdoc_pmsg(m, line, ppos, MANDOCERR_BADBODY)); /* If we're in the prologue, deny "body" macros. */ if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) && ! (MDOC_PBODY & m->flags)) { - if ( ! mdoc_pmsg(m, ln, pp, MANDOCERR_BADPROLOG)) + if ( ! mdoc_pmsg(m, line, ppos, MANDOCERR_BADPROLOG)) return(0); if (NULL == m->meta.title) m->meta.title = mandoc_strdup("UNKNOWN"); @@ -288,7 +291,8 @@ mdoc_macro(struct mdoc *m, enum mdoct tok, m->flags |= MDOC_PBODY; } - return((*mdoc_macros[tok].fp)(m, tok, ln, pp, pos, buf)); + return((*mdoc_macros[tok].fp) + (m, regs, tok, line, ppos, pos, buf)); } @@ -542,7 +546,8 @@ mdoc_node_delete(struct mdoc *m, struct mdoc_node *p) * control character. */ static int -mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) +mdoc_ptext(struct mdoc *m, const struct regset *regs, + int line, char *buf, int offs) { char *c, *ws, *end; struct mdoc_node *n; @@ -573,7 +578,8 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) LIST_column == n->data.Bl.type) { /* `Bl' is open without any children. */ m->flags |= MDOC_FREECOL; - return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); + return(mdoc_macro(m, regs, MDOC_It, + line, offs, &offs, buf)); } if (MDOC_It == n->tok && MDOC_BLOCK == n->type && @@ -582,7 +588,8 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) LIST_column == n->parent->data.Bl.type) { /* `Bl' has block-level `It' children. */ m->flags |= MDOC_FREECOL; - return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); + return(mdoc_macro(m, regs, MDOC_It, + line, offs, &offs, buf)); } /* @@ -692,7 +699,8 @@ macrowarn(struct mdoc *m, int ln, const char *buf, int offs) * character. */ int -mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) +mdoc_pmacro(struct mdoc *m, const struct regset *regs, + int ln, char *buf, int offs) { enum mdoct tok; int i, j, sv; @@ -771,7 +779,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) */ if (NULL == m->last || MDOC_It == tok || MDOC_El == tok) { - if ( ! mdoc_macro(m, tok, ln, sv, &i, buf)) + if ( ! mdoc_macro(m, regs, tok, ln, sv, &i, buf)) goto err; return(1); } @@ -787,7 +795,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) if (MDOC_Bl == n->tok && MDOC_BODY == n->type && LIST_column == n->data.Bl.type) { m->flags |= MDOC_FREECOL; - if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) + if ( ! mdoc_macro(m, regs, MDOC_It, ln, sv, &sv, buf)) goto err; return(1); } @@ -803,14 +811,14 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) MDOC_Bl == n->parent->tok && LIST_column == n->parent->data.Bl.type) { m->flags |= MDOC_FREECOL; - if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) + if ( ! mdoc_macro(m, regs, MDOC_It, ln, sv, &sv, buf)) goto err; return(1); } /* Normal processing of a macro. */ - if ( ! mdoc_macro(m, tok, ln, sv, &i, buf)) + if ( ! mdoc_macro(m, regs, tok, ln, sv, &i, buf)) goto err; return(1); diff --git a/mdoc_macro.c b/mdoc_macro.c index e13d0f9d..22acdff6 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -50,7 +50,9 @@ static int append_delims(struct mdoc *, int, int *, char *); static enum mdoct lookup(enum mdoct, const char *); static enum mdoct lookup_raw(const char *); -static int phrase(struct mdoc *, int, int, char *); +static int phrase(struct mdoc *, + const struct regset *, + int, int, char *); static enum mdoct rew_alt(enum mdoct); static int rew_dobreak(enum mdoct, const struct mdoc_node *); @@ -739,7 +741,7 @@ blk_exp_close(MACRO_PROT_ARGS) return(0); flushed = 1; } - if ( ! mdoc_macro(m, ntok, line, lastarg, pos, buf)) + if ( ! mdoc_macro(m, regs, ntok, line, lastarg, pos, buf)) return(0); break; } @@ -840,7 +842,7 @@ in_line(MACRO_PROT_ARGS) if ( ! mdoc_pmsg(m, line, ppos, MANDOCERR_MACROEMPTY)) return(0); } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf)) return(0); if ( ! nl) return(1); @@ -1086,7 +1088,7 @@ blk_full(MACRO_PROT_ARGS) if (ARGS_PEND == ac && ARGS_PPHRASE == lac) m->flags |= MDOC_PPHRASE; - if ( ! phrase(m, line, la, buf)) + if ( ! phrase(m, regs, line, la, buf)) return(0); m->flags &= ~MDOC_PPHRASE; @@ -1101,7 +1103,7 @@ blk_full(MACRO_PROT_ARGS) continue; } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf)) return(0); break; } @@ -1229,7 +1231,7 @@ blk_part_imp(MACRO_PROT_ARGS) continue; } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf)) return(0); break; } @@ -1374,7 +1376,7 @@ blk_part_exp(MACRO_PROT_ARGS) continue; } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf)) return(0); break; } @@ -1493,7 +1495,7 @@ in_line_argn(MACRO_PROT_ARGS) if ( ! flushed && ! rew_elem(m, tok)) return(0); flushed = 1; - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf)) return(0); j++; break; @@ -1599,7 +1601,7 @@ in_line_eoln(MACRO_PROT_ARGS) if ( ! rew_elem(m, tok)) return(0); - return(mdoc_macro(m, ntok, line, la, pos, buf)); + return(mdoc_macro(m, regs, ntok, line, la, pos, buf)); } /* Close out (no delimiters). */ @@ -1618,11 +1620,11 @@ ctx_synopsis(MACRO_PROT_ARGS) /* If we're not in the SYNOPSIS, go straight to in-line. */ if (SEC_SYNOPSIS != m->lastsec) - return(in_line(m, tok, line, ppos, pos, buf)); + return(in_line(m, regs, 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(m, regs, tok, line, ppos, pos, buf)); /* * XXX: this will open a block scope; however, if later we end @@ -1630,7 +1632,7 @@ ctx_synopsis(MACRO_PROT_ARGS) * the formatting. Be careful. */ - return(blk_part_imp(m, tok, line, ppos, pos, buf)); + return(blk_part_imp(m, regs, tok, line, ppos, pos, buf)); } @@ -1649,7 +1651,8 @@ obsolete(MACRO_PROT_ARGS) * macro is encountered. */ static int -phrase(struct mdoc *m, int line, int ppos, char *buf) +phrase(struct mdoc *m, const struct regset *regs, + int line, int ppos, char *buf) { int la, pos; enum margserr ac; @@ -1674,7 +1677,7 @@ phrase(struct mdoc *m, int line, int ppos, char *buf) continue; } - if ( ! mdoc_macro(m, ntok, line, la, &pos, buf)) + if ( ! mdoc_macro(m, regs, ntok, line, la, &pos, buf)) return(0); return(append_delims(m, line, &pos, buf)); } @@ -1719,7 +1722,7 @@ phrase_ta(MACRO_PROT_ARGS) continue; } - if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) + if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf)) return(0); return(append_delims(m, line, pos, buf)); } |