summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--libman.h11
-rw-r--r--libmdoc.h11
-rw-r--r--man.c13
-rw-r--r--man_macro.c5
-rw-r--r--mdoc.c44
-rw-r--r--mdoc_macro.c35
6 files changed, 73 insertions, 46 deletions
diff --git a/libman.h b/libman.h
index e7d537c2..2bc50027 100644
--- a/libman.h
+++ b/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.37 2010/06/26 15:36:37 kristaps Exp $ */
+/* $Id: libman.h,v 1.38 2010/06/26 16:07:08 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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);
diff --git a/libmdoc.h b/libmdoc.h
index e0d96a58..83a300e1 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.54 2010/06/26 15:36:37 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.55 2010/06/26 16:07:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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);
diff --git a/man.c b/man.c
index 02b5bd2f..3c1dbdad 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.77 2010/06/26 15:36:37 kristaps Exp $ */
+/* $Id: man.c,v 1.78 2010/06/26 16:07:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 387e0a34..bf36e799 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.47 2010/06/19 20:46:28 kristaps Exp $ */
+/* $Id: man_macro.c,v 1.48 2010/06/26 16:07:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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)
{
diff --git a/mdoc.c b/mdoc.c
index 36ed1acb..3afa42c0 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.147 2010/06/26 15:36:37 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.148 2010/06/26 16:07:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 0b0fe408..e274dfc7 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.80 2010/06/19 20:46:28 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.81 2010/06/26 16:07:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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));
}