version 1.150, 2014/11/28 03:14:18 |
version 1.151, 2014/11/28 04:47:03 |
Line 40 enum rew { /* see rew_dohalt() */ |
|
Line 40 enum rew { /* see rew_dohalt() */ |
|
REWIND_ERROR |
REWIND_ERROR |
}; |
}; |
|
|
static int blk_full(MACRO_PROT_ARGS); |
static void blk_full(MACRO_PROT_ARGS); |
static int blk_exp_close(MACRO_PROT_ARGS); |
static void blk_exp_close(MACRO_PROT_ARGS); |
static int blk_part_exp(MACRO_PROT_ARGS); |
static void blk_part_exp(MACRO_PROT_ARGS); |
static int blk_part_imp(MACRO_PROT_ARGS); |
static void blk_part_imp(MACRO_PROT_ARGS); |
static int ctx_synopsis(MACRO_PROT_ARGS); |
static void ctx_synopsis(MACRO_PROT_ARGS); |
static int in_line_eoln(MACRO_PROT_ARGS); |
static void in_line_eoln(MACRO_PROT_ARGS); |
static int in_line_argn(MACRO_PROT_ARGS); |
static void in_line_argn(MACRO_PROT_ARGS); |
static int in_line(MACRO_PROT_ARGS); |
static void in_line(MACRO_PROT_ARGS); |
static int phrase_ta(MACRO_PROT_ARGS); |
static void phrase_ta(MACRO_PROT_ARGS); |
|
|
static void dword(struct mdoc *, int, int, const char *, |
static void dword(struct mdoc *, int, int, const char *, |
enum mdelim, int); |
enum mdelim, int); |
Line 57 static enum mdoct lookup(enum mdoct, const char *); |
|
Line 57 static enum mdoct lookup(enum mdoct, const char *); |
|
static enum mdoct lookup_raw(const char *); |
static enum mdoct lookup_raw(const char *); |
static int make_pending(struct mdoc_node *, enum mdoct, |
static int make_pending(struct mdoc_node *, enum mdoct, |
struct mdoc *, int, int); |
struct mdoc *, int, int); |
static int phrase(struct mdoc *, int, int, char *); |
static void phrase(struct mdoc *, int, int, char *); |
static enum mdoct rew_alt(enum mdoct); |
static enum mdoct rew_alt(enum mdoct); |
static enum rew rew_dohalt(enum mdoct, enum mdoc_type, |
static enum rew rew_dohalt(enum mdoct, enum mdoc_type, |
const struct mdoc_node *); |
const struct mdoc_node *); |
Line 218 const struct mdoc_macro * const mdoc_macros = __mdoc_m |
|
Line 218 const struct mdoc_macro * const mdoc_macros = __mdoc_m |
|
* closing out open [implicit] scopes. Obviously, open explicit scopes |
* closing out open [implicit] scopes. Obviously, open explicit scopes |
* are errors. |
* are errors. |
*/ |
*/ |
int |
void |
mdoc_macroend(struct mdoc *mdoc) |
mdoc_macroend(struct mdoc *mdoc) |
{ |
{ |
struct mdoc_node *n; |
struct mdoc_node *n; |
|
|
/* Scan for open explicit scopes. */ |
/* Scan for open explicit scopes. */ |
|
|
n = MDOC_VALID & mdoc->last->flags ? |
n = mdoc->last->flags & MDOC_VALID ? |
mdoc->last->parent : mdoc->last; |
mdoc->last->parent : mdoc->last; |
|
|
for ( ; n; n = n->parent) |
for ( ; n; n = n->parent) |
if (MDOC_BLOCK == n->type && |
if (n->type == MDOC_BLOCK && |
MDOC_EXPLICIT & mdoc_macros[n->tok].flags) |
mdoc_macros[n->tok].flags & MDOC_EXPLICIT) |
mandoc_msg(MANDOCERR_BLK_NOEND, mdoc->parse, |
mandoc_msg(MANDOCERR_BLK_NOEND, mdoc->parse, |
n->line, n->pos, mdoc_macronames[n->tok]); |
n->line, n->pos, mdoc_macronames[n->tok]); |
|
|
/* Rewind to the first. */ |
/* Rewind to the first. */ |
|
|
rew_last(mdoc, mdoc->first); |
rew_last(mdoc, mdoc->first); |
return(1); |
|
} |
} |
|
|
/* |
/* |
Line 668 append_delims(struct mdoc *mdoc, int line, int *pos, c |
|
Line 667 append_delims(struct mdoc *mdoc, int line, int *pos, c |
|
/* |
/* |
* Close out block partial/full explicit. |
* Close out block partial/full explicit. |
*/ |
*/ |
static int |
static void |
blk_exp_close(MACRO_PROT_ARGS) |
blk_exp_close(MACRO_PROT_ARGS) |
{ |
{ |
struct mdoc_node *body; /* Our own body. */ |
struct mdoc_node *body; /* Our own body. */ |
Line 689 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 688 blk_exp_close(MACRO_PROT_ARGS) |
|
break; |
break; |
case MDOC_Ek: |
case MDOC_Ek: |
mdoc->flags &= ~MDOC_KEEP; |
mdoc->flags &= ~MDOC_KEEP; |
|
/* FALLTHROUGH */ |
default: |
default: |
maxargs = 0; |
maxargs = 0; |
break; |
break; |
Line 698 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 698 blk_exp_close(MACRO_PROT_ARGS) |
|
* Search backwards for beginnings of blocks, |
* Search backwards for beginnings of blocks, |
* both of our own and of pending sub-blocks. |
* both of our own and of pending sub-blocks. |
*/ |
*/ |
|
|
atok = rew_alt(tok); |
atok = rew_alt(tok); |
body = endbody = later = NULL; |
body = endbody = later = NULL; |
for (n = mdoc->last; n; n = n->parent) { |
for (n = mdoc->last; n; n = n->parent) { |
Line 705 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 706 blk_exp_close(MACRO_PROT_ARGS) |
|
continue; |
continue; |
|
|
/* Remember the start of our own body. */ |
/* Remember the start of our own body. */ |
|
|
if (n->type == MDOC_BODY && atok == n->tok) { |
if (n->type == MDOC_BODY && atok == n->tok) { |
if (n->end == ENDBODY_NOT) |
if (n->end == ENDBODY_NOT) |
body = n; |
body = n; |
Line 721 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 723 blk_exp_close(MACRO_PROT_ARGS) |
|
* When there is no pending sub block, |
* When there is no pending sub block, |
* just proceed to closing out. |
* just proceed to closing out. |
*/ |
*/ |
|
|
if (later == NULL) |
if (later == NULL) |
break; |
break; |
|
|
Line 729 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 732 blk_exp_close(MACRO_PROT_ARGS) |
|
* postpone closing out the current block |
* postpone closing out the current block |
* until the rew_sub() closing out the sub-block. |
* until the rew_sub() closing out the sub-block. |
*/ |
*/ |
|
|
make_pending(later, tok, mdoc, line, ppos); |
make_pending(later, tok, mdoc, line, ppos); |
|
|
/* |
/* |
* Mark the place where the formatting - but not |
* Mark the place where the formatting - but not |
* the scope - of the current block ends. |
* the scope - of the current block ends. |
*/ |
*/ |
|
|
mdoc_endbody_alloc(mdoc, line, ppos, |
mdoc_endbody_alloc(mdoc, line, ppos, |
atok, body, ENDBODY_SPACE); |
atok, body, ENDBODY_SPACE); |
|
|
|
/* |
|
* If a block closing macro taking arguments |
|
* breaks another block, put the arguments |
|
* into the end marker and remeber the |
|
* end marker in order to close it out. |
|
*/ |
|
|
if (maxargs) { |
if (maxargs) { |
endbody = mdoc->last; |
endbody = mdoc->last; |
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
Line 749 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 762 blk_exp_close(MACRO_PROT_ARGS) |
|
* open explicit block, or, in case there are only |
* open explicit block, or, in case there are only |
* implicit ones, the first open implicit block. |
* implicit ones, the first open implicit block. |
*/ |
*/ |
|
|
if (later && |
if (later && |
mdoc_macros[later->tok].flags & MDOC_EXPLICIT) |
mdoc_macros[later->tok].flags & MDOC_EXPLICIT) |
continue; |
continue; |
if (n->tok != MDOC_It) |
if (n->tok != MDOC_It) |
later = n; |
later = n; |
} |
} |
|
rew_sub(MDOC_BODY, mdoc, tok, line, ppos); |
|
|
if ( ! (mdoc_macros[tok].flags & MDOC_PARSED)) { |
if ( ! (mdoc_macros[tok].flags & MDOC_PARSED)) { |
if (buf[*pos] != '\0') |
if (buf[*pos] != '\0') |
Line 762 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 777 blk_exp_close(MACRO_PROT_ARGS) |
|
mdoc->parse, line, ppos, |
mdoc->parse, line, ppos, |
"%s %s", mdoc_macronames[tok], |
"%s %s", mdoc_macronames[tok], |
buf + *pos); |
buf + *pos); |
rew_sub(MDOC_BODY, mdoc, tok, line, ppos); |
|
rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos); |
rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos); |
return(1); |
return; |
} |
} |
rew_sub(MDOC_BODY, mdoc, tok, line, ppos); |
|
|
|
if (maxargs && endbody == NULL) { |
if (maxargs && endbody == NULL) { |
if (n == NULL) { |
if (n == NULL) { |
Line 811 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 824 blk_exp_close(MACRO_PROT_ARGS) |
|
rew_last(mdoc, endbody); |
rew_last(mdoc, endbody); |
flushed = 1; |
flushed = 1; |
} |
} |
|
|
mdoc->flags &= ~MDOC_NEWLINE; |
mdoc->flags &= ~MDOC_NEWLINE; |
|
mdoc_macro(mdoc, ntok, line, lastarg, pos, buf); |
if ( ! mdoc_macro(mdoc, ntok, line, lastarg, pos, buf)) |
|
return(0); |
|
break; |
break; |
} |
} |
|
|
Line 827 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 837 blk_exp_close(MACRO_PROT_ARGS) |
|
} |
} |
if (nl) |
if (nl) |
append_delims(mdoc, line, pos, buf); |
append_delims(mdoc, line, pos, buf); |
return(1); |
|
} |
} |
|
|
static int |
static void |
in_line(MACRO_PROT_ARGS) |
in_line(MACRO_PROT_ARGS) |
{ |
{ |
int la, scope, cnt, firstarg, mayopen, nc, nl; |
int la, scope, cnt, firstarg, mayopen, nc, nl; |
Line 870 in_line(MACRO_PROT_ARGS) |
|
Line 879 in_line(MACRO_PROT_ARGS) |
|
for (arg = NULL;; ) { |
for (arg = NULL;; ) { |
la = *pos; |
la = *pos; |
av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
|
if (av == ARGV_ARG) |
if (ARGV_WORD == av) { |
|
*pos = la; |
|
break; |
|
} |
|
if (ARGV_EOLN == av) |
|
break; |
|
if (ARGV_ARG == av) |
|
continue; |
continue; |
|
if (av == ARGV_WORD) |
mdoc_argv_free(arg); |
*pos = la; |
return(0); |
break; |
} |
} |
|
|
d = DELIM_NONE; |
d = DELIM_NONE; |
Line 938 in_line(MACRO_PROT_ARGS) |
|
Line 940 in_line(MACRO_PROT_ARGS) |
|
mdoc->parse, line, ppos, |
mdoc->parse, line, ppos, |
mdoc_macronames[tok]); |
mdoc_macronames[tok]); |
} |
} |
|
mdoc_macro(mdoc, ntok, line, la, pos, buf); |
if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) |
|
return(0); |
|
if (nl) |
if (nl) |
append_delims(mdoc, line, pos, buf); |
append_delims(mdoc, line, pos, buf); |
return(1); |
return; |
} |
} |
|
|
/* |
/* |
Line 1029 in_line(MACRO_PROT_ARGS) |
|
Line 1029 in_line(MACRO_PROT_ARGS) |
|
} |
} |
if (nl) |
if (nl) |
append_delims(mdoc, line, pos, buf); |
append_delims(mdoc, line, pos, buf); |
return(1); |
|
} |
} |
|
|
static int |
static void |
blk_full(MACRO_PROT_ARGS) |
blk_full(MACRO_PROT_ARGS) |
{ |
{ |
int la, nl, nparsed; |
int la, nl, nparsed; |
Line 1059 blk_full(MACRO_PROT_ARGS) |
|
Line 1058 blk_full(MACRO_PROT_ARGS) |
|
line, ppos, "It %s", buf + *pos); |
line, ppos, "It %s", buf + *pos); |
mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL); |
mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL); |
rew_elem(mdoc, MDOC_br); |
rew_elem(mdoc, MDOC_br); |
return(1); |
return; |
} |
} |
} |
} |
|
|
Line 1082 blk_full(MACRO_PROT_ARGS) |
|
Line 1081 blk_full(MACRO_PROT_ARGS) |
|
for (arg = NULL;; ) { |
for (arg = NULL;; ) { |
la = *pos; |
la = *pos; |
av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
|
if (av == ARGV_ARG) |
if (ARGV_WORD == av) { |
|
*pos = la; |
|
break; |
|
} |
|
|
|
if (ARGV_EOLN == av) |
|
break; |
|
if (ARGV_ARG == av) |
|
continue; |
continue; |
|
if (av == ARGV_WORD) |
mdoc_argv_free(arg); |
*pos = la; |
return(0); |
break; |
} |
} |
|
|
mdoc_block_alloc(mdoc, line, ppos, tok, arg); |
mdoc_block_alloc(mdoc, line, ppos, tok, arg); |
Line 1104 blk_full(MACRO_PROT_ARGS) |
|
Line 1095 blk_full(MACRO_PROT_ARGS) |
|
* Exception: Heads of `It' macros in `-diag' lists are not |
* Exception: Heads of `It' macros in `-diag' lists are not |
* parsed, even though `It' macros in general are parsed. |
* parsed, even though `It' macros in general are parsed. |
*/ |
*/ |
|
|
nparsed = tok == MDOC_It && |
nparsed = tok == MDOC_It && |
mdoc->last->parent->tok == MDOC_Bl && |
mdoc->last->parent->tok == MDOC_Bl && |
mdoc->last->parent->norm->Bl.type == LIST_diag; |
mdoc->last->parent->norm->Bl.type == LIST_diag; |
Line 1167 blk_full(MACRO_PROT_ARGS) |
|
Line 1159 blk_full(MACRO_PROT_ARGS) |
|
if (ac == ARGS_PHRASE || |
if (ac == ARGS_PHRASE || |
ac == ARGS_PEND || |
ac == ARGS_PEND || |
ac == ARGS_PPHRASE) { |
ac == ARGS_PPHRASE) { |
|
|
/* |
/* |
* If we haven't opened a body yet, rewind the |
* If we haven't opened a body yet, rewind the |
* head; if we have, rewind that instead. |
* head; if we have, rewind that instead. |
Line 1174 blk_full(MACRO_PROT_ARGS) |
|
Line 1167 blk_full(MACRO_PROT_ARGS) |
|
|
|
rew_sub(body ? MDOC_BODY : MDOC_HEAD, |
rew_sub(body ? MDOC_BODY : MDOC_HEAD, |
mdoc, tok, line, ppos); |
mdoc, tok, line, ppos); |
|
|
/* Then allocate our body context. */ |
|
|
|
body = mdoc_body_alloc(mdoc, line, ppos, tok); |
body = mdoc_body_alloc(mdoc, line, ppos, tok); |
|
|
/* |
/* |
Line 1189 blk_full(MACRO_PROT_ARGS) |
|
Line 1179 blk_full(MACRO_PROT_ARGS) |
|
mdoc->flags |= MDOC_PPHRASE; |
mdoc->flags |= MDOC_PPHRASE; |
if (ac == ARGS_PEND && lac == ARGS_PPHRASE) |
if (ac == ARGS_PEND && lac == ARGS_PPHRASE) |
mdoc->flags |= MDOC_PPHRASE; |
mdoc->flags |= MDOC_PPHRASE; |
|
phrase(mdoc, line, la, buf); |
if ( ! phrase(mdoc, line, la, buf)) |
|
return(0); |
|
|
|
mdoc->flags &= ~MDOC_PPHRASE; |
mdoc->flags &= ~MDOC_PPHRASE; |
continue; |
continue; |
} |
} |
Line 1200 blk_full(MACRO_PROT_ARGS) |
|
Line 1187 blk_full(MACRO_PROT_ARGS) |
|
ntok = nparsed || ac == ARGS_QWORD ? |
ntok = nparsed || ac == ARGS_QWORD ? |
MDOC_MAX : lookup(tok, p); |
MDOC_MAX : lookup(tok, p); |
|
|
if (ntok == MDOC_MAX) { |
if (ntok != MDOC_MAX) { |
dword(mdoc, line, la, p, DELIM_MAX, |
mdoc_macro(mdoc, ntok, line, la, pos, buf); |
MDOC_JOIN & mdoc_macros[tok].flags); |
break; |
continue; |
|
} |
} |
|
dword(mdoc, line, la, p, DELIM_MAX, |
if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) |
MDOC_JOIN & mdoc_macros[tok].flags); |
return(0); |
|
break; |
|
} |
} |
|
|
if (head == NULL) |
if (head == NULL) |
head = mdoc_head_alloc(mdoc, line, ppos, tok); |
head = mdoc_head_alloc(mdoc, line, ppos, tok); |
if (nl) |
if (nl) |
append_delims(mdoc, line, pos, buf); |
append_delims(mdoc, line, pos, buf); |
|
if (body != NULL) |
/* If we've already opened our body, exit now. */ |
|
|
|
if (NULL != body) |
|
goto out; |
goto out; |
|
|
/* |
/* |
Line 1228 blk_full(MACRO_PROT_ARGS) |
|
Line 1209 blk_full(MACRO_PROT_ARGS) |
|
* sub-block. |
* sub-block. |
*/ |
*/ |
for (n = mdoc->last; n && n != head; n = n->parent) { |
for (n = mdoc->last; n && n != head; n = n->parent) { |
if (MDOC_BLOCK == n->type && |
if (n->type == MDOC_BLOCK && |
MDOC_EXPLICIT & mdoc_macros[n->tok].flags && |
mdoc_macros[n->tok].flags & MDOC_EXPLICIT && |
! (MDOC_VALID & n->flags)) { |
! (n->flags & MDOC_VALID)) { |
n->pending = head; |
n->pending = head; |
return(1); |
return; |
} |
} |
} |
} |
|
|
Line 1240 blk_full(MACRO_PROT_ARGS) |
|
Line 1221 blk_full(MACRO_PROT_ARGS) |
|
|
|
rew_sub(MDOC_HEAD, mdoc, tok, line, ppos); |
rew_sub(MDOC_HEAD, mdoc, tok, line, ppos); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
|
|
out: |
out: |
if (mdoc->flags & MDOC_FREECOL) { |
if (mdoc->flags & MDOC_FREECOL) { |
rew_sub(MDOC_BODY, mdoc, tok, line, ppos); |
rew_sub(MDOC_BODY, mdoc, tok, line, ppos); |
rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos); |
rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos); |
mdoc->flags &= ~MDOC_FREECOL; |
mdoc->flags &= ~MDOC_FREECOL; |
} |
} |
return(1); |
|
} |
} |
|
|
static int |
static void |
blk_part_imp(MACRO_PROT_ARGS) |
blk_part_imp(MACRO_PROT_ARGS) |
{ |
{ |
int la, nl; |
int la, nl; |
Line 1299 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1278 blk_part_imp(MACRO_PROT_ARGS) |
|
|
|
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p); |
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p); |
|
|
if (ntok == MDOC_MAX) { |
if (ntok != MDOC_MAX) { |
dword(mdoc, line, la, p, DELIM_MAX, |
mdoc_macro(mdoc, ntok, line, la, pos, buf); |
MDOC_JOIN & mdoc_macros[tok].flags); |
break; |
continue; |
|
} |
} |
|
dword(mdoc, line, la, p, DELIM_MAX, |
if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) |
MDOC_JOIN & mdoc_macros[tok].flags); |
return(0); |
|
break; |
|
} |
} |
|
|
/* Clean-ups to leave in a consistent state. */ |
|
|
|
if (body == NULL) |
if (body == NULL) |
body = mdoc_body_alloc(mdoc, line, ppos, tok); |
body = mdoc_body_alloc(mdoc, line, ppos, tok); |
|
|
Line 1320 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1293 blk_part_imp(MACRO_PROT_ARGS) |
|
* postpone closing out the current block |
* postpone closing out the current block |
* until the rew_sub() call closing out the sub-block. |
* until the rew_sub() call closing out the sub-block. |
*/ |
*/ |
|
|
for (n = mdoc->last; n && n != body && n != blk->parent; |
for (n = mdoc->last; n && n != body && n != blk->parent; |
n = n->parent) { |
n = n->parent) { |
if (n->type == MDOC_BLOCK && |
if (n->type == MDOC_BLOCK && |
Line 1328 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1302 blk_part_imp(MACRO_PROT_ARGS) |
|
make_pending(n, tok, mdoc, line, ppos); |
make_pending(n, tok, mdoc, line, ppos); |
mdoc_endbody_alloc(mdoc, line, ppos, |
mdoc_endbody_alloc(mdoc, line, ppos, |
tok, body, ENDBODY_NOSPACE); |
tok, body, ENDBODY_NOSPACE); |
return(1); |
return; |
} |
} |
} |
} |
assert(n == body); |
assert(n == body); |
rew_sub(MDOC_BODY, mdoc, tok, line, ppos); |
rew_sub(MDOC_BODY, mdoc, tok, line, ppos); |
|
|
/* Standard appending of delimiters. */ |
|
|
|
if (nl) |
if (nl) |
append_delims(mdoc, line, pos, buf); |
append_delims(mdoc, line, pos, buf); |
|
|
/* Rewind scope, if applicable. */ |
|
|
|
rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos); |
rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos); |
|
|
/* Move trailing .Ns out of scope. */ |
/* Move trailing .Ns out of scope. */ |
Line 1349 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1317 blk_part_imp(MACRO_PROT_ARGS) |
|
/* Do nothing. */ ; |
/* Do nothing. */ ; |
if (n && n->tok == MDOC_Ns) |
if (n && n->tok == MDOC_Ns) |
mdoc_node_relink(mdoc, n); |
mdoc_node_relink(mdoc, n); |
|
|
return(1); |
|
} |
} |
|
|
static int |
static void |
blk_part_exp(MACRO_PROT_ARGS) |
blk_part_exp(MACRO_PROT_ARGS) |
{ |
{ |
int la, nl; |
int la, nl; |
Line 1410 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1376 blk_part_exp(MACRO_PROT_ARGS) |
|
assert(head != NULL && body != NULL); |
assert(head != NULL && body != NULL); |
|
|
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p); |
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p); |
if (ntok == MDOC_MAX) { |
if (ntok != MDOC_MAX) { |
dword(mdoc, line, la, p, DELIM_MAX, |
mdoc_macro(mdoc, ntok, line, la, pos, buf); |
MDOC_JOIN & mdoc_macros[tok].flags); |
break; |
continue; |
|
} |
} |
if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) |
dword(mdoc, line, la, p, DELIM_MAX, |
return(0); |
MDOC_JOIN & mdoc_macros[tok].flags); |
break; |
|
} |
} |
|
|
/* Clean-up to leave in a consistent state. */ |
/* Clean-up to leave in a consistent state. */ |
Line 1429 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1393 blk_part_exp(MACRO_PROT_ARGS) |
|
rew_sub(MDOC_HEAD, mdoc, tok, line, ppos); |
rew_sub(MDOC_HEAD, mdoc, tok, line, ppos); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
mdoc_body_alloc(mdoc, line, ppos, tok); |
} |
} |
|
|
/* Standard appending of delimiters. */ |
|
|
|
if (nl) |
if (nl) |
append_delims(mdoc, line, pos, buf); |
append_delims(mdoc, line, pos, buf); |
return(1); |
|
} |
} |
|
|
static int |
static void |
in_line_argn(MACRO_PROT_ARGS) |
in_line_argn(MACRO_PROT_ARGS) |
{ |
{ |
int la, flushed, j, maxargs, nl; |
int la, flushed, j, maxargs, nl; |
Line 1480 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1440 in_line_argn(MACRO_PROT_ARGS) |
|
for (arg = NULL; ; ) { |
for (arg = NULL; ; ) { |
la = *pos; |
la = *pos; |
av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
|
if (av == ARGV_ARG) |
if (ARGV_WORD == av) { |
|
*pos = la; |
|
break; |
|
} |
|
|
|
if (ARGV_EOLN == av) |
|
break; |
|
if (ARGV_ARG == av) |
|
continue; |
continue; |
|
if (av == ARGV_WORD) |
mdoc_argv_free(arg); |
*pos = la; |
return(0); |
break; |
} |
} |
|
|
for (flushed = j = 0; ; ) { |
for (flushed = j = 0; ; ) { |
Line 1520 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1472 in_line_argn(MACRO_PROT_ARGS) |
|
if ( ! flushed) |
if ( ! flushed) |
rew_elem(mdoc, tok); |
rew_elem(mdoc, tok); |
flushed = 1; |
flushed = 1; |
if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) |
mdoc_macro(mdoc, ntok, line, la, pos, buf); |
return(0); |
|
j++; |
j++; |
break; |
break; |
} |
} |
Line 1540 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1491 in_line_argn(MACRO_PROT_ARGS) |
|
|
|
if (j == 0) |
if (j == 0) |
mdoc_elem_alloc(mdoc, line, ppos, tok, arg); |
mdoc_elem_alloc(mdoc, line, ppos, tok, arg); |
|
|
/* Close out in a consistent state. */ |
|
|
|
if ( ! flushed) |
if ( ! flushed) |
rew_elem(mdoc, tok); |
rew_elem(mdoc, tok); |
if (nl) |
if (nl) |
append_delims(mdoc, line, pos, buf); |
append_delims(mdoc, line, pos, buf); |
return(1); |
|
} |
} |
|
|
static int |
static void |
in_line_eoln(MACRO_PROT_ARGS) |
in_line_eoln(MACRO_PROT_ARGS) |
{ |
{ |
int la; |
int la; |
Line 1570 in_line_eoln(MACRO_PROT_ARGS) |
|
Line 1517 in_line_eoln(MACRO_PROT_ARGS) |
|
for (arg = NULL; ; ) { |
for (arg = NULL; ; ) { |
la = *pos; |
la = *pos; |
av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
av = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
|
if (av == ARGV_ARG) |
if (ARGV_WORD == av) { |
|
*pos = la; |
|
break; |
|
} |
|
if (ARGV_EOLN == av) |
|
break; |
|
if (ARGV_ARG == av) |
|
continue; |
continue; |
|
if (av == ARGV_WORD) |
mdoc_argv_free(arg); |
*pos = la; |
return(0); |
break; |
} |
} |
|
|
/* Open element scope. */ |
/* Open element scope. */ |
Line 1598 in_line_eoln(MACRO_PROT_ARGS) |
|
Line 1538 in_line_eoln(MACRO_PROT_ARGS) |
|
|
|
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p); |
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p); |
|
|
if (ntok == MDOC_MAX) { |
if (ntok != MDOC_MAX) { |
dword(mdoc, line, la, p, DELIM_MAX, |
rew_elem(mdoc, tok); |
MDOC_JOIN & mdoc_macros[tok].flags); |
mdoc_macro(mdoc, ntok, line, la, pos, buf); |
continue; |
return; |
} |
} |
rew_elem(mdoc, tok); |
dword(mdoc, line, la, p, DELIM_MAX, |
return(mdoc_macro(mdoc, ntok, line, la, pos, buf)); |
MDOC_JOIN & mdoc_macros[tok].flags); |
} |
} |
|
|
/* Close out (no delimiters). */ |
/* Close out (no delimiters). */ |
|
|
rew_elem(mdoc, tok); |
rew_elem(mdoc, tok); |
return(1); |
|
} |
} |
|
|
static int |
static void |
ctx_synopsis(MACRO_PROT_ARGS) |
ctx_synopsis(MACRO_PROT_ARGS) |
{ |
{ |
int nl; |
|
|
|
nl = MDOC_NEWLINE & mdoc->flags; |
if (~mdoc->flags & (MDOC_SYNOPSIS | MDOC_NEWLINE)) |
|
in_line(mdoc, tok, line, ppos, pos, buf); |
/* If we're not in the SYNOPSIS, go straight to in-line. */ |
else if (tok == MDOC_Nm) |
if ( ! (MDOC_SYNOPSIS & mdoc->flags)) |
blk_full(mdoc, tok, line, ppos, pos, buf); |
return(in_line(mdoc, tok, line, ppos, pos, buf)); |
else { |
|
assert(tok == MDOC_Vt); |
/* If we're a nested call, same place. */ |
blk_part_imp(mdoc, tok, line, ppos, pos, buf); |
if ( ! nl) |
} |
return(in_line(mdoc, tok, line, ppos, pos, buf)); |
|
|
|
/* |
|
* XXX: this will open a block scope; however, if later we end |
|
* up formatting the block scope, then child nodes will inherit |
|
* the formatting. Be careful. |
|
*/ |
|
if (MDOC_Nm == tok) |
|
return(blk_full(mdoc, tok, line, ppos, pos, buf)); |
|
assert(MDOC_Vt == tok); |
|
return(blk_part_imp(mdoc, tok, line, ppos, pos, buf)); |
|
} |
} |
|
|
/* |
/* |
Line 1644 ctx_synopsis(MACRO_PROT_ARGS) |
|
Line 1571 ctx_synopsis(MACRO_PROT_ARGS) |
|
* They're unusual because they're basically free-form text until a |
* They're unusual because they're basically free-form text until a |
* macro is encountered. |
* macro is encountered. |
*/ |
*/ |
static int |
static void |
phrase(struct mdoc *mdoc, int line, int ppos, char *buf) |
phrase(struct mdoc *mdoc, int line, int ppos, char *buf) |
{ |
{ |
int la, pos; |
int la, pos; |
Line 1661 phrase(struct mdoc *mdoc, int line, int ppos, char *bu |
|
Line 1588 phrase(struct mdoc *mdoc, int line, int ppos, char *bu |
|
|
|
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup_raw(p); |
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup_raw(p); |
|
|
if (ntok == MDOC_MAX) { |
if (ntok != MDOC_MAX) { |
dword(mdoc, line, la, p, DELIM_MAX, 1); |
mdoc_macro(mdoc, ntok, line, la, &pos, buf); |
continue; |
append_delims(mdoc, line, &pos, buf); |
|
return; |
} |
} |
|
dword(mdoc, line, la, p, DELIM_MAX, 1); |
if ( ! mdoc_macro(mdoc, ntok, line, la, &pos, buf)) |
|
return(0); |
|
append_delims(mdoc, line, &pos, buf); |
|
return(1); |
|
} |
} |
|
|
return(1); |
|
} |
} |
|
|
static int |
static void |
phrase_ta(MACRO_PROT_ARGS) |
phrase_ta(MACRO_PROT_ARGS) |
{ |
{ |
struct mdoc_node *n; |
struct mdoc_node *n; |
Line 1685 phrase_ta(MACRO_PROT_ARGS) |
|
Line 1607 phrase_ta(MACRO_PROT_ARGS) |
|
char *p; |
char *p; |
|
|
/* Make sure we are in a column list or ignore this macro. */ |
/* Make sure we are in a column list or ignore this macro. */ |
|
|
n = mdoc->last; |
n = mdoc->last; |
while (NULL != n && MDOC_Bl != n->tok) |
while (n != NULL && n->tok != MDOC_Bl) |
n = n->parent; |
n = n->parent; |
if (NULL == n || LIST_column != n->norm->Bl.type) { |
if (n == NULL || n->norm->Bl.type != LIST_column) { |
mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse, |
mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse, |
line, ppos, "Ta"); |
line, ppos, "Ta"); |
return(1); |
return; |
} |
} |
|
|
/* Advance to the next column. */ |
/* Advance to the next column. */ |
Line 1707 phrase_ta(MACRO_PROT_ARGS) |
|
Line 1630 phrase_ta(MACRO_PROT_ARGS) |
|
|
|
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup_raw(p); |
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup_raw(p); |
|
|
if (ntok == MDOC_MAX) { |
if (ntok != MDOC_MAX) { |
dword(mdoc, line, la, p, DELIM_MAX, |
mdoc_macro(mdoc, ntok, line, la, pos, buf); |
MDOC_JOIN & mdoc_macros[tok].flags); |
append_delims(mdoc, line, pos, buf); |
continue; |
return; |
} |
} |
|
dword(mdoc, line, la, p, DELIM_MAX, |
if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf)) |
MDOC_JOIN & mdoc_macros[tok].flags); |
return(0); |
|
append_delims(mdoc, line, pos, buf); |
|
return(1); |
|
} |
} |
|
|
return(1); |
|
} |
} |