libman and libmdoc.
-/* $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>
*
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);
-/* $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>
*
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);
-/* $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>
*
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);
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));
}
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;
/* 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:
-/* $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>
*
}
+/* ARGSUSED */
int
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)
{
}
+/* ARGSUSED */
int
in_line_eoln(MACRO_PROT_ARGS)
{
-/* $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>
*
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);
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));
}
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);
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");
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));
}
* 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;
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 &&
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));
}
/*
* 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;
*/
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);
}
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);
}
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);
-/* $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>
*
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 *);
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;
}
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);
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;
continue;
}
- if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
+ if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
return(0);
break;
}
continue;
}
- if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
+ if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
return(0);
break;
}
continue;
}
- if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
+ if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
return(0);
break;
}
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;
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). */
/* 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
* 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));
}
* 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;
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));
}
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));
}