source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Move handling of the roff(7) .ft request from the man(7)
@ 2017-05-05  2:06 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-05-05  2:06 UTC (permalink / raw)
  To: source

Log Message:
-----------
Move handling of the roff(7) .ft request from the man(7) 
modules to the new roff(7) modules.  As a side effect, 
mdoc(7) now handles .ft, too.  Of course, do not use that.

Modified Files:
--------------
    mdocml:
        Makefile
        Makefile.depend
        man_html.c
        man_macro.c
        man_term.c
        man_validate.c
        mandoc_headers.3
        mdoc_html.c
        mdoc_man.c
        mdoc_markdown.c
        mdoc_term.c
        mdoc_validate.c
        roff.c
        roff.h
        roff_html.c
        roff_term.c
    mdocml/regress/roff/ft:
        Makefile

Added Files:
-----------
    mdocml:
        roff_validate.c
    mdocml/regress/roff/ft:
        badargs-mdoc.in
        badargs-mdoc.out_ascii
        badargs-mdoc.out_lint

Revision Data
-------------
Index: man_macro.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_macro.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -Lman_macro.c -Lman_macro.c -u -p -r1.117 -r1.118
--- man_macro.c
+++ man_macro.c
@@ -71,7 +71,6 @@ const	struct man_macro __man_macros[MAN_
 	{ 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 */
@@ -334,7 +333,7 @@ in_line_eoln(MACRO_PROT_ARGS)
 			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);
Index: roff.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -Lroff.h -Lroff.h -u -p -r1.43 -r1.44
--- roff.h
+++ roff.h
@@ -67,6 +67,7 @@ enum	roff_type {
 
 enum	roff_tok {
 	ROFF_br = 0,
+	ROFF_ft,
 	ROFF_MAX,
 	ROFF_ab,
 	ROFF_ad,
@@ -156,7 +157,6 @@ enum	roff_tok {
 	ROFF_fschar,
 	ROFF_fspacewidth,
 	ROFF_fspecial,
-	/* MAN_ft; ignored in mdoc(7) */
 	ROFF_ftr,
 	ROFF_fzoom,
 	ROFF_gcolor,
@@ -464,7 +464,6 @@ enum	roff_tok {
 	MAN_PD,
 	MAN_AT,
 	MAN_in,
-	MAN_ft,
 	MAN_OP,
 	MAN_EX,
 	MAN_EE,
@@ -576,3 +575,4 @@ void		 deroff(char **, const struct roff
 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 *);
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_html.c,v
retrieving revision 1.282
retrieving revision 1.283
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.282 -r1.283
--- mdoc_html.c
+++ mdoc_html.c
@@ -395,6 +395,7 @@ print_mdoc_node(MDOC_ARGS)
 		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);
Index: mdoc_markdown.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_markdown.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -Lmdoc_markdown.c -Lmdoc_markdown.c -u -p -r1.18 -r1.19
--- mdoc_markdown.c
+++ mdoc_markdown.c
@@ -323,7 +323,10 @@ md_node(struct roff_node *n)
 	} 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();
Index: man_validate.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_validate.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -Lman_validate.c -Lman_validate.c -u -p -r1.124 -r1.125
--- man_validate.c
+++ man_validate.c
@@ -48,7 +48,6 @@ static	void	  check_text(CHKARGS);
 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);
@@ -85,7 +84,6 @@ static	const v_check __man_valids[MAN_MA
 	NULL,       /* PD */
 	post_AT,    /* AT */
 	NULL,       /* in */
-	post_ft,    /* ft */
 	post_OP,    /* OP */
 	NULL,       /* EX */
 	NULL,       /* EE */
@@ -131,7 +129,8 @@ man_node_validate(struct roff_man *man)
 				post_vs(man, n);
 				break;
 			default:
-				abort();
+				roff_validate(man);
+				break;
 			}
 			break;
 		}
@@ -209,47 +208,6 @@ post_UR(CHKARGS)
 		mandoc_vmsg(MANDOCERR_UR_NOHEAD, man->parse,
 		    n->line, n->pos, "UR");
 	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
Index: roff_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff_term.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lroff_term.c -Lroff_term.c -u -p -r1.1 -r1.2
--- roff_term.c
+++ roff_term.c
@@ -1,6 +1,6 @@
 /*	$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
@@ -27,9 +27,11 @@
 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 */
 };
 
 
@@ -48,5 +50,31 @@ roff_term_pre_br(ROFF_TERM_ARGS)
 		p->offset = p->rmargin;
 		p->rmargin = p->maxrmargin;
 		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;
 	}
 }
Index: roff_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff_html.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lroff_html.c -Lroff_html.c -u -p -r1.1 -r1.2
--- roff_html.c
+++ roff_html.c
@@ -17,6 +17,7 @@
 #include <sys/types.h>
 
 #include <assert.h>
+#include <stddef.h>
 
 #include "roff.h"
 #include "out.h"
@@ -30,6 +31,7 @@ static	void	  roff_html_pre_br(ROFF_HTML
 
 static	const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = {
 	roff_html_pre_br,  /* br */
+	NULL,  /* ft */
 };
 
 
@@ -37,7 +39,8 @@ void
 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
Index: Makefile
===================================================================
RCS file: /home/cvs/mdocml/mdocml/Makefile,v
retrieving revision 1.510
retrieving revision 1.511
diff -LMakefile -LMakefile -u -p -r1.510 -r1.511
--- Makefile
+++ Makefile
@@ -112,6 +112,7 @@ SRCS		 = att.c \
 		   roff.c \
 		   roff_html.c \
 		   roff_term.c \
+		   roff_validate.c \
 		   soelim.c \
 		   st.c \
 		   tag.c \
@@ -212,6 +213,7 @@ LIBMDOC_OBJS	 = att.o \
 
 LIBROFF_OBJS	 = eqn.o \
 		   roff.o \
+		   roff_validate.o \
 		   tbl.o \
 		   tbl_data.o \
 		   tbl_layout.o \
Index: Makefile.depend
===================================================================
RCS file: /home/cvs/mdocml/mdocml/Makefile.depend,v
retrieving revision 1.29
retrieving revision 1.30
diff -LMakefile.depend -LMakefile.depend -u -p -r1.29 -r1.30
--- Makefile.depend
+++ Makefile.depend
@@ -57,6 +57,9 @@ out.o: out.c config.h mandoc_aux.h mando
 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
--- /dev/null
+++ roff_validate.c
@@ -0,0 +1,89 @@
+/*	$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);
+}
Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -Lman_term.c -Lman_term.c -u -p -r1.194 -r1.195
--- man_term.c
+++ man_term.c
@@ -80,7 +80,6 @@ static	int		  pre_SS(DECL_ARGS);
 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);
@@ -126,7 +125,6 @@ static	const struct termact __termacts[M
 	{ 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 */
@@ -358,41 +356,6 @@ pre_OP(DECL_ARGS)
 	term_fontrepl(p, TERMFONT_NONE);
 	p->flags |= TERMP_NOSPACE;
 	term_word(p, "]");
-	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;
 }
 
Index: man_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_html.c,v
retrieving revision 1.138
retrieving revision 1.139
diff -Lman_html.c -Lman_html.c -u -p -r1.138 -r1.139
--- man_html.c
+++ man_html.c
@@ -102,7 +102,6 @@ static	const struct htmlman __mans[MAN_M
 	{ 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 */
Index: mandoc_headers.3
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc_headers.3,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lmandoc_headers.3 -Lmandoc_headers.3 -u -p -r1.12 -r1.13
--- mandoc_headers.3
+++ mandoc_headers.3
@@ -144,8 +144,9 @@ and the functions
 .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
Index: roff.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.c,v
retrieving revision 1.296
retrieving revision 1.297
diff -Lroff.c -Lroff.c -u -p -r1.296 -r1.297
--- roff.c
+++ roff.c
@@ -182,6 +182,7 @@ static	enum rofferr	 roff_line_ignore(RO
 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 *);
@@ -210,7 +211,7 @@ static	enum rofferr	 roff_userdef(ROFF_A
 #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",
@@ -309,7 +310,7 @@ const char *__roff_name[MAN_MAX + 1] = {
 	"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
 };
@@ -317,6 +318,7 @@ const	char *const *roff_name = __roff_na
 
 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 */
@@ -2763,6 +2765,34 @@ roff_TS(ROFF_ARGS)
 		r->first_tbl = r->last_tbl = tbl;
 
 	r->tbl = r->last_tbl = tbl;
+	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;
 }
 
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.352
retrieving revision 1.353
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.352 -r1.353
--- mdoc_term.c
+++ mdoc_term.c
@@ -366,6 +366,7 @@ print_mdoc_node(DECL_ARGS)
 	default:
 		if (n->tok < ROFF_MAX) {
 			roff_term_pre(p, n);
+			chld = 0;
 			break;
 		}
 		assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
Index: mdoc_man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_man.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.110 -r1.111
--- mdoc_man.c
+++ mdoc_man.c
@@ -94,6 +94,7 @@ static	int	  pre_fl(DECL_ARGS);
 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);
@@ -148,14 +149,14 @@ static	const struct manact __manacts[MDO
 	{ 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 */
@@ -654,7 +655,10 @@ print_node(DECL_ARGS)
 	} 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();
@@ -1314,12 +1318,21 @@ post_fo(DECL_ARGS)
 }
 
 static int
-pre_ft(DECL_ARGS)
+pre_Ft(DECL_ARGS)
 {
 
 	pre_syn(n);
 	font_push('I');
 	return 1;
+}
+
+static int
+pre_ft(DECL_ARGS)
+{
+	print_line(".ft", 0);
+	print_word(n->child->string);
+	outflags |= MMAN_nl;
+	return 0;
 }
 
 static int
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_validate.c,v
retrieving revision 1.323
retrieving revision 1.324
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.323 -r1.324
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -332,7 +332,8 @@ mdoc_node_validate(struct roff_man *mdoc
 				post_par(mdoc);
 				break;
 			default:
-				abort();
+				roff_validate(mdoc);
+				break;
 			}
 			break;
 		}
--- /dev/null
+++ regress/roff/ft/badargs-mdoc.out_ascii
@@ -0,0 +1,9 @@
+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
+++ regress/roff/ft/badargs-mdoc.out_lint
@@ -0,0 +1,2 @@
+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
--- /dev/null
+++ regress/roff/ft/badargs-mdoc.in
@@ -0,0 +1,18 @@
+.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
Index: Makefile
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/roff/ft/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/roff/ft/Makefile -Lregress/roff/ft/Makefile -u -p -r1.1 -r1.2
--- regress/roff/ft/Makefile
+++ regress/roff/ft/Makefile
@@ -1,6 +1,8 @@
 # $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>
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-05  2:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05  2:06 mdocml: Move handling of the roff(7) .ft request from the man(7) schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).