version 1.141, 2018/12/14 05:18:02 |
version 1.149, 2019/06/27 15:07:30 |
|
|
/* $OpenBSD$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org> |
|
|
|
|
typedef void (*v_check)(CHKARGS); |
typedef void (*v_check)(CHKARGS); |
|
|
static void check_abort(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); |
static void check_text(CHKARGS); |
static void check_text(CHKARGS); |
|
|
static void post_AT(CHKARGS); |
static void post_AT(CHKARGS); |
|
static void post_EE(CHKARGS); |
|
static void post_EX(CHKARGS); |
static void post_IP(CHKARGS); |
static void post_IP(CHKARGS); |
static void post_OP(CHKARGS); |
static void post_OP(CHKARGS); |
static void post_SH(CHKARGS); |
static void post_SH(CHKARGS); |
Line 78 static const v_check man_valids[MAN_MAX - MAN_TH] = { |
|
Line 80 static const v_check man_valids[MAN_MAX - MAN_TH] = { |
|
NULL, /* I */ |
NULL, /* I */ |
NULL, /* IR */ |
NULL, /* IR */ |
NULL, /* RI */ |
NULL, /* RI */ |
NULL, /* nf */ |
|
NULL, /* fi */ |
|
NULL, /* RE */ |
NULL, /* RE */ |
check_part, /* RS */ |
check_part, /* RS */ |
NULL, /* DT */ |
NULL, /* DT */ |
Line 90 static const v_check man_valids[MAN_MAX - MAN_TH] = { |
|
Line 90 static const v_check man_valids[MAN_MAX - MAN_TH] = { |
|
NULL, /* SY */ |
NULL, /* SY */ |
NULL, /* YS */ |
NULL, /* YS */ |
post_OP, /* OP */ |
post_OP, /* OP */ |
NULL, /* EX */ |
post_EX, /* EX */ |
NULL, /* EE */ |
post_EE, /* EE */ |
post_UR, /* UR */ |
post_UR, /* UR */ |
NULL, /* UE */ |
NULL, /* UE */ |
post_UR, /* MT */ |
post_UR, /* MT */ |
Line 101 static const v_check man_valids[MAN_MAX - MAN_TH] = { |
|
Line 101 static const v_check man_valids[MAN_MAX - MAN_TH] = { |
|
|
|
/* Validate the subtree rooted at man->last. */ |
/* Validate the subtree rooted at man->last. */ |
void |
void |
man_node_validate(struct roff_man *man) |
man_validate(struct roff_man *man) |
{ |
{ |
struct roff_node *n; |
struct roff_node *n; |
const v_check *cp; |
const v_check *cp; |
Line 128 man_node_validate(struct roff_man *man) |
|
Line 128 man_node_validate(struct roff_man *man) |
|
|
|
man->last = man->last->child; |
man->last = man->last->child; |
while (man->last != NULL) { |
while (man->last != NULL) { |
man_node_validate(man); |
man_validate(man); |
if (man->last == n) |
if (man->last == n) |
man->last = man->last->child; |
man->last = man->last->child; |
else |
else |
Line 160 man_node_validate(struct roff_man *man) |
|
Line 160 man_node_validate(struct roff_man *man) |
|
if (*cp) |
if (*cp) |
(*cp)(man, n); |
(*cp)(man, n); |
if (man->last == n) |
if (man->last == n) |
man_state(man, n); |
n->flags |= NODE_VALID; |
break; |
break; |
} |
} |
} |
} |
Line 185 check_root(CHKARGS) |
|
Line 185 check_root(CHKARGS) |
|
|
|
man->meta.title = mandoc_strdup(""); |
man->meta.title = mandoc_strdup(""); |
man->meta.msec = mandoc_strdup(""); |
man->meta.msec = mandoc_strdup(""); |
man->meta.date = man->quick ? mandoc_strdup("") : |
man->meta.date = mandoc_normdate(man, NULL, n->line, n->pos); |
mandoc_normdate(man, NULL, n->line, n->pos); |
|
} |
} |
|
|
if (man->meta.os_e && |
if (man->meta.os_e && |
Line 207 check_text(CHKARGS) |
|
Line 206 check_text(CHKARGS) |
|
{ |
{ |
char *cp, *p; |
char *cp, *p; |
|
|
if (MAN_LITERAL & man->flags) |
if (n->flags & NODE_NOFILL) |
return; |
return; |
|
|
cp = n->string; |
cp = n->string; |
Line 217 check_text(CHKARGS) |
|
Line 216 check_text(CHKARGS) |
|
} |
} |
|
|
static void |
static void |
|
post_EE(CHKARGS) |
|
{ |
|
if ((n->flags & NODE_NOFILL) == 0) |
|
mandoc_msg(MANDOCERR_FI_SKIP, n->line, n->pos, "EE"); |
|
} |
|
|
|
static void |
|
post_EX(CHKARGS) |
|
{ |
|
if (n->flags & NODE_NOFILL) |
|
mandoc_msg(MANDOCERR_NF_SKIP, n->line, n->pos, "EX"); |
|
} |
|
|
|
static void |
post_OP(CHKARGS) |
post_OP(CHKARGS) |
{ |
{ |
|
|
Line 355 post_TH(CHKARGS) |
|
Line 368 post_TH(CHKARGS) |
|
/* ->TITLE<- MSEC DATE OS VOL */ |
/* ->TITLE<- MSEC DATE OS VOL */ |
|
|
n = n->child; |
n = n->child; |
if (n && n->string) { |
if (n != NULL && n->string != NULL) { |
for (p = n->string; '\0' != *p; p++) { |
for (p = n->string; *p != '\0'; p++) { |
/* Only warn about this once... */ |
/* Only warn about this once... */ |
if (isalpha((unsigned char)*p) && |
if (isalpha((unsigned char)*p) && |
! isupper((unsigned char)*p)) { |
! isupper((unsigned char)*p)) { |
Line 374 post_TH(CHKARGS) |
|
Line 387 post_TH(CHKARGS) |
|
|
|
/* TITLE ->MSEC<- DATE OS VOL */ |
/* TITLE ->MSEC<- DATE OS VOL */ |
|
|
if (n) |
if (n != NULL) |
n = n->next; |
n = n->next; |
if (n && n->string) |
if (n != NULL && n->string != NULL) |
man->meta.msec = mandoc_strdup(n->string); |
man->meta.msec = mandoc_strdup(n->string); |
else { |
else { |
man->meta.msec = mandoc_strdup(""); |
man->meta.msec = mandoc_strdup(""); |
Line 386 post_TH(CHKARGS) |
|
Line 399 post_TH(CHKARGS) |
|
|
|
/* TITLE MSEC ->DATE<- OS VOL */ |
/* TITLE MSEC ->DATE<- OS VOL */ |
|
|
if (n) |
if (n != NULL) |
n = n->next; |
n = n->next; |
if (n && n->string && '\0' != n->string[0]) { |
if (n != NULL && n->string != NULL && n->string[0] != '\0') |
man->meta.date = man->quick ? |
man->meta.date = mandoc_normdate(man, |
mandoc_strdup(n->string) : |
n->string, n->line, n->pos); |
mandoc_normdate(man, n->string, n->line, n->pos); |
else { |
} else { |
|
man->meta.date = mandoc_strdup(""); |
man->meta.date = mandoc_strdup(""); |
mandoc_msg(MANDOCERR_DATE_MISSING, |
mandoc_msg(MANDOCERR_DATE_MISSING, |
n ? n->line : nb->line, |
n == NULL ? nb->line : n->line, |
n ? n->pos : nb->pos, "TH"); |
n == NULL ? nb->pos : n->pos, "TH"); |
} |
} |
|
|
/* TITLE MSEC DATE ->OS<- VOL */ |
/* TITLE MSEC DATE ->OS<- VOL */ |