version 1.153, 2020/04/18 20:40:10 |
version 1.158, 2023/04/28 20:23:19 |
|
|
|
|
typedef void (*v_check)(CHKARGS); |
typedef void (*v_check)(CHKARGS); |
|
|
static void check_abort(CHKARGS) __attribute__((__noreturn__)); |
|
static void check_par(CHKARGS); |
static void check_par(CHKARGS); |
static void check_part(CHKARGS); |
static void check_part(CHKARGS); |
static void check_root(CHKARGS); |
static void check_root(CHKARGS); |
Line 69 static const v_check man_valids[MAN_MAX - MAN_TH] = { |
|
Line 68 static const v_check man_valids[MAN_MAX - MAN_TH] = { |
|
post_SH, /* SS */ |
post_SH, /* SS */ |
post_TP, /* TP */ |
post_TP, /* TP */ |
post_TP, /* TQ */ |
post_TP, /* TQ */ |
check_abort,/* LP */ |
check_par, /* LP */ |
check_par, /* PP */ |
check_par, /* PP */ |
check_abort,/* P */ |
check_par, /* P */ |
post_IP, /* IP */ |
post_IP, /* IP */ |
NULL, /* HP */ |
NULL, /* HP */ |
NULL, /* SM */ |
NULL, /* SM */ |
Line 112 man_validate(struct roff_man *man) |
|
Line 111 man_validate(struct roff_man *man) |
|
const v_check *cp; |
const v_check *cp; |
|
|
/* |
/* |
* Translate obsolete macros such that later code |
|
* does not need to look for them. |
|
*/ |
|
|
|
n = man->last; |
|
switch (n->tok) { |
|
case MAN_LP: |
|
case MAN_P: |
|
n->tok = MAN_PP; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
/* |
|
* Iterate over all children, recursing into each one |
* Iterate over all children, recursing into each one |
* in turn, depth-first. |
* in turn, depth-first. |
*/ |
*/ |
|
|
|
n = man->last; |
man->last = man->last->child; |
man->last = man->last->child; |
while (man->last != NULL) { |
while (man->last != NULL) { |
man_validate(man); |
man_validate(man); |
Line 200 check_root(CHKARGS) |
|
Line 185 check_root(CHKARGS) |
|
"(OpenBSD)" : "(NetBSD)"); |
"(OpenBSD)" : "(NetBSD)"); |
} |
} |
|
|
static void |
|
check_abort(CHKARGS) |
|
{ |
|
abort(); |
|
} |
|
|
|
/* |
/* |
* Skip leading whitespace, dashes, backslashes, and font escapes, |
* Skip leading whitespace, dashes, backslashes, and font escapes, |
* then create a tag if the first following byte is a letter. |
* then create a tag if the first following byte is a letter. |
Line 239 check_tag(struct roff_node *n, struct roff_node *nt) |
|
Line 218 check_tag(struct roff_node *n, struct roff_node *nt) |
|
case ESCAPE_FONTITALIC: |
case ESCAPE_FONTITALIC: |
case ESCAPE_FONTBI: |
case ESCAPE_FONTBI: |
case ESCAPE_FONTROMAN: |
case ESCAPE_FONTROMAN: |
case ESCAPE_FONTCW: |
case ESCAPE_FONTCR: |
|
case ESCAPE_FONTCB: |
|
case ESCAPE_FONTCI: |
case ESCAPE_FONTPREV: |
case ESCAPE_FONTPREV: |
case ESCAPE_IGNORE: |
case ESCAPE_IGNORE: |
break; |
break; |
Line 324 post_SH(CHKARGS) |
|
Line 305 post_SH(CHKARGS) |
|
*cp = '_'; |
*cp = '_'; |
if (nc != NULL && nc->type == ROFFT_TEXT && |
if (nc != NULL && nc->type == ROFFT_TEXT && |
strcmp(nc->string, tag) == 0) |
strcmp(nc->string, tag) == 0) |
tag_put(NULL, TAG_WEAK, n); |
tag_put(NULL, TAG_STRONG, n); |
else |
else |
tag_put(tag, TAG_FALLBACK, n); |
tag_put(tag, TAG_FALLBACK, n); |
free(tag); |
free(tag); |
Line 338 post_SH(CHKARGS) |
|
Line 319 post_SH(CHKARGS) |
|
return; |
return; |
} |
} |
|
|
if (nc->tok == MAN_PP && nc->body->child != NULL) { |
if ((nc->tok == MAN_LP || nc->tok == MAN_PP || nc->tok == MAN_P) && |
|
nc->body->child != NULL) { |
while (nc->body->last != NULL) { |
while (nc->body->last != NULL) { |
man->next = ROFF_NEXT_CHILD; |
man->next = ROFF_NEXT_CHILD; |
roff_node_relink(man, nc->body->last); |
roff_node_relink(man, nc->body->last); |
Line 346 post_SH(CHKARGS) |
|
Line 328 post_SH(CHKARGS) |
|
} |
} |
} |
} |
|
|
if (nc->tok == MAN_PP || nc->tok == ROFF_sp || nc->tok == ROFF_br) { |
if (nc->tok == MAN_LP || nc->tok == MAN_PP || nc->tok == MAN_P || |
|
nc->tok == ROFF_sp || nc->tok == ROFF_br) { |
mandoc_msg(MANDOCERR_PAR_SKIP, nc->line, nc->pos, |
mandoc_msg(MANDOCERR_PAR_SKIP, nc->line, nc->pos, |
"%s after %s", roff_name[nc->tok], roff_name[n->tok]); |
"%s after %s", roff_name[nc->tok], roff_name[n->tok]); |
roff_node_delete(man, nc); |
roff_node_delete(man, nc); |
Line 371 post_UR(CHKARGS) |
|
Line 354 post_UR(CHKARGS) |
|
if (n->type == ROFFT_HEAD && n->child == NULL) |
if (n->type == ROFFT_HEAD && n->child == NULL) |
mandoc_msg(MANDOCERR_UR_NOHEAD, n->line, n->pos, |
mandoc_msg(MANDOCERR_UR_NOHEAD, n->line, n->pos, |
"%s", roff_name[n->tok]); |
"%s", roff_name[n->tok]); |
check_part(man, n); |
|
} |
} |
|
|
static void |
static void |
check_part(CHKARGS) |
check_part(CHKARGS) |
{ |
{ |
|
|
if (n->type == ROFFT_BODY && n->child == NULL) |
if (n->type == ROFFT_BODY && n->child == NULL) |
mandoc_msg(MANDOCERR_BLK_EMPTY, n->line, n->pos, |
mandoc_msg(MANDOCERR_BLK_EMPTY, n->line, n->pos, |
"%s", roff_name[n->tok]); |
"%s", roff_name[n->tok]); |
Line 510 post_TH(CHKARGS) |
|
Line 491 post_TH(CHKARGS) |
|
|
|
if (n != NULL) |
if (n != NULL) |
n = n->next; |
n = n->next; |
if (n != NULL && n->string != NULL) |
if (n != NULL && n->string != NULL) { |
man->meta.msec = mandoc_strdup(n->string); |
man->meta.msec = mandoc_strdup(n->string); |
else { |
if (man->filesec != '\0' && |
|
man->filesec != *n->string && |
|
*n->string >= '1' && *n->string <= '9') |
|
mandoc_msg(MANDOCERR_MSEC_FILE, n->line, n->pos, |
|
"*.%c vs TH ... %c", man->filesec, *n->string); |
|
} else { |
man->meta.msec = mandoc_strdup(""); |
man->meta.msec = mandoc_strdup(""); |
mandoc_msg(MANDOCERR_MSEC_MISSING, |
mandoc_msg(MANDOCERR_MSEC_MISSING, |
nb->line, nb->pos, "TH %s", man->meta.title); |
nb->line, nb->pos, "TH %s", man->meta.title); |