diff options
-rw-r--r-- | mdoc.7 | 14 | ||||
-rw-r--r-- | mdoc.c | 6 | ||||
-rw-r--r-- | mdoc_action.c | 9 | ||||
-rw-r--r-- | mdoc_validate.c | 27 |
4 files changed, 40 insertions, 16 deletions
@@ -1408,13 +1408,15 @@ This is the mandatory second macro of any file. Its calling syntax is as follows: .Pp -.D1 \. Ns Sx \&Dt Cm title section Op Cm volume | arch +.D1 \. Ns Sx \&Dt Op Cm title Op Cm section Op Cm volume | arch .Pp Its arguments are as follows: .Bl -tag -width Ds -offset Ds .It Cm title -The document's title (name). -This should be capitalised and is required. +The document's title (name), defaulting to +.Qq UNKNOWN +if unspecified. +It should be capitalised. .It Cm section The manual section. This may be one of @@ -1451,8 +1453,9 @@ This may be one of or .Ar paper .Pq paper . -It is also required and should correspond to the manual's filename -suffix. +It should correspond to the manual's filename suffix and defaults to +.Qq 1 +if unspecified. .It Cm volume This overrides the volume inferred from .Ar section . @@ -1524,7 +1527,6 @@ Examples: .D1 \&.Dt FOO 1 .D1 \&.Dt FOO 4 KM .D1 \&.Dt FOO 9 i386 -.D1 \&.Dt FOO 9 KM i386 .Pp See also .Sx \&Dd @@ -276,11 +276,11 @@ mdoc_macro(struct mdoc *m, enum mdoct tok, if ( ! mdoc_pmsg(m, ln, pp, MANDOCERR_BADPROLOG)) return(0); if (NULL == m->meta.title) - m->meta.title = mandoc_strdup("unknown"); + m->meta.title = mandoc_strdup("UNKNOWN"); if (NULL == m->meta.vol) - m->meta.vol = mandoc_strdup("local"); + m->meta.vol = mandoc_strdup("LOCAL"); if (NULL == m->meta.os) - m->meta.os = mandoc_strdup("local"); + m->meta.os = mandoc_strdup("LOCAL"); if (0 == m->meta.date) m->meta.date = time(NULL); m->flags |= MDOC_PBODY; diff --git a/mdoc_action.c b/mdoc_action.c index 9ac5e604..3d94c3fd 100644 --- a/mdoc_action.c +++ b/mdoc_action.c @@ -499,8 +499,8 @@ post_dt(POST_ARGS) if (NULL == (nn = n->child)) { /* XXX: make these macro values. */ /* FIXME: warn about missing values. */ - m->meta.title = mandoc_strdup("unknown"); - m->meta.vol = mandoc_strdup("local"); + m->meta.title = mandoc_strdup("UNKNOWN"); + m->meta.vol = mandoc_strdup("LOCAL"); m->meta.msec = mandoc_strdup("1"); return(post_prol(m, n)); } @@ -509,12 +509,13 @@ post_dt(POST_ARGS) * --> title = TITLE, volume = local, msec = 0, arch = NULL */ - m->meta.title = mandoc_strdup(nn->string); + m->meta.title = mandoc_strdup + ('\0' == nn->string[0] ? "UNKNOWN" : nn->string); if (NULL == (nn = nn->next)) { /* FIXME: warn about missing msec. */ /* XXX: make this a macro value. */ - m->meta.vol = mandoc_strdup("local"); + m->meta.vol = mandoc_strdup("LOCAL"); m->meta.msec = mandoc_strdup("1"); return(post_prol(m, n)); } diff --git a/mdoc_validate.c b/mdoc_validate.c index c1381bb2..30d7ea8d 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -83,6 +83,7 @@ static int post_at(POST_ARGS); static int post_bf(POST_ARGS); static int post_bl(POST_ARGS); static int post_bl_head(POST_ARGS); +static int post_dt(POST_ARGS); static int post_it(POST_ARGS); static int post_lb(POST_ARGS); static int post_nm(POST_ARGS); @@ -113,6 +114,7 @@ static v_post posts_bf[] = { hwarn_le1, post_bf, NULL }; static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL }; static v_post posts_bool[] = { eerr_eq1, ebool, NULL }; static v_post posts_eoln[] = { post_eoln, NULL }; +static v_post posts_dt[] = { post_dt, NULL }; static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL }; static v_post posts_it[] = { post_it, NULL }; static v_post posts_lb[] = { eerr_eq1, post_lb, NULL }; @@ -147,7 +149,7 @@ static v_pre pres_ss[] = { pre_ss, NULL }; const struct valids mdoc_valids[MDOC_MAX] = { { NULL, NULL }, /* Ap */ { pres_dd, posts_text }, /* Dd */ - { pres_dt, NULL }, /* Dt */ + { pres_dt, posts_dt }, /* Dt */ { pres_os, NULL }, /* Os */ { pres_sh, posts_sh }, /* Sh */ { pres_ss, posts_ss }, /* Ss */ @@ -738,10 +740,29 @@ pre_rv(PRE_ARGS) static int -pre_dt(PRE_ARGS) +post_dt(POST_ARGS) { + const struct mdoc_node *nn; + const char *p; + + if (NULL != (nn = mdoc->last->child)) + for (p = nn->string; *p; p++) { + if ( ! isalpha((u_char)*p)) + continue; + if (isupper((u_char)*p)) + continue; + if ( ! mdoc_nmsg(mdoc, nn, MANDOCERR_UPPERCASE)) + return(0); + break; + } - /* FIXME: make sure is capitalised. */ + return(1); +} + + +static int +pre_dt(PRE_ARGS) +{ if (0 == mdoc->meta.date || mdoc->meta.os) if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO)) |