version 1.14, 2008/12/30 18:15:26 |
version 1.15, 2008/12/30 19:06:03 |
|
|
|
|
/* FIXME: maxlineargs should be per LINE, no per TOKEN. */ |
/* FIXME: maxlineargs should be per LINE, no per TOKEN. */ |
/* FIXME: prologue check should be in macro_call. */ |
/* FIXME: prologue check should be in macro_call. */ |
|
/* FIXME: prologue macros should be part of macro_constant. */ |
|
|
#define _CC(p) ((const char **)p) |
#define _CC(p) ((const char **)p) |
|
|
Line 45 static int append_delims(struct mdoc *, int, int *, |
|
Line 46 static int append_delims(struct mdoc *, int, int *, |
|
|
|
|
|
static int |
static int |
append_delims(struct mdoc *mdoc, int tok, int *pos, char *buf) |
|
{ |
|
int c, lastarg; |
|
char *p; |
|
|
|
if (0 == buf[*pos]) |
|
return(1); |
|
|
|
mdoc_msg(mdoc, *pos, "`%s' flushing punctuation", |
|
mdoc_macronames[tok]); |
|
|
|
for (;;) { |
|
lastarg = *pos; |
|
c = mdoc_args(mdoc, tok, pos, buf, 0, &p); |
|
if (ARGS_ERROR == c) |
|
return(0); |
|
else if (ARGS_EOLN == c) |
|
break; |
|
assert(mdoc_isdelim(p)); |
|
mdoc_word_alloc(mdoc, lastarg, p); |
|
} |
|
|
|
return(1); |
|
} |
|
|
|
|
|
static int |
|
scope_rewind_imp(struct mdoc *mdoc, int ppos, int tok) |
scope_rewind_imp(struct mdoc *mdoc, int ppos, int tok) |
{ |
{ |
struct mdoc_node *n; |
struct mdoc_node *n; |
Line 90 scope_rewind_imp(struct mdoc *mdoc, int ppos, int tok) |
|
Line 64 scope_rewind_imp(struct mdoc *mdoc, int ppos, int tok) |
|
return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK)); |
return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK)); |
} |
} |
|
|
if (n) { |
if (n) |
mdoc->last = n; |
mdoc->last = n; |
mdoc_msg(mdoc, ppos, "scope: rewound implicit `%s'", |
|
mdoc_macronames[tok]); |
|
return(1); |
|
} |
|
|
|
mdoc_msg(mdoc, ppos, "scope: new implicit `%s'", |
|
mdoc_macronames[tok]); |
|
return(1); |
return(1); |
} |
} |
|
|
Line 119 scope_rewind_exp(struct mdoc *mdoc, int ppos, int tok, |
|
Line 86 scope_rewind_exp(struct mdoc *mdoc, int ppos, int tok, |
|
return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK)); |
return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK)); |
} |
} |
|
|
if (NULL == (mdoc->last = n)) |
if ((mdoc->last = n)) |
return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_NOCTX)); |
return(1); |
|
return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_NOCTX)); |
|
} |
|
|
mdoc_msg(mdoc, ppos, "scope: rewound explicit `%s' to `%s'", |
|
mdoc_macronames[tok], mdoc_macronames[dst]); |
|
|
|
|
static int |
|
append_delims(struct mdoc *mdoc, int tok, int *pos, char *buf) |
|
{ |
|
int c, lastarg; |
|
char *p; |
|
|
|
if (0 == buf[*pos]) |
|
return(1); |
|
|
|
for (;;) { |
|
lastarg = *pos; |
|
c = mdoc_args(mdoc, tok, pos, buf, 0, &p); |
|
if (ARGS_ERROR == c) |
|
return(0); |
|
else if (ARGS_EOLN == c) |
|
break; |
|
assert(mdoc_isdelim(p)); |
|
mdoc_word_alloc(mdoc, lastarg, p); |
|
} |
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 134 append_constarg(struct mdoc *mdoc, int tok, int pos, |
|
Line 121 append_constarg(struct mdoc *mdoc, int tok, int pos, |
|
int argc, const struct mdoc_arg *argv) |
int argc, const struct mdoc_arg *argv) |
{ |
{ |
|
|
switch (tok) { |
if ( ! mdoc_valid(mdoc, tok, pos, 0, NULL, argc, argv)) |
default: |
return(0); |
break; |
|
} |
|
|
|
mdoc_elem_alloc(mdoc, pos, tok, argc, argv, 0, NULL); |
mdoc_elem_alloc(mdoc, pos, tok, argc, argv, 0, NULL); |
return(1); |
return(1); |
} |
} |
|
|
|
|
/* |
|
* Append a node with implicit or explicit scoping ONLY. ALL macros |
|
* with the implicit- or explicit-scope callback must be included here. |
|
*/ |
|
static int |
static int |
append_scoped(struct mdoc *mdoc, int tok, int pos, |
append_scoped(struct mdoc *mdoc, int tok, int pos, |
int sz, const char *args[], |
int sz, const char *args[], |
Line 188 append_const(struct mdoc *mdoc, int tok, |
|
Line 168 append_const(struct mdoc *mdoc, int tok, |
|
case (MDOC_At): |
case (MDOC_At): |
if (0 == sz) |
if (0 == sz) |
break; |
break; |
|
if (ATT_DEFAULT == mdoc_atoatt(args[0])) { |
if (ATT_DEFAULT != mdoc_atoatt(args[0])) { |
|
mdoc_elem_alloc(mdoc, pos, tok, 0, |
|
NULL, 1, _CC(&args[0])); |
|
} else { |
|
mdoc_elem_alloc(mdoc, pos, tok, |
mdoc_elem_alloc(mdoc, pos, tok, |
0, NULL, 0, NULL); |
0, NULL, 0, NULL); |
mdoc_word_alloc(mdoc, pos, args[0]); |
mdoc_word_alloc(mdoc, pos, args[0]); |
} |
} else |
|
mdoc_elem_alloc(mdoc, pos, tok, 0, |
|
NULL, 1, _CC(&args[0])); |
|
|
if (1 == sz) |
if (sz > 1) |
return(1); |
mdoc_word_alloc(mdoc, pos, args[1]); |
mdoc_word_alloc(mdoc, pos, args[1]); |
|
return(1); |
return(1); |
default: |
default: |
break; |
break; |
Line 226 append_text(struct mdoc *mdoc, int tok, |
|
Line 203 append_text(struct mdoc *mdoc, int tok, |
|
int |
int |
macro_text(MACRO_PROT_ARGS) |
macro_text(MACRO_PROT_ARGS) |
{ |
{ |
int lastarg, lastpunct, c, j; |
int lastarg, lastpunct, c, j, fl; |
char *args[MDOC_LINEARG_MAX]; |
char *args[MDOC_LINEARG_MAX]; |
|
|
if (SEC_PROLOGUE == mdoc->sec_lastn) |
if (SEC_PROLOGUE == mdoc->sec_lastn) |
Line 260 macro_text(MACRO_PROT_ARGS) |
|
Line 237 macro_text(MACRO_PROT_ARGS) |
|
j = 0; |
j = 0; |
lastarg = ppos; |
lastarg = ppos; |
lastpunct = 0; |
lastpunct = 0; |
|
fl = ARGS_DELIM; |
|
|
|
if (MDOC_QUOTABLE & mdoc_macros[tok].flags) |
|
fl |= ARGS_QUOTED; |
|
|
again: |
again: |
if (j == MDOC_LINEARG_MAX) |
if (j == MDOC_LINEARG_MAX) |
return(mdoc_err(mdoc, tok, lastarg, ERR_ARGS_MANY)); |
return(mdoc_err(mdoc, tok, lastarg, ERR_ARGS_MANY)); |
|
|
|
|
lastarg = *pos; |
lastarg = *pos; |
|
|
switch (mdoc_args(mdoc, tok, pos, buf, ARGS_DELIM, &args[j])) { |
switch (mdoc_args(mdoc, tok, pos, buf, fl, &args[j])) { |
case (ARGS_ERROR): |
case (ARGS_ERROR): |
return(0); |
return(0); |
case (ARGS_WORD): |
case (ARGS_WORD): |
Line 410 macro_prologue_os(MACRO_PROT_ARGS) |
|
Line 391 macro_prologue_os(MACRO_PROT_ARGS) |
|
int lastarg, j; |
int lastarg, j; |
char *args[MDOC_LINEARG_MAX]; |
char *args[MDOC_LINEARG_MAX]; |
|
|
|
/* FIXME: if we use `Os' again... ? */ |
|
|
if (SEC_PROLOGUE != mdoc->sec_lastn) |
if (SEC_PROLOGUE != mdoc->sec_lastn) |
return(mdoc_err(mdoc, tok, ppos, ERR_SEC_NPROLOGUE)); |
return(mdoc_err(mdoc, tok, ppos, ERR_SEC_NPROLOGUE)); |
if (0 == mdoc->meta.title[0]) |
if (0 == mdoc->meta.title[0]) |
|
|
int |
int |
macro_constant(MACRO_PROT_ARGS) |
macro_constant(MACRO_PROT_ARGS) |
{ |
{ |
int lastarg, j; |
int lastarg, j, fl; |
char *args[MDOC_LINEARG_MAX]; |
char *args[MDOC_LINEARG_MAX]; |
|
|
if (SEC_PROLOGUE == mdoc->sec_lastn) |
if (SEC_PROLOGUE == mdoc->sec_lastn) |
return(mdoc_err(mdoc, tok, ppos, ERR_SEC_PROLOGUE)); |
return(mdoc_err(mdoc, tok, ppos, ERR_SEC_PROLOGUE)); |
|
|
j = 0; |
j = fl = 0; |
lastarg = ppos; |
lastarg = ppos; |
|
if (MDOC_QUOTABLE & mdoc_macros[tok].flags) |
|
fl = ARGS_QUOTED; |
|
|
again: |
again: |
if (j == MDOC_LINEARG_MAX) |
if (j == MDOC_LINEARG_MAX) |
|
|
|
|
lastarg = *pos; |
lastarg = *pos; |
|
|
switch (mdoc_args(mdoc, tok, pos, buf, 0, &args[j])) { |
switch (mdoc_args(mdoc, tok, pos, buf, fl, &args[j])) { |
case (ARGS_ERROR): |
case (ARGS_ERROR): |
return(0); |
return(0); |
case (ARGS_WORD): |
case (ARGS_WORD): |
Line 1004 macro_constant_argv(MACRO_PROT_ARGS) |
|
Line 989 macro_constant_argv(MACRO_PROT_ARGS) |
|
c = append_constarg(mdoc, tok, ppos, j, argv); |
c = append_constarg(mdoc, tok, ppos, j, argv); |
mdoc_argv_free(j, argv); |
mdoc_argv_free(j, argv); |
return(c); |
return(c); |
|
} |
|
|
|
|
|
int |
|
macro_obsolete(MACRO_PROT_ARGS) |
|
{ |
|
|
|
return(mdoc_warn(mdoc, tok, ppos, WARN_IGN_OBSOLETE)); |
} |
} |