version 1.26, 2009/01/07 15:57:14 |
version 1.27, 2009/01/07 16:11:40 |
Line 35 static int rewind_expblock(struct mdoc *, int, int, |
|
Line 35 static int rewind_expblock(struct mdoc *, int, int, |
|
static int rewind_head(struct mdoc *, int, int); |
static int rewind_head(struct mdoc *, int, int); |
static int rewind_body(struct mdoc *, int, int, int); |
static int rewind_body(struct mdoc *, int, int, int); |
static int rewind_last(struct mdoc *, int, struct mdoc_node *); |
static int rewind_last(struct mdoc *, int, struct mdoc_node *); |
static int append_delims(struct mdoc *, int, int *, char *); |
static int append_delims(struct mdoc *, |
|
int, int, int *, char *); |
static int lookup(struct mdoc *, int, const char *); |
static int lookup(struct mdoc *, int, const char *); |
|
|
|
|
Line 181 rewind_impblock(struct mdoc *mdoc, int ppos, int tok) |
|
Line 182 rewind_impblock(struct mdoc *mdoc, int ppos, int tok) |
|
|
|
|
|
static int |
static int |
append_delims(struct mdoc *mdoc, int tok, int *pos, char *buf) |
append_delims(struct mdoc *mdoc, int tok, |
|
int line, int *pos, char *buf) |
{ |
{ |
int c, lastarg; |
int c, lastarg; |
char *p; |
char *p; |
Line 197 append_delims(struct mdoc *mdoc, int tok, int *pos, ch |
|
Line 199 append_delims(struct mdoc *mdoc, int tok, int *pos, ch |
|
else if (ARGS_EOLN == c) |
else if (ARGS_EOLN == c) |
break; |
break; |
assert(mdoc_isdelim(p)); |
assert(mdoc_isdelim(p)); |
mdoc_word_alloc(mdoc, lastarg, p); |
mdoc_word_alloc(mdoc, line, lastarg, p); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
} |
} |
|
|
Line 287 macro_close_explicit(MACRO_PROT_ARGS) |
|
Line 289 macro_close_explicit(MACRO_PROT_ARGS) |
|
flushed = 0; |
flushed = 0; |
|
|
if (maxargs > 0) { |
if (maxargs > 0) { |
mdoc_tail_alloc(mdoc, ppos, tt); |
mdoc_tail_alloc(mdoc, line, ppos, tt); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
} |
} |
|
|
Line 319 macro_close_explicit(MACRO_PROT_ARGS) |
|
Line 321 macro_close_explicit(MACRO_PROT_ARGS) |
|
break; |
break; |
} |
} |
|
|
mdoc_word_alloc(mdoc, lastarg, p); |
mdoc_word_alloc(mdoc, line, lastarg, p); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
} |
} |
|
|
Line 332 macro_close_explicit(MACRO_PROT_ARGS) |
|
Line 334 macro_close_explicit(MACRO_PROT_ARGS) |
|
|
|
if (ppos > 1) |
if (ppos > 1) |
return(1); |
return(1); |
return(append_delims(mdoc, tok, pos, buf)); |
return(append_delims(mdoc, tok, line, pos, buf)); |
} |
} |
|
|
|
|
Line 376 macro_text(MACRO_PROT_ARGS) |
|
Line 378 macro_text(MACRO_PROT_ARGS) |
|
if (MDOC_QUOTABLE & mdoc_macros[tok].flags) |
if (MDOC_QUOTABLE & mdoc_macros[tok].flags) |
fl |= ARGS_QUOTED; |
fl |= ARGS_QUOTED; |
|
|
mdoc_elem_alloc(mdoc, lastarg, tok, argc, argv); |
mdoc_elem_alloc(mdoc, line, lastarg, tok, argc, argv); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
for (lastpunct = sz = 0; sz + argc < MDOC_LINEARG_MAX; sz++) { |
for (lastpunct = sz = 0; sz + argc < MDOC_LINEARG_MAX; sz++) { |
lastarg = *pos; |
lastarg = *pos; |
|
|
if (lastpunct) { |
if (lastpunct) { |
mdoc_elem_alloc(mdoc, lastarg, tok, argc, argv); |
mdoc_elem_alloc(mdoc, line, lastarg, tok, argc, argv); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
lastpunct = 0; |
lastpunct = 0; |
} |
} |
Line 409 macro_text(MACRO_PROT_ARGS) |
|
Line 411 macro_text(MACRO_PROT_ARGS) |
|
return(0); |
return(0); |
if (ppos > 1) |
if (ppos > 1) |
return(1); |
return(1); |
return(append_delims(mdoc, tok, pos, buf)); |
return(append_delims(mdoc, tok, line, pos, buf)); |
} |
} |
|
|
if (mdoc_isdelim(p)) { |
if (mdoc_isdelim(p)) { |
Line 419 macro_text(MACRO_PROT_ARGS) |
|
Line 421 macro_text(MACRO_PROT_ARGS) |
|
} |
} |
lastpunct = 1; |
lastpunct = 1; |
} |
} |
mdoc_word_alloc(mdoc, lastarg, p); |
mdoc_word_alloc(mdoc, line, lastarg, p); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
} |
} |
|
|
Line 432 macro_text(MACRO_PROT_ARGS) |
|
Line 434 macro_text(MACRO_PROT_ARGS) |
|
return(0); |
return(0); |
if (ppos > 1) |
if (ppos > 1) |
return(1); |
return(1); |
return(append_delims(mdoc, tok, pos, buf)); |
return(append_delims(mdoc, tok, line, pos, buf)); |
} |
} |
|
|
|
|
Line 470 macro_scoped(MACRO_PROT_ARGS) |
|
Line 472 macro_scoped(MACRO_PROT_ARGS) |
|
return(0); |
return(0); |
} |
} |
|
|
mdoc_block_alloc(mdoc, ppos, tok, (size_t)argc, argv); |
mdoc_block_alloc(mdoc, line, ppos, tok, (size_t)argc, argv); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
mdoc_argv_free(argc, argv); |
mdoc_argv_free(argc, argv); |
|
|
if (0 == buf[*pos]) { |
if (0 == buf[*pos]) { |
mdoc_head_alloc(mdoc, ppos, tok); |
mdoc_head_alloc(mdoc, line, ppos, tok); |
if ( ! rewind_head(mdoc, ppos, tok)) |
if ( ! rewind_head(mdoc, ppos, tok)) |
return(0); |
return(0); |
mdoc_body_alloc(mdoc, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
return(1); |
return(1); |
} |
} |
|
|
mdoc_head_alloc(mdoc, ppos, tok); |
mdoc_head_alloc(mdoc, line, ppos, tok); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
for (j = 0; j < MDOC_LINEARG_MAX; j++) { |
for (j = 0; j < MDOC_LINEARG_MAX; j++) { |
Line 499 macro_scoped(MACRO_PROT_ARGS) |
|
Line 501 macro_scoped(MACRO_PROT_ARGS) |
|
break; |
break; |
|
|
if (MDOC_MAX == (c = lookup(mdoc, tok, p))) { |
if (MDOC_MAX == (c = lookup(mdoc, tok, p))) { |
mdoc_word_alloc(mdoc, lastarg, p); |
mdoc_word_alloc(mdoc, line, lastarg, p); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
continue; |
continue; |
} |
} |
Line 514 macro_scoped(MACRO_PROT_ARGS) |
|
Line 516 macro_scoped(MACRO_PROT_ARGS) |
|
|
|
if ( ! rewind_head(mdoc, ppos, tok)) |
if ( ! rewind_head(mdoc, ppos, tok)) |
return(0); |
return(0); |
if (1 == ppos && ! append_delims(mdoc, tok, pos, buf)) |
if (1 == ppos && ! append_delims(mdoc, tok, line, pos, buf)) |
return(0); |
return(0); |
|
|
mdoc_body_alloc(mdoc, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
return(1); |
return(1); |
Line 535 macro_scoped_line(MACRO_PROT_ARGS) |
|
Line 537 macro_scoped_line(MACRO_PROT_ARGS) |
|
int lastarg, c, j; |
int lastarg, c, j; |
char *p; |
char *p; |
|
|
mdoc_block_alloc(mdoc, ppos, tok, 0, NULL); |
mdoc_block_alloc(mdoc, line, ppos, tok, 0, NULL); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
mdoc_head_alloc(mdoc, ppos, tok); |
mdoc_head_alloc(mdoc, line, ppos, tok); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
/* XXX - no known argument macros. */ |
/* XXX - no known argument macros. */ |
Line 560 macro_scoped_line(MACRO_PROT_ARGS) |
|
Line 562 macro_scoped_line(MACRO_PROT_ARGS) |
|
break; |
break; |
|
|
if (MDOC_MAX == (c = lookup(mdoc, tok, p))) { |
if (MDOC_MAX == (c = lookup(mdoc, tok, p))) { |
mdoc_word_alloc(mdoc, lastarg, p); |
mdoc_word_alloc(mdoc, line, lastarg, p); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
continue; |
continue; |
} |
} |
Line 576 macro_scoped_line(MACRO_PROT_ARGS) |
|
Line 578 macro_scoped_line(MACRO_PROT_ARGS) |
|
if (1 == ppos) { |
if (1 == ppos) { |
if ( ! rewind_head(mdoc, ppos, tok)) |
if ( ! rewind_head(mdoc, ppos, tok)) |
return(0); |
return(0); |
if ( ! append_delims(mdoc, tok, pos, buf)) |
if ( ! append_delims(mdoc, tok, line, pos, buf)) |
return(0); |
return(0); |
} |
} |
return(rewind_impblock(mdoc, ppos, tok)); |
return(rewind_impblock(mdoc, ppos, tok)); |
Line 604 macro_constant_scoped(MACRO_PROT_ARGS) |
|
Line 606 macro_constant_scoped(MACRO_PROT_ARGS) |
|
if ( ! mdoc_valid_pre(mdoc, tok, ppos, 0, NULL)) |
if ( ! mdoc_valid_pre(mdoc, tok, ppos, 0, NULL)) |
return(0); |
return(0); |
|
|
mdoc_block_alloc(mdoc, ppos, tok, 0, NULL); |
mdoc_block_alloc(mdoc, line, ppos, tok, 0, NULL); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
if (0 == maxargs) { |
if (0 == maxargs) { |
mdoc_head_alloc(mdoc, ppos, tok); |
mdoc_head_alloc(mdoc, line, ppos, tok); |
if ( ! rewind_head(mdoc, ppos, tok)) |
if ( ! rewind_head(mdoc, ppos, tok)) |
return(0); |
return(0); |
mdoc_body_alloc(mdoc, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
flushed = 1; |
flushed = 1; |
} else |
} else |
mdoc_head_alloc(mdoc, ppos, tok); |
mdoc_head_alloc(mdoc, line, ppos, tok); |
|
|
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
Line 625 macro_constant_scoped(MACRO_PROT_ARGS) |
|
Line 627 macro_constant_scoped(MACRO_PROT_ARGS) |
|
if ( ! rewind_head(mdoc, ppos, tok)) |
if ( ! rewind_head(mdoc, ppos, tok)) |
return(0); |
return(0); |
flushed = 1; |
flushed = 1; |
mdoc_body_alloc(mdoc, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
} |
} |
|
|
Line 642 macro_constant_scoped(MACRO_PROT_ARGS) |
|
Line 644 macro_constant_scoped(MACRO_PROT_ARGS) |
|
if ( ! rewind_head(mdoc, ppos, tok)) |
if ( ! rewind_head(mdoc, ppos, tok)) |
return(0); |
return(0); |
flushed = 1; |
flushed = 1; |
mdoc_body_alloc(mdoc, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
} |
} |
if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf)) |
if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf)) |
Line 654 macro_constant_scoped(MACRO_PROT_ARGS) |
|
Line 656 macro_constant_scoped(MACRO_PROT_ARGS) |
|
if ( ! rewind_head(mdoc, ppos, tok)) |
if ( ! rewind_head(mdoc, ppos, tok)) |
return(0); |
return(0); |
flushed = 1; |
flushed = 1; |
mdoc_body_alloc(mdoc, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
} |
} |
|
|
mdoc_word_alloc(mdoc, lastarg, p); |
mdoc_word_alloc(mdoc, line, lastarg, p); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
} |
} |
|
|
Line 668 macro_constant_scoped(MACRO_PROT_ARGS) |
|
Line 670 macro_constant_scoped(MACRO_PROT_ARGS) |
|
if ( ! flushed) { |
if ( ! flushed) { |
if ( ! rewind_head(mdoc, ppos, tok)) |
if ( ! rewind_head(mdoc, ppos, tok)) |
return(0); |
return(0); |
mdoc_body_alloc(mdoc, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
} |
} |
|
|
if (ppos > 1) |
if (ppos > 1) |
return(1); |
return(1); |
return(append_delims(mdoc, tok, pos, buf)); |
return(append_delims(mdoc, tok, line, pos, buf)); |
} |
} |
|
|
|
|
Line 725 macro_constant_delimited(MACRO_PROT_ARGS) |
|
Line 727 macro_constant_delimited(MACRO_PROT_ARGS) |
|
return(0); |
return(0); |
} |
} |
|
|
mdoc_elem_alloc(mdoc, lastarg, tok, argc, argv); |
mdoc_elem_alloc(mdoc, line, lastarg, tok, argc, argv); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
mdoc_argv_free(argc, argv); |
mdoc_argv_free(argc, argv); |
Line 762 macro_constant_delimited(MACRO_PROT_ARGS) |
|
Line 764 macro_constant_delimited(MACRO_PROT_ARGS) |
|
flushed = 1; |
flushed = 1; |
} |
} |
|
|
mdoc_word_alloc(mdoc, lastarg, p); |
mdoc_word_alloc(mdoc, line, lastarg, p); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
} |
} |
|
|
Line 774 macro_constant_delimited(MACRO_PROT_ARGS) |
|
Line 776 macro_constant_delimited(MACRO_PROT_ARGS) |
|
|
|
if (ppos > 1) |
if (ppos > 1) |
return(1); |
return(1); |
return(append_delims(mdoc, tok, pos, buf)); |
return(append_delims(mdoc, tok, line, pos, buf)); |
} |
} |
|
|
|
|
Line 815 macro_constant(MACRO_PROT_ARGS) |
|
Line 817 macro_constant(MACRO_PROT_ARGS) |
|
return(mdoc_err(mdoc, tok, lastarg, ERR_ARGS_MANY)); |
return(mdoc_err(mdoc, tok, lastarg, ERR_ARGS_MANY)); |
} |
} |
|
|
mdoc_elem_alloc(mdoc, ppos, tok, argc, argv); |
mdoc_elem_alloc(mdoc, line, ppos, tok, argc, argv); |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
|
|
mdoc_argv_free(argc, argv); |
mdoc_argv_free(argc, argv); |
Line 828 macro_constant(MACRO_PROT_ARGS) |
|
Line 830 macro_constant(MACRO_PROT_ARGS) |
|
if (ARGS_EOLN == c) |
if (ARGS_EOLN == c) |
break; |
break; |
|
|
mdoc_word_alloc(mdoc, lastarg, p); |
mdoc_word_alloc(mdoc, line, lastarg, p); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
} |
} |
|
|