version 1.54, 2010/12/06 13:56:56 |
version 1.59, 2011/01/12 16:55:22 |
Line 44 struct man_valid { |
|
Line 44 struct man_valid { |
|
|
|
static int check_bline(CHKARGS); |
static int check_bline(CHKARGS); |
static int check_eq0(CHKARGS); |
static int check_eq0(CHKARGS); |
|
static int check_ft(CHKARGS); |
static int check_le1(CHKARGS); |
static int check_le1(CHKARGS); |
static int check_ge2(CHKARGS); |
static int check_ge2(CHKARGS); |
static int check_le5(CHKARGS); |
static int check_le5(CHKARGS); |
Line 64 static v_check posts_at[] = { post_AT, NULL }; |
|
Line 65 static v_check posts_at[] = { post_AT, NULL }; |
|
static v_check posts_eq0[] = { check_eq0, NULL }; |
static v_check posts_eq0[] = { check_eq0, NULL }; |
static v_check posts_fi[] = { check_eq0, post_fi, NULL }; |
static v_check posts_fi[] = { check_eq0, post_fi, NULL }; |
static v_check posts_le1[] = { check_le1, NULL }; |
static v_check posts_le1[] = { check_le1, NULL }; |
|
static v_check posts_ft[] = { check_ft, NULL }; |
static v_check posts_nf[] = { check_eq0, post_nf, NULL }; |
static v_check posts_nf[] = { check_eq0, post_nf, NULL }; |
static v_check posts_par[] = { check_par, NULL }; |
static v_check posts_par[] = { check_par, NULL }; |
static v_check posts_part[] = { check_part, NULL }; |
static v_check posts_part[] = { check_part, NULL }; |
Line 78 static const struct man_valid man_valids[MAN_MAX] = { |
|
Line 80 static const struct man_valid man_valids[MAN_MAX] = { |
|
{ pres_bline, posts_th }, /* TH */ |
{ pres_bline, posts_th }, /* TH */ |
{ pres_bline, posts_sec }, /* SH */ |
{ pres_bline, posts_sec }, /* SH */ |
{ pres_bline, posts_sec }, /* SS */ |
{ pres_bline, posts_sec }, /* SS */ |
{ pres_bline, posts_par }, /* TP */ |
{ pres_bline, NULL }, /* TP */ |
{ pres_bline, posts_par }, /* LP */ |
{ pres_bline, posts_par }, /* LP */ |
{ pres_bline, posts_par }, /* PP */ |
{ pres_bline, posts_par }, /* PP */ |
{ pres_bline, posts_par }, /* P */ |
{ pres_bline, posts_par }, /* P */ |
{ pres_bline, posts_par }, /* IP */ |
{ pres_bline, NULL }, /* IP */ |
{ pres_bline, posts_par }, /* HP */ |
{ pres_bline, NULL }, /* HP */ |
{ NULL, NULL }, /* SM */ |
{ NULL, NULL }, /* SM */ |
{ NULL, NULL }, /* SB */ |
{ NULL, NULL }, /* SB */ |
{ NULL, NULL }, /* BI */ |
{ NULL, NULL }, /* BI */ |
Line 96 static const struct man_valid man_valids[MAN_MAX] = { |
|
Line 98 static const struct man_valid man_valids[MAN_MAX] = { |
|
{ NULL, NULL }, /* IR */ |
{ NULL, NULL }, /* IR */ |
{ NULL, NULL }, /* RI */ |
{ NULL, NULL }, /* RI */ |
{ NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */ |
{ NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */ |
{ NULL, NULL }, /* i */ |
|
{ NULL, posts_le1 }, /* sp */ /* FIXME: should warn only. */ |
{ NULL, posts_le1 }, /* sp */ /* FIXME: should warn only. */ |
{ pres_bline, posts_nf }, /* nf */ |
{ pres_bline, posts_nf }, /* nf */ |
{ pres_bline, posts_fi }, /* fi */ |
{ pres_bline, posts_fi }, /* fi */ |
{ NULL, NULL }, /* r */ |
|
{ NULL, NULL }, /* RE */ |
{ NULL, NULL }, /* RE */ |
{ NULL, posts_part }, /* RS */ |
{ NULL, posts_part }, /* RS */ |
{ NULL, NULL }, /* DT */ |
{ NULL, NULL }, /* DT */ |
Line 108 static const struct man_valid man_valids[MAN_MAX] = { |
|
Line 108 static const struct man_valid man_valids[MAN_MAX] = { |
|
{ NULL, NULL }, /* PD */ |
{ NULL, NULL }, /* PD */ |
{ NULL, posts_at }, /* AT */ |
{ NULL, posts_at }, /* AT */ |
{ NULL, NULL }, /* in */ |
{ NULL, NULL }, /* in */ |
|
{ NULL, posts_ft }, /* ft */ |
}; |
}; |
|
|
|
|
Line 116 man_valid_pre(struct man *m, struct man_node *n) |
|
Line 117 man_valid_pre(struct man *m, struct man_node *n) |
|
{ |
{ |
v_check *cp; |
v_check *cp; |
|
|
if (MAN_TEXT == n->type) |
switch (n->type) { |
|
case (MAN_TEXT): |
|
/* FALLTHROUGH */ |
|
case (MAN_ROOT): |
|
/* FALLTHROUGH */ |
|
case (MAN_TBL): |
return(1); |
return(1); |
if (MAN_ROOT == n->type) |
default: |
return(1); |
break; |
|
} |
|
|
if (NULL == (cp = man_valids[n->tok].pres)) |
if (NULL == (cp = man_valids[n->tok].pres)) |
return(1); |
return(1); |
Line 144 man_valid_post(struct man *m) |
|
Line 151 man_valid_post(struct man *m) |
|
return(check_text(m, m->last)); |
return(check_text(m, m->last)); |
case (MAN_ROOT): |
case (MAN_ROOT): |
return(check_root(m, m->last)); |
return(check_root(m, m->last)); |
|
case (MAN_TBL): |
|
return(1); |
default: |
default: |
break; |
break; |
} |
} |
Line 268 INEQ_DEFINE(1, <=, le1) |
|
Line 277 INEQ_DEFINE(1, <=, le1) |
|
INEQ_DEFINE(2, >=, ge2) |
INEQ_DEFINE(2, >=, ge2) |
INEQ_DEFINE(5, <=, le5) |
INEQ_DEFINE(5, <=, le5) |
|
|
|
static int |
|
check_ft(CHKARGS) |
|
{ |
|
char *cp; |
|
int ok; |
|
|
|
if (0 == n->nchild) |
|
return(1); |
|
|
|
ok = 0; |
|
cp = n->child->string; |
|
switch (*cp) { |
|
case ('1'): |
|
/* FALLTHROUGH */ |
|
case ('2'): |
|
/* FALLTHROUGH */ |
|
case ('3'): |
|
/* FALLTHROUGH */ |
|
case ('4'): |
|
/* FALLTHROUGH */ |
|
case ('I'): |
|
/* FALLTHROUGH */ |
|
case ('P'): |
|
/* FALLTHROUGH */ |
|
case ('R'): |
|
if ('\0' == cp[1]) |
|
ok = 1; |
|
break; |
|
case ('B'): |
|
if ('\0' == cp[1] || ('I' == cp[1] && '\0' == cp[2])) |
|
ok = 1; |
|
break; |
|
case ('C'): |
|
if ('W' == cp[1] && '\0' == cp[2]) |
|
ok = 1; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
if (0 == ok) { |
|
man_vmsg(m, MANDOCERR_BADFONT, |
|
n->line, n->pos, "%s", cp); |
|
*cp = '\0'; |
|
} |
|
|
|
if (1 < n->nchild) |
|
man_vmsg(m, MANDOCERR_ARGCOUNT, n->line, n->pos, |
|
"want one child (have %d)", n->nchild); |
|
|
|
return(1); |
|
} |
|
|
static int |
static int |
check_sec(CHKARGS) |
check_sec(CHKARGS) |
{ |
{ |
|
|
check_par(CHKARGS) |
check_par(CHKARGS) |
{ |
{ |
|
|
if (MAN_BODY == n->type) |
switch (n->type) { |
switch (n->tok) { |
case (MAN_BLOCK): |
case (MAN_IP): |
if (0 == n->body->nchild) |
/* FALLTHROUGH */ |
man_node_delete(m, n); |
case (MAN_HP): |
break; |
/* FALLTHROUGH */ |
case (MAN_BODY): |
case (MAN_TP): |
if (0 == n->nchild) |
/* Body-less lists are ok. */ |
man_nmsg(m, n, MANDOCERR_IGNPAR); |
break; |
break; |
default: |
case (MAN_HEAD): |
if (0 == n->nchild) |
if (n->nchild) |
man_nmsg(m, n, MANDOCERR_NOBODY); |
man_nmsg(m, n, MANDOCERR_ARGSLOST); |
break; |
break; |
} |
default: |
if (MAN_HEAD == n->type) |
break; |
switch (n->tok) { |
} |
case (MAN_PP): |
|
/* FALLTHROUGH */ |
|
case (MAN_P): |
|
/* FALLTHROUGH */ |
|
case (MAN_LP): |
|
if (n->nchild) |
|
man_nmsg(m, n, MANDOCERR_ARGSLOST); |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
return(1); |
return(1); |
} |
} |
Line 428 post_fi(CHKARGS) |
|
Line 478 post_fi(CHKARGS) |
|
{ |
{ |
|
|
if ( ! (MAN_LITERAL & m->flags)) |
if ( ! (MAN_LITERAL & m->flags)) |
man_nmsg(m, n, MANDOCERR_NOSCOPE); |
man_nmsg(m, n, MANDOCERR_WNOSCOPE); |
|
|
m->flags &= ~MAN_LITERAL; |
m->flags &= ~MAN_LITERAL; |
return(1); |
return(1); |