version 1.2, 2008/12/15 01:54:58 |
version 1.3, 2008/12/15 02:23:12 |
|
|
|
|
#include "private.h" |
#include "private.h" |
|
|
#define _C(p) ((const char **)p) |
#define _CC(p) ((const char **)p) |
|
|
|
static int append_text(struct mdoc *, int, |
|
int, int, char *[]); |
|
static int append_scoped(struct mdoc *, int, |
|
int, int, char *[]); |
static int isdelim(const char *); |
static int isdelim(const char *); |
static int args_next(struct mdoc *, int, int *, char *, char **); |
static int args_next(struct mdoc *, int, |
static int append_text(struct mdoc *, int, int, int, char *[]); |
int *, char *, char **); |
static int append_scoped(struct mdoc *, int, int, int, char *[]); |
|
|
|
|
|
static int |
static int |
Line 118 args_next(struct mdoc *mdoc, int tok, |
|
Line 121 args_next(struct mdoc *mdoc, int tok, |
|
|
|
|
|
static int |
static int |
append_scoped(struct mdoc *mdoc, int tok, int pos, int sz, char *args[]) |
append_scoped(struct mdoc *mdoc, int tok, |
|
int pos, int sz, char *args[]) |
{ |
{ |
|
|
|
assert(sz >= 0); |
args[sz] = NULL; |
args[sz] = NULL; |
mdoc_block_alloc(mdoc, pos, tok, 0, NULL); |
mdoc_block_alloc(mdoc, pos, tok, 0, NULL); |
mdoc_head_alloc(mdoc, pos, tok, sz, _C(args)); |
mdoc_head_alloc(mdoc, pos, tok, (size_t)sz, _CC(args)); |
mdoc_body_alloc(mdoc, pos, tok); |
mdoc_body_alloc(mdoc, pos, tok); |
return(1); |
return(1); |
} |
} |
|
|
|
|
static int |
static int |
append_text(struct mdoc *mdoc, int tok, int pos, int sz, char *args[]) |
append_text(struct mdoc *mdoc, int tok, |
|
int pos, int sz, char *args[]) |
{ |
{ |
|
|
|
assert(sz >= 0); |
args[sz] = NULL; |
args[sz] = NULL; |
|
|
switch (tok) { |
switch (tok) { |
Line 149 append_text(struct mdoc *mdoc, int tok, int pos, int s |
|
Line 156 append_text(struct mdoc *mdoc, int tok, int pos, int s |
|
case (MDOC_Tn): |
case (MDOC_Tn): |
if (0 == sz && ! mdoc_warn(mdoc, tok, pos, WARN_ARGS_GE1)) |
if (0 == sz && ! mdoc_warn(mdoc, tok, pos, WARN_ARGS_GE1)) |
return(0); |
return(0); |
mdoc_elem_alloc(mdoc, pos, tok, 0, NULL, sz, _C(args)); |
mdoc_elem_alloc(mdoc, pos, tok, 0, |
|
NULL, (size_t)sz, _CC(args)); |
return(1); |
return(1); |
|
|
case (MDOC_Ar): |
case (MDOC_Ar): |
Line 157 append_text(struct mdoc *mdoc, int tok, int pos, int s |
|
Line 165 append_text(struct mdoc *mdoc, int tok, int pos, int s |
|
case (MDOC_Cm): |
case (MDOC_Cm): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Fl): |
case (MDOC_Fl): |
mdoc_elem_alloc(mdoc, pos, tok, 0, NULL, sz, _C(args)); |
mdoc_elem_alloc(mdoc, pos, tok, 0, |
|
NULL, (size_t)sz, _CC(args)); |
return(1); |
return(1); |
|
|
case (MDOC_Ad): |
case (MDOC_Ad): |
Line 179 append_text(struct mdoc *mdoc, int tok, int pos, int s |
|
Line 188 append_text(struct mdoc *mdoc, int tok, int pos, int s |
|
case (MDOC_Vt): |
case (MDOC_Vt): |
if (0 == sz) |
if (0 == sz) |
return(mdoc_err(mdoc, tok, pos, ERR_ARGS_GE1)); |
return(mdoc_err(mdoc, tok, pos, ERR_ARGS_GE1)); |
mdoc_elem_alloc(mdoc, pos, tok, 0, NULL, sz, _C(args)); |
mdoc_elem_alloc(mdoc, pos, tok, 0, |
|
NULL, (size_t)sz, _CC(args)); |
return(1); |
return(1); |
|
|
/* ======= ADD MORE MACRO ARGUMENT-LIMITS ABOVE. ======= */ |
/* ======= ADD MORE MACRO ARGUMENT-LIMITS ABOVE. ======= */ |
Line 195 append_text(struct mdoc *mdoc, int tok, int pos, int s |
|
Line 205 append_text(struct mdoc *mdoc, int tok, int pos, int s |
|
int |
int |
macro_text(struct mdoc *mdoc, int tok, int ppos, int *pos, char *buf) |
macro_text(struct mdoc *mdoc, int tok, int ppos, int *pos, char *buf) |
{ |
{ |
int lastarg, j, c, lasttok, lastpunct; |
int lastarg, c, lasttok, lastpunct, j; |
char *args[MDOC_LINEARG_MAX], *p; |
char *args[MDOC_LINEARG_MAX], *p; |
|
|
lasttok = ppos; |
lasttok = ppos; |
|
|
macro_scoped_implicit(struct mdoc *mdoc, |
macro_scoped_implicit(struct mdoc *mdoc, |
int tok, int ppos, int *pos, char *buf) |
int tok, int ppos, int *pos, char *buf) |
{ |
{ |
int j, c, lastarg, t; |
int t, c, lastarg, j; |
char *args[MDOC_LINEARG_MAX]; |
char *args[MDOC_LINEARG_MAX]; |
struct mdoc_node *n; |
struct mdoc_node *n; |
|
|
Line 264 macro_scoped_implicit(struct mdoc *mdoc, |
|
Line 274 macro_scoped_implicit(struct mdoc *mdoc, |
|
|
|
assert( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)); |
assert( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)); |
|
|
|
/* LINTED */ |
for (n = mdoc->last; n; n = n->parent) { |
for (n = mdoc->last; n; n = n->parent) { |
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
continue; |
continue; |
|
|
/* Command found. */ |
/* Command found. */ |
|
|
if (MDOC_MAX != (c = mdoc_find(mdoc, args[j]))) |
if (MDOC_MAX != (c = mdoc_find(mdoc, args[j]))) |
if ( ! mdoc_warn(mdoc, tok, *pos, WARN_SYNTAX_MACLIKE)) |
if ( ! mdoc_warn(mdoc, tok, lastarg, WARN_SYNTAX_MACLIKE)) |
return(0); |
return(0); |
|
|
/* Word found. */ |
/* Word found. */ |