-# $Id: Makefile,v 1.510 2017/05/04 22:16:09 schwarze Exp $
+# $Id: Makefile,v 1.511 2017/05/05 02:06:19 schwarze Exp $
#
# Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
# Copyright (c) 2011, 2013-2017 Ingo Schwarze <schwarze@openbsd.org>
roff.c \
roff_html.c \
roff_term.c \
+ roff_validate.c \
soelim.c \
st.c \
tag.c \
LIBROFF_OBJS = eqn.o \
roff.o \
+ roff_validate.o \
tbl.o \
tbl_data.o \
tbl_layout.o \
preconv.o: preconv.c config.h mandoc.h libmandoc.h
read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h libmandoc.h roff_int.h
roff.o: roff.c config.h mandoc.h mandoc_aux.h mandoc_ohash.h compat_ohash.h roff.h libmandoc.h roff_int.h libroff.h predefs.in
+roff_html.o: roff_html.c roff.h out.h html.h
+roff_term.o: roff_term.c roff.h out.h term.h
+roff_validate.o: roff_validate.c mandoc.h roff.h libmandoc.h roff_int.h
soelim.o: soelim.c config.h compat_stringlist.h
st.o: st.c config.h roff.h mdoc.h libmdoc.h st.in
tag.o: tag.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h tag.h
-/* $Id: man_html.c,v 1.138 2017/05/04 22:16:09 schwarze Exp $ */
+/* $Id: man_html.c,v 1.139 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
{ man_ign_pre, NULL }, /* PD */
{ man_ign_pre, NULL }, /* AT */
{ man_in_pre, NULL }, /* in */
- { man_ign_pre, NULL }, /* ft */
{ man_OP_pre, NULL }, /* OP */
{ NULL, NULL }, /* EX */
{ NULL, NULL }, /* EE */
-/* $Id: man_macro.c,v 1.117 2017/05/04 17:48:28 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.118 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
{ in_line_eoln, MAN_NSCOPED }, /* PD */
{ in_line_eoln, 0 }, /* AT */
{ in_line_eoln, 0 }, /* in */
- { in_line_eoln, 0 }, /* ft */
{ in_line_eoln, 0 }, /* OP */
{ in_line_eoln, MAN_BSCOPE }, /* EX */
{ in_line_eoln, MAN_BSCOPE }, /* EE */
break;
}
if (buf[*pos] != '\0' && man->last != n &&
- (tok == MAN_PD || tok == MAN_ft || tok == MAN_sp)) {
+ (tok == MAN_PD || tok == MAN_sp)) {
mandoc_vmsg(MANDOCERR_ARG_EXCESS,
man->parse, line, *pos, "%s ... %s",
roff_name[tok], buf + *pos);
-/* $Id: man_term.c,v 1.194 2017/05/04 22:16:09 schwarze Exp $ */
+/* $Id: man_term.c,v 1.195 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
static int pre_TP(DECL_ARGS);
static int pre_UR(DECL_ARGS);
static int pre_alternate(DECL_ARGS);
-static int pre_ft(DECL_ARGS);
static int pre_ign(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_literal(DECL_ARGS);
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
- { pre_ft, NULL, MAN_NOTEXT }, /* ft */
{ pre_OP, NULL, 0 }, /* OP */
{ pre_literal, NULL, 0 }, /* EX */
{ pre_literal, NULL, 0 }, /* EE */
return 0;
}
-static int
-pre_ft(DECL_ARGS)
-{
- const char *cp;
-
- if (NULL == n->child) {
- term_fontlast(p);
- return 0;
- }
-
- cp = n->child->string;
- switch (*cp) {
- case '4':
- case '3':
- case 'B':
- term_fontrepl(p, TERMFONT_BOLD);
- break;
- case '2':
- case 'I':
- term_fontrepl(p, TERMFONT_UNDER);
- break;
- case 'P':
- term_fontlast(p);
- break;
- case '1':
- case 'C':
- case 'R':
- term_fontrepl(p, TERMFONT_NONE);
- break;
- default:
- break;
- }
- return 0;
-}
-
static int
pre_in(DECL_ARGS)
{
static void post_AT(CHKARGS);
static void post_IP(CHKARGS);
static void post_vs(CHKARGS);
-static void post_ft(CHKARGS);
static void post_OP(CHKARGS);
static void post_TH(CHKARGS);
static void post_UC(CHKARGS);
NULL, /* PD */
post_AT, /* AT */
NULL, /* in */
- post_ft, /* ft */
post_OP, /* OP */
NULL, /* EX */
NULL, /* EE */
post_vs(man, n);
break;
default:
- abort();
+ roff_validate(man);
+ break;
}
break;
}
check_part(man, n);
}
-static void
-post_ft(CHKARGS)
-{
- char *cp;
- int ok;
-
- if (n->child == NULL)
- return;
-
- ok = 0;
- cp = n->child->string;
- switch (*cp) {
- case '1':
- case '2':
- case '3':
- case '4':
- case 'I':
- case 'P':
- 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) {
- mandoc_vmsg(MANDOCERR_FT_BAD, man->parse,
- n->line, n->pos, "ft %s", cp);
- *cp = '\0';
- }
-}
-
static void
check_part(CHKARGS)
{
.Fn deroff ,
.Fn roffhash_alloc ,
.Fn roffhash_find ,
+.Fn roffhash_free ,
and
-.Fn roffhash_free .
+.Fn roff_validate .
.Pp
Uses pointers to the types
.Vt struct mdoc_arg
-/* $Id: mdoc_html.c,v 1.282 2017/05/04 22:16:09 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.283 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org>
assert(h->tblt == NULL);
if (n->tok < ROFF_MAX) {
roff_html_pre(h, n);
+ child = 0;
break;
}
assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
-/* $Id: mdoc_man.c,v 1.110 2017/05/04 17:48:29 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.111 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
*
static int pre_fn(DECL_ARGS);
static int pre_fo(DECL_ARGS);
static int pre_ft(DECL_ARGS);
+static int pre_Ft(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_it(DECL_ARGS);
static int pre_lk(DECL_ARGS);
{ NULL, pre_fd, post_fd, NULL, NULL }, /* Fd */
{ NULL, pre_fl, post_fl, NULL, NULL }, /* Fl */
{ NULL, pre_fn, post_fn, NULL, NULL }, /* Fn */
- { NULL, pre_ft, post_font, NULL, NULL }, /* Ft */
+ { NULL, pre_Ft, post_font, NULL, NULL }, /* Ft */
{ NULL, pre_sy, post_font, NULL, NULL }, /* Ic */
{ NULL, pre_in, post_in, NULL, NULL }, /* In */
{ NULL, pre_li, post_font, NULL, NULL }, /* Li */
{ cond_head, pre_enc, NULL, "\\- ", NULL }, /* Nd */
{ NULL, pre_nm, post_nm, NULL, NULL }, /* Nm */
{ cond_body, pre_enc, post_enc, "[", "]" }, /* Op */
- { NULL, pre_ft, post_font, NULL, NULL }, /* Ot */
+ { NULL, pre_Ft, post_font, NULL, NULL }, /* Ot */
{ NULL, pre_em, post_font, NULL, NULL }, /* Pa */
{ NULL, pre_ex, NULL, NULL, NULL }, /* Rv */
{ NULL, NULL, NULL, NULL, NULL }, /* St */
} else if (n->tok < ROFF_MAX) {
switch (n->tok) {
case ROFF_br:
- pre_br(meta, n);
+ do_sub = pre_br(meta, n);
+ break;
+ case ROFF_ft:
+ do_sub = pre_ft(meta, n);
break;
default:
abort();
}
static int
-pre_ft(DECL_ARGS)
+pre_Ft(DECL_ARGS)
{
pre_syn(n);
return 1;
}
+static int
+pre_ft(DECL_ARGS)
+{
+ print_line(".ft", 0);
+ print_word(n->child->string);
+ outflags |= MMAN_nl;
+ return 0;
+}
+
static int
pre_in(DECL_ARGS)
{
-/* $Id: mdoc_markdown.c,v 1.18 2017/05/04 17:48:29 schwarze Exp $ */
+/* $Id: mdoc_markdown.c,v 1.19 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
*
} else if (n->tok < ROFF_MAX) {
switch (n->tok) {
case ROFF_br:
- md_pre_br(n);
+ process_children = md_pre_br(n);
+ break;
+ case ROFF_ft:
+ process_children = 0;
break;
default:
abort();
-/* $Id: mdoc_term.c,v 1.352 2017/05/04 22:16:09 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.353 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
default:
if (n->tok < ROFF_MAX) {
roff_term_pre(p, n);
+ chld = 0;
break;
}
assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
-/* $Id: mdoc_validate.c,v 1.323 2017/05/04 17:48:29 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.324 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
post_par(mdoc);
break;
default:
- abort();
+ roff_validate(mdoc);
+ break;
}
break;
}
# $OpenBSD: Makefile,v 1.1 2014/07/05 12:33:54 schwarze Exp $
-REGRESS_TARGETS = badargs
-LINT_TARGETS = badargs
+REGRESS_TARGETS = badargs badargs-mdoc
+LINT_TARGETS = badargs badargs-mdoc
+
+SKIP_TMAN = badargs
.include <bsd.regress.mk>
--- /dev/null
+.Dd May 5, 2017
+.Dt FT-BADARGS-MDOC 1
+.Os OpenBSD
+.Sh NAME
+.Nm ft-badargs-mdoc
+.Nd font request with bad arguments
+.Sh DESCRIPTION
+default font
+.ft B
+bold
+.ft foo
+still bold
+.ft I bogus
+italic
+.ft P
+back to bold
+.ft
+back to italic
--- /dev/null
+FT-BADARGS-MDOC(1) General Commands Manual FT-BADARGS-MDOC(1)
+
+N\bNA\bAM\bME\bE
+ f\bft\bt-\b-b\bba\bad\bda\bar\brg\bgs\bs-\b-m\bmd\bdo\boc\bc - font request with bad arguments
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ default font b\bbo\bol\bld\bd s\bst\bti\bil\bll\bl b\bbo\bol\bld\bd _\bi_\bt_\ba_\bl_\bi_\bc b\bba\bac\bck\bk t\bto\bo b\bbo\bol\bld\bd _\bb_\ba_\bc_\bk _\bt_\bo _\bi_\bt_\ba_\bl_\bi_\bc
+
+OpenBSD May 5, 2017 OpenBSD
--- /dev/null
+mandoc: badargs-mdoc.in:13:7: ERROR: skipping excess arguments: ft ... bogus
+mandoc: badargs-mdoc.in:11:2: WARNING: unknown font, skipping request: ft foo
-/* $Id: roff.c,v 1.296 2017/05/04 17:48:29 schwarze Exp $ */
+/* $Id: roff.c,v 1.297 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
static void roff_man_alloc1(struct roff_man *);
static void roff_man_free1(struct roff_man *);
static enum rofferr roff_nr(ROFF_ARGS);
+static enum rofferr roff_onearg(ROFF_ARGS);
static enum roff_tok roff_parse(struct roff *, char *, int *,
int, int);
static enum rofferr roff_parsetext(struct buf *, int, int *);
#define ROFFNUM_WHITE (1 << 1) /* Skip whitespace in roff_evalnum(). */
const char *__roff_name[MAN_MAX + 1] = {
- "br", NULL,
+ "br", "ft", NULL,
"ab", "ad", "af", "aln",
"als", "am", "am1", "ami",
"ami1", "as", "as1", "asciify",
"B", "I", "IR", "RI",
"sp", "nf", "fi",
"RE", "RS", "DT", "UC",
- "PD", "AT", "in", "ft",
+ "PD", "AT", "in",
"OP", "EX", "EE", "UR",
"UE", "ll", NULL
};
static struct roffmac roffs[TOKEN_NONE] = {
{ roff_br, NULL, NULL, 0 }, /* br */
+ { roff_onearg, NULL, NULL, 0 }, /* ft */
{ NULL, NULL, NULL, 0 }, /* ROFF_MAX */
{ roff_unsupp, NULL, NULL, 0 }, /* ab */
{ roff_line_ignore, NULL, NULL, 0 }, /* ad */
return ROFF_IGN;
}
+static enum rofferr
+roff_onearg(ROFF_ARGS)
+{
+ struct roff_node *n;
+ char *cp;
+
+ roff_elem_alloc(r->man, ln, ppos, tok);
+ n = r->man->last;
+
+ cp = buf->buf + pos;
+ if (*cp != '\0') {
+ while (*cp != '\0' && *cp != ' ')
+ cp++;
+ while (*cp == ' ')
+ *cp++ = '\0';
+ if (*cp != '\0')
+ mandoc_vmsg(MANDOCERR_ARG_EXCESS,
+ r->parse, ln, cp - buf->buf,
+ "%s ... %s", roff_name[tok], cp);
+ roff_word_alloc(r->man, ln, pos, buf->buf + pos);
+ }
+
+ n->flags |= NODE_LINE | NODE_VALID | NODE_ENDED;
+ r->man->last = n;
+ r->man->next = ROFF_NEXT_SIBLING;
+ return ROFF_IGN;
+}
+
static enum rofferr
roff_br(ROFF_ARGS)
{
-/* $Id: roff.h,v 1.43 2017/05/04 17:48:29 schwarze Exp $ */
+/* $Id: roff.h,v 1.44 2017/05/05 02:06:19 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
enum roff_tok {
ROFF_br = 0,
+ ROFF_ft,
ROFF_MAX,
ROFF_ab,
ROFF_ad,
ROFF_fschar,
ROFF_fspacewidth,
ROFF_fspecial,
- /* MAN_ft; ignored in mdoc(7) */
ROFF_ftr,
ROFF_fzoom,
ROFF_gcolor,
MAN_PD,
MAN_AT,
MAN_in,
- MAN_ft,
MAN_OP,
MAN_EX,
MAN_EE,
struct ohash *roffhash_alloc(enum roff_tok, enum roff_tok);
enum roff_tok roffhash_find(struct ohash *, const char *, size_t);
void roffhash_free(struct ohash *);
+void roff_validate(struct roff_man *);
#include <sys/types.h>
#include <assert.h>
+#include <stddef.h>
#include "roff.h"
#include "out.h"
static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = {
roff_html_pre_br, /* br */
+ NULL, /* ft */
};
roff_html_pre(struct html *h, const struct roff_node *n)
{
assert(n->tok < ROFF_MAX);
- (*roff_html_pre_acts[n->tok])(h, n);
+ if (roff_html_pre_acts[n->tok] != NULL)
+ (*roff_html_pre_acts[n->tok])(h, n);
}
static void
/* $OpenBSD$ */
/*
- * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2017 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
typedef void (*roff_term_pre_fp)(ROFF_TERM_ARGS);
static void roff_term_pre_br(ROFF_TERM_ARGS);
+static void roff_term_pre_ft(ROFF_TERM_ARGS);
static const roff_term_pre_fp roff_term_pre_acts[ROFF_MAX] = {
roff_term_pre_br, /* br */
+ roff_term_pre_ft, /* ft */
};
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
}
}
+
+static void
+roff_term_pre_ft(ROFF_TERM_ARGS)
+{
+ switch (*n->child->string) {
+ case '4':
+ case '3':
+ case 'B':
+ term_fontrepl(p, TERMFONT_BOLD);
+ break;
+ case '2':
+ case 'I':
+ term_fontrepl(p, TERMFONT_UNDER);
+ break;
+ case 'P':
+ term_fontlast(p);
+ break;
+ case '1':
+ case 'C':
+ case 'R':
+ term_fontrepl(p, TERMFONT_NONE);
+ break;
+ default:
+ break;
+ }
+}
--- /dev/null
+/* $OpenBSD: roff_html.c,v 1.1 2017/05/04 22:07:44 schwarze Exp $ */
+/*
+ * Copyright (c) 2010, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <sys/types.h>
+
+#include <assert.h>
+#include <stddef.h>
+
+#include "mandoc.h"
+#include "roff.h"
+#include "libmandoc.h"
+#include "roff_int.h"
+
+#define ROFF_VALID_ARGS struct roff_man *man, struct roff_node *n
+
+typedef void (*roff_valid_fp)(ROFF_VALID_ARGS);
+
+static void roff_valid_ft(ROFF_VALID_ARGS);
+
+static const roff_valid_fp roff_valids[ROFF_MAX] = {
+ NULL, /* br */
+ roff_valid_ft, /* ft */
+};
+
+
+void
+roff_validate(struct roff_man *man)
+{
+ struct roff_node *n;
+
+ n = man->last;
+ assert(n->tok < ROFF_MAX);
+ if (roff_valids[n->tok] != NULL)
+ (*roff_valids[n->tok])(man, n);
+}
+
+static void
+roff_valid_ft(ROFF_VALID_ARGS)
+{
+ char *cp;
+
+ if (n->child == NULL) {
+ man->next = ROFF_NEXT_CHILD;
+ roff_word_alloc(man, n->line, n->pos, "P");
+ man->last = n;
+ return;
+ }
+
+ cp = n->child->string;
+ switch (*cp) {
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case 'I':
+ case 'P':
+ case 'R':
+ if (cp[1] == '\0')
+ return;
+ break;
+ case 'B':
+ if (cp[1] == '\0' || (cp[1] == 'I' && cp[2] == '\0'))
+ return;
+ break;
+ case 'C':
+ if (cp[1] == 'W' && cp[2] == '\0')
+ return;
+ break;
+ default:
+ break;
+ }
+
+ mandoc_vmsg(MANDOCERR_FT_BAD, man->parse,
+ n->line, n->pos, "ft %s", cp);
+ roff_node_delete(man, n);
+}