version 1.261, 2014/11/28 18:09:01 |
version 1.272, 2015/02/06 01:07:22 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> |
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 48 enum check_ineq { |
|
Line 48 enum check_ineq { |
|
CHECK_EQ |
CHECK_EQ |
}; |
}; |
|
|
enum check_lvl { |
|
CHECK_WARN, |
|
CHECK_ERROR, |
|
}; |
|
|
|
typedef void (*v_pre)(PRE_ARGS); |
typedef void (*v_pre)(PRE_ARGS); |
typedef void (*v_post)(POST_ARGS); |
typedef void (*v_post)(POST_ARGS); |
|
|
|
|
}; |
}; |
|
|
static void check_count(struct mdoc *, enum mdoc_type, |
static void check_count(struct mdoc *, enum mdoc_type, |
enum check_lvl, enum check_ineq, int); |
enum check_ineq, int); |
static void check_text(struct mdoc *, int, int, char *); |
static void check_text(struct mdoc *, int, int, char *); |
static void check_argv(struct mdoc *, |
static void check_argv(struct mdoc *, |
struct mdoc_node *, struct mdoc_argv *); |
struct mdoc_node *, struct mdoc_argv *); |
Line 75 static void rewrite_macro2len(char **); |
|
Line 70 static void rewrite_macro2len(char **); |
|
static void bwarn_ge1(POST_ARGS); |
static void bwarn_ge1(POST_ARGS); |
static void ewarn_eq1(POST_ARGS); |
static void ewarn_eq1(POST_ARGS); |
static void ewarn_ge1(POST_ARGS); |
static void ewarn_ge1(POST_ARGS); |
static void hwarn_eq0(POST_ARGS); |
|
|
|
static void post_an(POST_ARGS); |
static void post_an(POST_ARGS); |
static void post_at(POST_ARGS); |
static void post_at(POST_ARGS); |
Line 162 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 156 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
{ NULL, post_fn }, /* Fn */ |
{ NULL, post_fn }, /* Fn */ |
{ NULL, NULL }, /* Ft */ |
{ NULL, NULL }, /* Ft */ |
{ NULL, NULL }, /* Ic */ |
{ NULL, NULL }, /* Ic */ |
{ NULL, ewarn_eq1 }, /* In */ |
{ NULL, NULL }, /* In */ |
{ NULL, post_defaults }, /* Li */ |
{ NULL, post_defaults }, /* Li */ |
{ NULL, post_nd }, /* Nd */ |
{ NULL, post_nd }, /* Nd */ |
{ NULL, post_nm }, /* Nm */ |
{ NULL, post_nm }, /* Nm */ |
Line 173 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 167 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
{ NULL, post_st }, /* St */ |
{ NULL, post_st }, /* St */ |
{ NULL, NULL }, /* Va */ |
{ NULL, NULL }, /* Va */ |
{ NULL, post_vt }, /* Vt */ |
{ NULL, post_vt }, /* Vt */ |
{ NULL, ewarn_ge1 }, /* Xr */ |
{ NULL, NULL }, /* Xr */ |
{ NULL, ewarn_ge1 }, /* %A */ |
{ NULL, ewarn_ge1 }, /* %A */ |
{ NULL, post_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */ |
{ NULL, post_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */ |
{ NULL, ewarn_ge1 }, /* %D */ |
{ NULL, ewarn_ge1 }, /* %D */ |
Line 210 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 204 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
{ NULL, NULL }, /* Nx */ |
{ NULL, NULL }, /* Nx */ |
{ NULL, NULL }, /* Ox */ |
{ NULL, NULL }, /* Ox */ |
{ NULL, NULL }, /* Pc */ |
{ NULL, NULL }, /* Pc */ |
{ NULL, ewarn_eq1 }, /* Pf */ |
{ NULL, NULL }, /* Pf */ |
{ NULL, NULL }, /* Po */ |
{ NULL, NULL }, /* Po */ |
{ NULL, NULL }, /* Pq */ |
{ NULL, NULL }, /* Pq */ |
{ NULL, NULL }, /* Qc */ |
{ NULL, NULL }, /* Qc */ |
Line 374 mdoc_valid_post(struct mdoc *mdoc) |
|
Line 368 mdoc_valid_post(struct mdoc *mdoc) |
|
|
|
static void |
static void |
check_count(struct mdoc *mdoc, enum mdoc_type type, |
check_count(struct mdoc *mdoc, enum mdoc_type type, |
enum check_lvl lvl, enum check_ineq ineq, int val) |
enum check_ineq ineq, int val) |
{ |
{ |
const char *p; |
const char *p; |
enum mandocerr t; |
|
|
|
if (mdoc->last->type != type) |
if (mdoc->last->type != type) |
return; |
return; |
Line 403 check_count(struct mdoc *mdoc, enum mdoc_type type, |
|
Line 396 check_count(struct mdoc *mdoc, enum mdoc_type type, |
|
/* NOTREACHED */ |
/* NOTREACHED */ |
} |
} |
|
|
t = lvl == CHECK_WARN ? MANDOCERR_ARGCWARN : MANDOCERR_ARGCOUNT; |
mandoc_vmsg(MANDOCERR_ARGCWARN, mdoc->parse, mdoc->last->line, |
mandoc_vmsg(t, mdoc->parse, mdoc->last->line, |
|
mdoc->last->pos, "want %s%d children (have %d)", |
mdoc->last->pos, "want %s%d children (have %d)", |
p, val, mdoc->last->nchild); |
p, val, mdoc->last->nchild); |
} |
} |
Line 412 check_count(struct mdoc *mdoc, enum mdoc_type type, |
|
Line 404 check_count(struct mdoc *mdoc, enum mdoc_type type, |
|
static void |
static void |
bwarn_ge1(POST_ARGS) |
bwarn_ge1(POST_ARGS) |
{ |
{ |
check_count(mdoc, MDOC_BODY, CHECK_WARN, CHECK_GT, 0); |
check_count(mdoc, MDOC_BODY, CHECK_GT, 0); |
} |
} |
|
|
static void |
static void |
ewarn_eq1(POST_ARGS) |
ewarn_eq1(POST_ARGS) |
{ |
{ |
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 1); |
check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1); |
} |
} |
|
|
static void |
static void |
ewarn_ge1(POST_ARGS) |
ewarn_ge1(POST_ARGS) |
{ |
{ |
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_GT, 0); |
check_count(mdoc, MDOC_ELEM, CHECK_GT, 0); |
} |
} |
|
|
static void |
static void |
hwarn_eq0(POST_ARGS) |
|
{ |
|
check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_EQ, 0); |
|
} |
|
|
|
static void |
|
check_args(struct mdoc *mdoc, struct mdoc_node *n) |
check_args(struct mdoc *mdoc, struct mdoc_node *n) |
{ |
{ |
int i; |
int i; |
Line 941 post_lb(POST_ARGS) |
|
Line 927 post_lb(POST_ARGS) |
|
const char *stdlibname; |
const char *stdlibname; |
char *libname; |
char *libname; |
|
|
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 1); |
check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1); |
n = mdoc->last->child; |
n = mdoc->last->child; |
assert(MDOC_TEXT == n->type); |
assert(MDOC_TEXT == n->type); |
|
|
|
|
post_fo(POST_ARGS) |
post_fo(POST_ARGS) |
{ |
{ |
|
|
check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_EQ, 1); |
check_count(mdoc, MDOC_HEAD, CHECK_EQ, 1); |
bwarn_ge1(mdoc); |
bwarn_ge1(mdoc); |
if (mdoc->last->type == MDOC_HEAD && mdoc->last->nchild) |
if (mdoc->last->type == MDOC_HEAD && mdoc->last->nchild) |
post_fname(mdoc); |
post_fname(mdoc); |
Line 1047 post_vt(POST_ARGS) |
|
Line 1033 post_vt(POST_ARGS) |
|
static void |
static void |
post_nm(POST_ARGS) |
post_nm(POST_ARGS) |
{ |
{ |
|
struct mdoc_node *n; |
|
|
|
n = mdoc->last; |
|
|
|
if (n->last != NULL && |
|
(n->last->tok == MDOC_Pp || |
|
n->last->tok == MDOC_Lp)) |
|
mdoc_node_relink(mdoc, n->last); |
|
|
if (NULL != mdoc->meta.name) |
if (NULL != mdoc->meta.name) |
return; |
return; |
|
|
mdoc_deroff(&mdoc->meta.name, mdoc->last); |
mdoc_deroff(&mdoc->meta.name, n); |
|
|
if (NULL == mdoc->meta.name) |
if (NULL == mdoc->meta.name) |
mandoc_msg(MANDOCERR_NM_NONAME, mdoc->parse, |
mandoc_msg(MANDOCERR_NM_NONAME, mdoc->parse, |
mdoc->last->line, mdoc->last->pos, "Nm"); |
n->line, n->pos, "Nm"); |
} |
} |
|
|
static void |
static void |
post_nd(POST_ARGS) |
post_nd(POST_ARGS) |
{ |
{ |
|
struct mdoc_node *n; |
|
|
check_count(mdoc, MDOC_BODY, CHECK_ERROR, CHECK_GT, 0); |
n = mdoc->last; |
|
|
|
if (n->type != MDOC_BODY) |
|
return; |
|
|
|
if (n->child == NULL) |
|
mandoc_msg(MANDOCERR_ND_EMPTY, mdoc->parse, |
|
n->line, n->pos, "Nd"); |
|
|
post_hyph(mdoc); |
post_hyph(mdoc); |
} |
} |
|
|
|
|
post_literal(POST_ARGS) |
post_literal(POST_ARGS) |
{ |
{ |
|
|
if (mdoc->last->tok == MDOC_Bd) |
|
hwarn_eq0(mdoc); |
|
bwarn_ge1(mdoc); |
bwarn_ge1(mdoc); |
|
|
/* |
/* |
Line 1164 post_at(POST_ARGS) |
|
Line 1165 post_at(POST_ARGS) |
|
static void |
static void |
post_an(POST_ARGS) |
post_an(POST_ARGS) |
{ |
{ |
struct mdoc_node *np; |
struct mdoc_node *np, *nch; |
|
|
np = mdoc->last; |
np = mdoc->last; |
if (AUTH__NONE == np->norm->An.auth) { |
nch = np->child; |
if (0 == np->child) |
if (np->norm->An.auth == AUTH__NONE) { |
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_GT, 0); |
if (nch == NULL) |
} else if (np->child) |
mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, |
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 0); |
np->line, np->pos, "An"); |
|
} else if (nch != NULL) |
|
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
|
nch->line, nch->pos, "An ... %s", nch->string); |
} |
} |
|
|
static void |
static void |
Line 1197 post_it(POST_ARGS) |
|
Line 1201 post_it(POST_ARGS) |
|
struct mdoc_node *nbl, *nit, *nch; |
struct mdoc_node *nbl, *nit, *nch; |
|
|
nit = mdoc->last; |
nit = mdoc->last; |
if (MDOC_BLOCK != nit->type) |
if (nit->type != MDOC_BLOCK) |
return; |
return; |
|
|
nbl = nit->parent->parent; |
nbl = nit->parent->parent; |
Line 1213 post_it(POST_ARGS) |
|
Line 1217 post_it(POST_ARGS) |
|
case LIST_inset: |
case LIST_inset: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case LIST_diag: |
case LIST_diag: |
if (NULL == nit->head->child) |
if (nit->head->child == NULL) |
mandoc_vmsg(MANDOCERR_IT_NOHEAD, |
mandoc_vmsg(MANDOCERR_IT_NOHEAD, |
mdoc->parse, nit->line, nit->pos, |
mdoc->parse, nit->line, nit->pos, |
"Bl -%s It", |
"Bl -%s It", |
Line 1226 post_it(POST_ARGS) |
|
Line 1230 post_it(POST_ARGS) |
|
case LIST_enum: |
case LIST_enum: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case LIST_hyphen: |
case LIST_hyphen: |
if (NULL == nit->body->child) |
if (nit->body == NULL || nit->body->child == NULL) |
mandoc_vmsg(MANDOCERR_IT_NOBODY, |
mandoc_vmsg(MANDOCERR_IT_NOBODY, |
mdoc->parse, nit->line, nit->pos, |
mdoc->parse, nit->line, nit->pos, |
"Bl -%s It", |
"Bl -%s It", |
mdoc_argnames[nbl->args->argv[0].arg]); |
mdoc_argnames[nbl->args->argv[0].arg]); |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case LIST_item: |
case LIST_item: |
if (NULL != nit->head->child) |
if (nit->head->child != NULL) |
mandoc_vmsg(MANDOCERR_ARG_SKIP, |
mandoc_vmsg(MANDOCERR_ARG_SKIP, |
mdoc->parse, nit->line, nit->pos, |
mdoc->parse, nit->line, nit->pos, |
"It %s", nit->head->child->string); |
"It %s", nit->head->child->string); |
Line 1241 post_it(POST_ARGS) |
|
Line 1245 post_it(POST_ARGS) |
|
case LIST_column: |
case LIST_column: |
cols = (int)nbl->norm->Bl.ncols; |
cols = (int)nbl->norm->Bl.ncols; |
|
|
assert(NULL == nit->head->child); |
assert(nit->head->child == NULL); |
|
|
for (i = 0, nch = nit->child; nch; nch = nch->next) |
for (i = 0, nch = nit->child; nch; nch = nch->next) |
if (MDOC_BODY == nch->type) |
if (nch->type == MDOC_BODY) |
i++; |
i++; |
|
|
if (i < cols || i > cols + 1) |
if (i < cols || i > cols + 1) |
Line 1404 post_bl_block_tag(POST_ARGS) |
|
Line 1408 post_bl_block_tag(POST_ARGS) |
|
static void |
static void |
post_bl_head(POST_ARGS) |
post_bl_head(POST_ARGS) |
{ |
{ |
struct mdoc_node *np, *nn, *nnp; |
struct mdoc_node *nbl, *nh, *nch, *nnext; |
struct mdoc_argv *argv; |
struct mdoc_argv *argv; |
int i, j; |
int i, j; |
|
|
if (LIST_column != mdoc->last->norm->Bl.type) { |
nh = mdoc->last; |
/* FIXME: this should be ERROR class... */ |
|
hwarn_eq0(mdoc); |
if (nh->norm->Bl.type != LIST_column) { |
|
if ((nch = nh->child) == NULL) |
|
return; |
|
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
|
nch->line, nch->pos, "Bl ... %s", nch->string); |
|
while (nch != NULL) { |
|
mdoc_node_delete(mdoc, nch); |
|
nch = nh->child; |
|
} |
return; |
return; |
} |
} |
|
|
Line 1420 post_bl_head(POST_ARGS) |
|
Line 1432 post_bl_head(POST_ARGS) |
|
* lists where they're argument values following -column. |
* lists where they're argument values following -column. |
*/ |
*/ |
|
|
if (mdoc->last->child == NULL) |
if (nh->child == NULL) |
return; |
return; |
|
|
np = mdoc->last->parent; |
nbl = nh->parent; |
assert(np->args); |
for (j = 0; j < (int)nbl->args->argc; j++) |
|
if (nbl->args->argv[j].arg == MDOC_Column) |
for (j = 0; j < (int)np->args->argc; j++) |
|
if (MDOC_Column == np->args->argv[j].arg) |
|
break; |
break; |
|
|
assert(j < (int)np->args->argc); |
assert(j < (int)nbl->args->argc); |
|
|
/* |
/* |
* Accommodate for new-style groff column syntax. Shuffle the |
* Accommodate for new-style groff column syntax. Shuffle the |
Line 1438 post_bl_head(POST_ARGS) |
|
Line 1448 post_bl_head(POST_ARGS) |
|
* column field. Then, delete the head children. |
* column field. Then, delete the head children. |
*/ |
*/ |
|
|
argv = np->args->argv + j; |
argv = nbl->args->argv + j; |
i = argv->sz; |
i = argv->sz; |
argv->sz += mdoc->last->nchild; |
argv->sz += nh->nchild; |
argv->value = mandoc_reallocarray(argv->value, |
argv->value = mandoc_reallocarray(argv->value, |
argv->sz, sizeof(char *)); |
argv->sz, sizeof(char *)); |
|
|
mdoc->last->norm->Bl.ncols = argv->sz; |
nh->norm->Bl.ncols = argv->sz; |
mdoc->last->norm->Bl.cols = (void *)argv->value; |
nh->norm->Bl.cols = (void *)argv->value; |
|
|
for (nn = mdoc->last->child; nn; i++) { |
for (nch = nh->child; nch != NULL; nch = nnext) { |
argv->value[i] = nn->string; |
argv->value[i++] = nch->string; |
nn->string = NULL; |
nch->string = NULL; |
nnp = nn; |
nnext = nch->next; |
nn = nn->next; |
mdoc_node_delete(NULL, nch); |
mdoc_node_delete(NULL, nnp); |
|
} |
} |
|
nh->nchild = 0; |
mdoc->last->nchild = 0; |
nh->child = NULL; |
mdoc->last->child = NULL; |
|
} |
} |
|
|
static void |
static void |
Line 1484 post_bl(POST_ARGS) |
|
Line 1492 post_bl(POST_ARGS) |
|
|
|
nchild = nbody->child; |
nchild = nbody->child; |
while (NULL != nchild) { |
while (NULL != nchild) { |
if (MDOC_It == nchild->tok || MDOC_Sm == nchild->tok) { |
if (nchild->tok == MDOC_It || |
|
(nchild->tok == MDOC_Sm && |
|
nchild->next != NULL && |
|
nchild->next->tok == MDOC_It)) { |
nchild = nchild->next; |
nchild = nchild->next; |
continue; |
continue; |
} |
} |
Line 1539 post_bl(POST_ARGS) |
|
Line 1550 post_bl(POST_ARGS) |
|
static void |
static void |
post_bk(POST_ARGS) |
post_bk(POST_ARGS) |
{ |
{ |
|
struct mdoc_node *n; |
|
|
hwarn_eq0(mdoc); |
n = mdoc->last; |
bwarn_ge1(mdoc); |
|
|
if (n->type == MDOC_BLOCK && n->body->child == NULL) { |
|
mandoc_msg(MANDOCERR_MACRO_EMPTY, |
|
mdoc->parse, n->line, n->pos, "Bk"); |
|
mdoc_node_delete(mdoc, n); |
|
} |
} |
} |
|
|
static void |
static void |
Line 1623 post_st(POST_ARGS) |
|
Line 1640 post_st(POST_ARGS) |
|
n = mdoc->last; |
n = mdoc->last; |
nch = n->child; |
nch = n->child; |
|
|
if (NULL == nch) { |
|
mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, |
|
n->line, n->pos, mdoc_macronames[n->tok]); |
|
mdoc_node_delete(mdoc, n); |
|
return; |
|
} |
|
|
|
assert(MDOC_TEXT == nch->type); |
assert(MDOC_TEXT == nch->type); |
|
|
if (NULL == (p = mdoc_a2st(nch->string))) { |
if (NULL == (p = mdoc_a2st(nch->string))) { |
Line 1645 post_st(POST_ARGS) |
|
Line 1655 post_st(POST_ARGS) |
|
static void |
static void |
post_rs(POST_ARGS) |
post_rs(POST_ARGS) |
{ |
{ |
struct mdoc_node *nn, *next, *prev; |
struct mdoc_node *np, *nch, *next, *prev; |
int i, j; |
int i, j; |
|
|
switch (mdoc->last->type) { |
np = mdoc->last; |
case MDOC_HEAD: |
|
check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_EQ, 0); |
if (np->type != MDOC_BODY) |
return; |
return; |
case MDOC_BODY: |
|
if (mdoc->last->child) |
if (np->child == NULL) { |
break; |
mandoc_msg(MANDOCERR_RS_EMPTY, mdoc->parse, |
check_count(mdoc, MDOC_BODY, CHECK_WARN, CHECK_GT, 0); |
np->line, np->pos, "Rs"); |
return; |
return; |
default: |
|
return; |
|
} |
} |
|
|
/* |
/* |
Line 1668 post_rs(POST_ARGS) |
|
Line 1676 post_rs(POST_ARGS) |
|
*/ |
*/ |
|
|
next = NULL; |
next = NULL; |
for (nn = mdoc->last->child->next; nn; nn = next) { |
for (nch = np->child->next; nch != NULL; nch = next) { |
/* Determine order of `nn'. */ |
/* Determine order number of this child. */ |
for (i = 0; i < RSORD_MAX; i++) |
for (i = 0; i < RSORD_MAX; i++) |
if (rsord[i] == nn->tok) |
if (rsord[i] == nch->tok) |
break; |
break; |
|
|
if (i == RSORD_MAX) { |
if (i == RSORD_MAX) { |
mandoc_msg(MANDOCERR_RS_BAD, |
mandoc_msg(MANDOCERR_RS_BAD, |
mdoc->parse, nn->line, nn->pos, |
mdoc->parse, nch->line, nch->pos, |
mdoc_macronames[nn->tok]); |
mdoc_macronames[nch->tok]); |
i = -1; |
i = -1; |
} else if (MDOC__J == nn->tok || MDOC__B == nn->tok) |
} else if (nch->tok == MDOC__J || nch->tok == MDOC__B) |
mdoc->last->norm->Rs.quote_T++; |
np->norm->Rs.quote_T++; |
|
|
/* |
/* |
* Remove `nn' from the chain. This somewhat |
* Remove this child from the chain. This somewhat |
* repeats mdoc_node_unlink(), but since we're |
* repeats mdoc_node_unlink(), but since we're |
* just re-ordering, there's no need for the |
* just re-ordering, there's no need for the |
* full unlink process. |
* full unlink process. |
*/ |
*/ |
|
|
if (NULL != (next = nn->next)) |
if ((next = nch->next) != NULL) |
next->prev = nn->prev; |
next->prev = nch->prev; |
|
|
if (NULL != (prev = nn->prev)) |
if ((prev = nch->prev) != NULL) |
prev->next = nn->next; |
prev->next = nch->next; |
|
|
nn->prev = nn->next = NULL; |
nch->prev = nch->next = NULL; |
|
|
/* |
/* |
* Scan back until we reach a node that's |
* Scan back until we reach a node that's |
* ordered before `nn'. |
* to be ordered before this child. |
*/ |
*/ |
|
|
for ( ; prev ; prev = prev->prev) { |
for ( ; prev ; prev = prev->prev) { |
Line 1715 post_rs(POST_ARGS) |
|
Line 1723 post_rs(POST_ARGS) |
|
} |
} |
|
|
/* |
/* |
* Set `nn' back into its correct place in front |
* Set this child back into its correct place |
* of the `prev' node. |
* in front of the `prev' node. |
*/ |
*/ |
|
|
nn->prev = prev; |
nch->prev = prev; |
|
|
if (prev) { |
if (prev == NULL) { |
if (prev->next) |
np->child->prev = nch; |
prev->next->prev = nn; |
nch->next = np->child; |
nn->next = prev->next; |
np->child = nch; |
prev->next = nn; |
|
} else { |
} else { |
mdoc->last->child->prev = nn; |
if (prev->next) |
nn->next = mdoc->last->child; |
prev->next->prev = nch; |
mdoc->last->child = nn; |
nch->next = prev->next; |
|
prev->next = nch; |
} |
} |
} |
} |
} |
} |
Line 2061 post_ignpar(POST_ARGS) |
|
Line 2069 post_ignpar(POST_ARGS) |
|
{ |
{ |
struct mdoc_node *np; |
struct mdoc_node *np; |
|
|
check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_GT, 0); |
|
post_hyph(mdoc); |
post_hyph(mdoc); |
|
|
if (MDOC_BODY != mdoc->last->type) |
if (MDOC_BODY != mdoc->last->type) |
Line 2123 post_par(POST_ARGS) |
|
Line 2130 post_par(POST_ARGS) |
|
{ |
{ |
struct mdoc_node *np; |
struct mdoc_node *np; |
|
|
if (mdoc->last->tok == MDOC_sp) |
np = mdoc->last; |
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_LT, 2); |
|
else |
|
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 0); |
|
|
|
if (MDOC_ELEM != mdoc->last->type && |
if (np->tok == MDOC_sp) { |
MDOC_BLOCK != mdoc->last->type) |
if (np->nchild > 1) |
return; |
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
|
np->child->next->line, np->child->next->pos, |
|
"sp ... %s", np->child->next->string); |
|
} else if (np->child != NULL) |
|
mandoc_vmsg(MANDOCERR_ARG_SKIP, |
|
mdoc->parse, np->line, np->pos, "%s %s", |
|
mdoc_macronames[np->tok], np->child->string); |
|
|
if (NULL == (np = mdoc->last->prev)) { |
if (NULL == (np = mdoc->last->prev)) { |
np = mdoc->last->parent; |
np = mdoc->last->parent; |
Line 2280 post_dt(POST_ARGS) |
|
Line 2290 post_dt(POST_ARGS) |
|
mdoc->meta.msec = mandoc_strdup(nn->string); |
mdoc->meta.msec = mandoc_strdup(nn->string); |
} |
} |
|
|
if (NULL == (nn = nn->next)) |
/* Handle an optional architecture */ |
goto out; |
|
|
|
/* |
if ((nn = nn->next) != NULL) { |
* If the third argument is a volume name, format is, |
|
* otherwise assume it's an architecture. |
|
*/ |
|
|
|
cp = mdoc_a2vol(nn->string); |
|
if (cp) { |
|
free(mdoc->meta.vol); |
|
mdoc->meta.vol = mandoc_strdup(cp); |
|
} else { |
|
for (p = nn->string; *p; p++) |
for (p = nn->string; *p; p++) |
*p = tolower((unsigned char)*p); |
*p = tolower((unsigned char)*p); |
mdoc->meta.arch = mandoc_strdup(nn->string); |
mdoc->meta.arch = mandoc_strdup(nn->string); |