-/* $Id: mandoc.h,v 1.86 2014/07/09 11:30:07 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.87 2014/08/08 15:10:14 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged */
MANDOCERR_BL_LATETYPE, /* list type is not the first argument: arg */
MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */
+ MANDOCERR_EX_NONAME, /* missing name for .Ex, using "" */
MANDOCERR_IT_NOHEAD, /* empty head in list item: type */
MANDOCERR_IT_NOBODY, /* empty list item: type */
MANDOCERR_BF_NOFONT, /* missing font type, using \fR */
/* related to request and macro arguments */
MANDOCERR_NAMESC, /* escaped character not allowed in a name */
- MANDOCERR_NONAME, /* manual name not yet set */
MANDOCERR_ARGCOUNT, /* argument count wrong */
+ MANDOCERR_NM_NONAME, /* missing manual name, using "" */
MANDOCERR_ST_BAD, /* unknown standard specifier: standard */
MANDOCERR_UNAME, /* uname(3) system call failed */
MANDOCERR_NUMERIC, /* request requires a numeric argument */
-/* $Id: mdoc_html.c,v 1.75 2014/07/02 19:54:39 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.76 2014/08/08 15:10:14 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
}
if (nchild > 1)
- print_text(h, "utilities exit");
+ print_text(h, "utilities exit\\~0");
else
- print_text(h, "utility exits");
+ print_text(h, "utility exits\\~0");
- print_text(h, "0 on success, and >0 if an error occurs.");
+ print_text(h, "on success, and\\~>0 if an error occurs.");
return(0);
}
PAIR_CLASS_INIT(&tag, "fname");
- print_text(h, "The");
-
nchild = n->nchild;
- for (n = n->child; n; n = n->next) {
- assert(MDOC_TEXT == n->type);
+ if (nchild > 0) {
+ print_text(h, "The");
- t = print_otag(h, TAG_B, 1, &tag);
- print_text(h, n->string);
- print_tagq(h, t);
-
- h->flags |= HTML_NOSPACE;
- print_text(h, "()");
+ for (n = n->child; n; n = n->next) {
+ t = print_otag(h, TAG_B, 1, &tag);
+ print_text(h, n->string);
+ print_tagq(h, t);
- if (nchild > 2 && n->next) {
h->flags |= HTML_NOSPACE;
- print_text(h, ",");
+ print_text(h, "()");
+
+ if (n->next == NULL)
+ continue;
+
+ if (nchild > 2) {
+ h->flags |= HTML_NOSPACE;
+ print_text(h, ",");
+ }
+ if (n->next->next == NULL)
+ print_text(h, "and");
}
- if (n->next && NULL == n->next->next)
- print_text(h, "and");
- }
+ if (nchild > 1)
+ print_text(h, "functions return");
+ else
+ print_text(h, "function returns");
- if (nchild > 1)
- print_text(h, "functions return");
- else
- print_text(h, "function returns");
+ print_text(h, "the value\\~0 if successful;");
+ } else
+ print_text(h, "Upon successful completion,"
+ " the value\\~0 is returned;");
- print_text(h, "the value 0 if successful; otherwise the "
- "value -1 is returned and the global variable");
+ print_text(h, "otherwise the value\\~\\-1 is returned"
+ " and the global variable");
PAIR_CLASS_INIT(&tag, "var");
t = print_otag(h, TAG_B, 1, &tag);
-/* $Id: mdoc_man.c,v 1.65 2014/07/04 16:11:41 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.66 2014/08/08 15:10:15 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
static int pre_enc(DECL_ARGS);
static int pre_em(DECL_ARGS);
static int pre_es(DECL_ARGS);
+static int pre_ex(DECL_ARGS);
static int pre_fa(DECL_ARGS);
static int pre_fd(DECL_ARGS);
static int pre_fl(DECL_ARGS);
static int pre_ns(DECL_ARGS);
static int pre_pp(DECL_ARGS);
static int pre_rs(DECL_ARGS);
+static int pre_rv(DECL_ARGS);
static int pre_sm(DECL_ARGS);
static int pre_sp(DECL_ARGS);
static int pre_sect(DECL_ARGS);
{ NULL, pre_li, post_font, NULL, NULL }, /* Dv */
{ NULL, pre_li, post_font, NULL, NULL }, /* Er */
{ NULL, pre_li, post_font, NULL, NULL }, /* Ev */
- { NULL, pre_enc, post_enc, "The \\fB",
- "\\fP\nutility exits 0 on success, and >0 if an error occurs."
- }, /* Ex */
+ { NULL, pre_ex, NULL, NULL, NULL }, /* Ex */
{ NULL, pre_fa, post_fa, NULL, NULL }, /* Fa */
{ NULL, pre_fd, post_fd, NULL, NULL }, /* Fd */
{ NULL, pre_fl, post_fl, NULL, NULL }, /* Fl */
{ cond_body, pre_enc, post_enc, "[", "]" }, /* Op */
{ NULL, pre_ft, post_font, NULL, NULL }, /* Ot */
{ NULL, pre_em, post_font, NULL, NULL }, /* Pa */
- { NULL, pre_enc, post_enc, "The \\fB",
- "\\fP\nfunction returns the value 0 if successful;\n"
- "otherwise the value -1 is returned and the global\n"
- "variable \\fIerrno\\fP is set to indicate the error."
- }, /* Rv */
+ { NULL, pre_rv, NULL, NULL, NULL }, /* Rv */
{ NULL, NULL, NULL, NULL, NULL }, /* St */
{ NULL, pre_em, post_font, NULL, NULL }, /* Va */
{ NULL, pre_vt, post_vt, NULL, NULL }, /* Vt */
print_word(suffix);
}
+static int
+pre_ex(DECL_ARGS)
+{
+ int nchild;
+
+ outflags |= MMAN_br | MMAN_nl;
+
+ print_word("The");
+
+ nchild = n->nchild;
+ for (n = n->child; n; n = n->next) {
+ font_push('B');
+ print_word(n->string);
+ font_pop();
+
+ if (n->next == NULL)
+ continue;
+
+ if (nchild > 2) {
+ outflags &= ~MMAN_spc;
+ print_word(",");
+ }
+ if (n->next->next == NULL)
+ print_word("and");
+ }
+
+ if (nchild > 1)
+ print_word("utilities exit\\~0");
+ else
+ print_word("utility exits\\~0");
+
+ print_word("on success, and\\~>0 if an error occurs.");
+ outflags |= MMAN_nl;
+ return(0);
+}
+
static void
post_font(DECL_ARGS)
{
case MDOC_HEAD:
/* FALLTHROUGH */
case MDOC_ELEM:
- font_pop();
+ if (n->child != NULL || meta->name != NULL)
+ font_pop();
break;
default:
break;
return(1);
}
+static int
+pre_rv(DECL_ARGS)
+{
+ int nchild;
+
+ outflags |= MMAN_br | MMAN_nl;
+
+ nchild = n->nchild;
+ if (nchild > 0) {
+ print_word("The");
+
+ for (n = n->child; n; n = n->next) {
+ font_push('B');
+ print_word(n->string);
+ font_pop();
+
+ outflags &= ~MMAN_spc;
+ print_word("()");
+
+ if (n->next == NULL)
+ continue;
+
+ if (nchild > 2) {
+ outflags &= ~MMAN_spc;
+ print_word(",");
+ }
+ if (n->next->next == NULL)
+ print_word("and");
+ }
+
+ if (nchild > 1)
+ print_word("functions return");
+ else
+ print_word("function returns");
+
+ print_word("the value\\~0 if successful;");
+ } else
+ print_word("Upon successful completion, "
+ "the value\\~0 is returned;");
+
+ print_word("otherwise the value\\~\\-1 is returned"
+ " and the global variable");
+
+ font_push('I');
+ print_word("errno");
+ font_pop();
+
+ print_word("is set to indicate the error.");
+ outflags |= MMAN_nl;
+ return(0);
+}
+
static int
pre_sm(DECL_ARGS)
{
-/* $Id: mdoc_term.c,v 1.174 2014/08/08 15:03:24 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.175 2014/08/08 15:10:15 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
int nchild;
term_newln(p);
- term_word(p, "The");
nchild = n->nchild;
- for (n = n->child; n; n = n->next) {
- term_fontpush(p, TERMFONT_BOLD);
- term_word(p, n->string);
- term_fontpop(p);
+ if (nchild > 0) {
+ term_word(p, "The");
- p->flags |= TERMP_NOSPACE;
- term_word(p, "()");
+ for (n = n->child; n; n = n->next) {
+ term_fontpush(p, TERMFONT_BOLD);
+ term_word(p, n->string);
+ term_fontpop(p);
- if (nchild > 2 && n->next) {
p->flags |= TERMP_NOSPACE;
- term_word(p, ",");
+ term_word(p, "()");
+
+ if (n->next == NULL)
+ continue;
+
+ if (nchild > 2) {
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, ",");
+ }
+ if (n->next->next == NULL)
+ term_word(p, "and");
}
- if (n->next && NULL == n->next->next)
- term_word(p, "and");
- }
+ if (nchild > 1)
+ term_word(p, "functions return");
+ else
+ term_word(p, "function returns");
- if (nchild > 1)
- term_word(p, "functions return");
- else
- term_word(p, "function returns");
+ term_word(p, "the value\\~0 if successful;");
+ } else
+ term_word(p, "Upon successful completion,"
+ " the value\\~0 is returned;");
- term_word(p, "the value 0 if successful; otherwise the "
- "value -1 is returned and the global variable");
+ term_word(p, "otherwise the value\\~\\-1 is returned"
+ " and the global variable");
term_fontpush(p, TERMFONT_UNDER);
term_word(p, "errno");
}
if (nchild > 1)
- term_word(p, "utilities exit");
+ term_word(p, "utilities exit\\~0");
else
- term_word(p, "utility exits");
+ term_word(p, "utility exits\\~0");
- term_word(p, "0 on success, and >0 if an error occurs.");
+ term_word(p, "on success, and\\~>0 if an error occurs.");
p->flags |= TERMP_SENTENCE;
return(0);
-/* $Id: mdoc_validate.c,v 1.149 2014/08/08 15:03:25 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.150 2014/08/08 15:10:15 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
static int post_en(POST_ARGS);
static int post_es(POST_ARGS);
static int post_eoln(POST_ARGS);
+static int post_ex(POST_ARGS);
static int post_hyph(POST_ARGS);
static int post_ignpar(POST_ARGS);
static int post_it(POST_ARGS);
static int post_sh_body(POST_ARGS);
static int post_sh_head(POST_ARGS);
static int post_st(POST_ARGS);
-static int post_std(POST_ARGS);
static int post_vt(POST_ARGS);
static int pre_an(PRE_ARGS);
static int pre_bd(PRE_ARGS);
static v_post posts_dt[] = { post_dt, post_prol, NULL };
static v_post posts_en[] = { post_en, NULL };
static v_post posts_es[] = { post_es, NULL };
+static v_post posts_ex[] = { post_ex, NULL };
static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL };
static v_post posts_hyph[] = { post_hyph, NULL };
static v_post posts_hyphtext[] = { ewarn_ge1, post_hyph, NULL };
static v_post posts_sp[] = { post_par, ewarn_le1, NULL };
static v_post posts_ss[] = { post_ignpar, hwarn_ge1, post_hyph, NULL };
static v_post posts_st[] = { post_st, NULL };
-static v_post posts_std[] = { post_std, NULL };
static v_post posts_text[] = { ewarn_ge1, NULL };
static v_post posts_text1[] = { ewarn_eq1, NULL };
static v_post posts_vt[] = { post_vt, NULL };
{ NULL, NULL }, /* Dv */
{ NULL, NULL }, /* Er */
{ NULL, NULL }, /* Ev */
- { pres_std, posts_std }, /* Ex */
+ { pres_std, posts_ex }, /* Ex */
{ NULL, NULL }, /* Fa */
{ NULL, posts_text }, /* Fd */
{ NULL, NULL }, /* Fl */
{ NULL, NULL }, /* Op */
{ pres_obsolete, NULL }, /* Ot */
{ NULL, posts_defaults }, /* Pa */
- { pres_std, posts_std }, /* Rv */
+ { pres_std, NULL }, /* Rv */
{ NULL, posts_st }, /* St */
{ NULL, NULL }, /* Va */
{ NULL, posts_vt }, /* Vt */
for (i = 0; i < (int)v->sz; i++)
check_text(mdoc, v->line, v->pos, v->value[i]);
-
- /* FIXME: move to post_std(). */
-
- if (MDOC_Std == v->arg)
- if ( ! (v->sz || mdoc->meta.name))
- mdoc_nmsg(mdoc, n, MANDOCERR_NONAME);
}
static void
mdoc_deroff(&mdoc->meta.name, mdoc->last);
- if (NULL == mdoc->meta.name) {
- mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NONAME);
- mdoc->meta.name = mandoc_strdup("UNKNOWN");
- }
+ if (NULL == mdoc->meta.name)
+ mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NM_NONAME);
return(1);
}
return(1);
}
+/*
+ * If no argument is provided,
+ * fill in the name of the current manual page.
+ */
static int
-post_std(POST_ARGS)
+post_ex(POST_ARGS)
{
- struct mdoc_node *nn, *n;
+ struct mdoc_node *n;
n = mdoc->last;
- /*
- * Macros accepting `-std' as an argument have the name of the
- * current document (`Nm') filled in as the argument if it's not
- * provided.
- */
-
if (n->child)
return(1);
- if (NULL == mdoc->meta.name)
+ if (mdoc->meta.name == NULL) {
+ mdoc_nmsg(mdoc, n, MANDOCERR_EX_NONAME);
return(1);
+ }
- nn = n;
mdoc->next = MDOC_NEXT_CHILD;
if ( ! mdoc_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name))
return(0);
- mdoc->last = nn;
+ mdoc->last = n;
return(1);
}
-/* $Id: read.c,v 1.47 2014/07/09 11:30:07 schwarze Exp $ */
+/* $Id: read.c,v 1.48 2014/08/08 15:10:15 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
"missing display type, using -ragged",
"list type is not the first argument",
"missing -width in -tag list, using 8n",
+ "missing name for .Ex, using \"\"",
"empty head in list item",
"empty list item",
"missing font type, using \\fR",
/* related to request and macro arguments */
"escaped character not allowed in a name",
- "manual name not yet set",
"argument count wrong",
+ "missing manual name, using \"\"",
"unknown standard specifier",
"uname(3) system call failed",
"request requires a numeric argument",