version 1.13, 2009/06/17 11:02:06 |
version 1.17, 2009/06/27 09:03:03 |
|
|
EMULTILIST, |
EMULTILIST, |
EARGREP, |
EARGREP, |
EBOOL, |
EBOOL, |
|
ECOLMIS, |
ENESTDISP |
ENESTDISP |
}; |
}; |
|
|
|
|
WNOWIDTH, |
WNOWIDTH, |
WMISSWIDTH, |
WMISSWIDTH, |
WESCAPE, |
WESCAPE, |
WDEPESC, |
|
WDEPCOL, |
WDEPCOL, |
WWRONGMSEC, |
WWRONGMSEC, |
WSECOOO, |
WSECOOO, |
Line 98 static int err_child_gt(struct mdoc *, const char *, i |
|
Line 98 static int err_child_gt(struct mdoc *, const char *, i |
|
static int warn_child_gt(struct mdoc *, const char *, int); |
static int warn_child_gt(struct mdoc *, const char *, int); |
static int err_child_eq(struct mdoc *, const char *, int); |
static int err_child_eq(struct mdoc *, const char *, int); |
static int warn_child_eq(struct mdoc *, const char *, int); |
static int warn_child_eq(struct mdoc *, const char *, int); |
static int count_child(struct mdoc *); |
|
static int warn_print(struct mdoc *, int, int); |
static int warn_print(struct mdoc *, int, int); |
static int warn_count(struct mdoc *, const char *, |
static int warn_count(struct mdoc *, const char *, |
int, const char *, int); |
int, const char *, int); |
Line 138 static int post_args(POST_ARGS); |
|
Line 137 static int post_args(POST_ARGS); |
|
static int post_at(POST_ARGS); |
static int post_at(POST_ARGS); |
static int post_bf(POST_ARGS); |
static int post_bf(POST_ARGS); |
static int post_bl(POST_ARGS); |
static int post_bl(POST_ARGS); |
|
static int post_bl_head(POST_ARGS); |
static int post_it(POST_ARGS); |
static int post_it(POST_ARGS); |
static int post_nm(POST_ARGS); |
static int post_nm(POST_ARGS); |
static int post_root(POST_ARGS); |
static int post_root(POST_ARGS); |
Line 174 static v_post posts_wtext[] = { ewarn_ge1, NULL }; |
|
Line 174 static v_post posts_wtext[] = { ewarn_ge1, NULL }; |
|
static v_post posts_notext[] = { eerr_eq0, NULL }; |
static v_post posts_notext[] = { eerr_eq0, NULL }; |
static v_post posts_wline[] = { bwarn_ge1, herr_eq0, NULL }; |
static v_post posts_wline[] = { bwarn_ge1, herr_eq0, NULL }; |
static v_post posts_sh[] = { herr_ge1, bwarn_ge1, post_sh, NULL }; |
static v_post posts_sh[] = { herr_ge1, bwarn_ge1, post_sh, NULL }; |
static v_post posts_bl[] = { herr_eq0, bwarn_ge1, post_bl, NULL }; |
static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL }; |
static v_post posts_it[] = { post_it, NULL }; |
static v_post posts_it[] = { post_it, NULL }; |
static v_post posts_in[] = { ewarn_eq1, NULL }; |
static v_post posts_in[] = { ewarn_eq1, NULL }; |
static v_post posts_ss[] = { herr_ge1, NULL }; |
static v_post posts_ss[] = { herr_ge1, NULL }; |
Line 425 perr(struct mdoc *m, int line, int pos, enum merr type |
|
Line 425 perr(struct mdoc *m, int line, int pos, enum merr type |
|
case (ENODATA): |
case (ENODATA): |
p = "document has no data"; |
p = "document has no data"; |
break; |
break; |
|
case (ECOLMIS): |
|
p = "column syntax style mismatch"; |
|
break; |
case (EATT): |
case (EATT): |
p = "expected valid AT&T symbol"; |
p = "expected valid AT&T symbol"; |
break; |
break; |
Line 482 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
Line 485 pwarn(struct mdoc *m, int line, int pos, enum mwarn ty |
|
case (WESCAPE): |
case (WESCAPE): |
p = "invalid escape sequence"; |
p = "invalid escape sequence"; |
break; |
break; |
case (WDEPESC): |
|
p = "deprecated special-character escape"; |
|
break; |
|
case (WNOLINE): |
case (WNOLINE): |
p = "suggested no line arguments"; |
p = "suggested no line arguments"; |
break; |
break; |
Line 548 err_count(struct mdoc *m, const char *k, |
|
Line 548 err_count(struct mdoc *m, const char *k, |
|
} |
} |
|
|
|
|
static inline int |
|
count_child(struct mdoc *mdoc) |
|
{ |
|
int i; |
|
struct mdoc_node *n; |
|
|
|
for (i = 0, n = mdoc->last->child; n; n = n->next, i++) |
|
/* Do nothing */ ; |
|
|
|
return(i); |
|
} |
|
|
|
|
|
/* |
/* |
* Build these up with macros because they're basically the same check |
* Build these up with macros because they're basically the same check |
* for different inequalities. Yes, this could be done with functions, |
* for different inequalities. Yes, this could be done with functions, |
Line 571 count_child(struct mdoc *mdoc) |
|
Line 558 count_child(struct mdoc *mdoc) |
|
static int \ |
static int \ |
lvl##_child_##name(struct mdoc *mdoc, const char *p, int sz) \ |
lvl##_child_##name(struct mdoc *mdoc, const char *p, int sz) \ |
{ \ |
{ \ |
int i; \ |
if (mdoc->last->nchild ineq sz) \ |
if ((i = count_child(mdoc)) ineq sz) \ |
|
return(1); \ |
return(1); \ |
return(lvl##_count(mdoc, #ineq, sz, p, i)); \ |
return(lvl##_count(mdoc, #ineq, sz, p, mdoc->last->nchild)); \ |
} |
} |
|
|
#define CHECK_BODY_DEFN(name, lvl, func, num) \ |
#define CHECK_BODY_DEFN(name, lvl, func, num) \ |
Line 738 check_text(struct mdoc *mdoc, int line, int pos, const |
|
Line 724 check_text(struct mdoc *mdoc, int line, int pos, const |
|
|
|
c = mdoc_isescape(p); |
c = mdoc_isescape(p); |
if (c) { |
if (c) { |
/* See if form is deprecated. */ |
|
if ('*' == p[1]) |
|
if ( ! pwarn(mdoc, line, pos, WDEPESC)) |
|
return(0); |
|
p += (int)c - 1; |
p += (int)c - 1; |
continue; |
continue; |
} |
} |
Line 797 pre_display(PRE_ARGS) |
|
Line 779 pre_display(PRE_ARGS) |
|
static int |
static int |
pre_bl(PRE_ARGS) |
pre_bl(PRE_ARGS) |
{ |
{ |
int pos, col, type, width, offset; |
int pos, type, width, offset; |
|
|
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
return(1); |
return(1); |
Line 806 pre_bl(PRE_ARGS) |
|
Line 788 pre_bl(PRE_ARGS) |
|
|
|
/* Make sure that only one type of list is specified. */ |
/* Make sure that only one type of list is specified. */ |
|
|
type = offset = width = col = -1; |
type = offset = width = -1; |
|
|
/* LINTED */ |
/* LINTED */ |
for (pos = 0; pos < (int)n->args->argc; pos++) |
for (pos = 0; pos < (int)n->args->argc; pos++) |
Line 835 pre_bl(PRE_ARGS) |
|
Line 817 pre_bl(PRE_ARGS) |
|
if (-1 != type) |
if (-1 != type) |
return(nerr(mdoc, n, EMULTILIST)); |
return(nerr(mdoc, n, EMULTILIST)); |
type = n->args->argv[pos].arg; |
type = n->args->argv[pos].arg; |
col = pos; |
|
break; |
break; |
case (MDOC_Width): |
case (MDOC_Width): |
if (-1 != width) |
if (-1 != width) |
Line 879 pre_bl(PRE_ARGS) |
|
Line 860 pre_bl(PRE_ARGS) |
|
break; |
break; |
} |
} |
|
|
/* |
|
* General validation of fields. |
|
*/ |
|
|
|
switch (type) { |
|
case (MDOC_Column): |
|
assert(col >= 0); |
|
if (0 == n->args->argv[col].sz) |
|
break; |
|
if ( ! nwarn(mdoc, n, WDEPCOL)) |
|
return(0); |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 1257 post_it(POST_ARGS) |
|
Line 1222 post_it(POST_ARGS) |
|
|
|
|
|
static int |
static int |
|
post_bl_head(POST_ARGS) |
|
{ |
|
int i; |
|
const struct mdoc_node *n; |
|
|
|
n = mdoc->last->parent; |
|
assert(n->args); |
|
|
|
for (i = 0; i < (int)n->args->argc; i++) |
|
if (n->args->argv[i].arg == MDOC_Column) |
|
break; |
|
|
|
if (i == (int)n->args->argc) |
|
return(1); |
|
|
|
if (n->args->argv[i].sz && mdoc->last->child) |
|
return(nerr(mdoc, n, ECOLMIS)); |
|
|
|
return(1); |
|
} |
|
|
|
|
|
static int |
post_bl(POST_ARGS) |
post_bl(POST_ARGS) |
{ |
{ |
struct mdoc_node *n; |
struct mdoc_node *n; |
|
|
|
if (MDOC_HEAD == mdoc->last->type) |
|
return(post_bl_head(mdoc)); |
if (MDOC_BODY != mdoc->last->type) |
if (MDOC_BODY != mdoc->last->type) |
return(1); |
return(1); |
if (NULL == mdoc->last->child) |
if (NULL == mdoc->last->child) |