source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Do not rewrite MAN_LP and MAN_P to MAN_PP because doing that
@ 2023-04-28 20:23 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2023-04-28 20:23 UTC (permalink / raw)
  To: source

Log Message:
-----------
Do not rewrite MAN_LP and MAN_P to MAN_PP because doing that causes
confusing warning messages complaining about macros that don't even
appear in the input file.
As a welcome side effect, this also shortens the code...

Fixing a minibug
reported by Alejandro Colomar <alx dot manpages at gmail dot com>.

Modified Files:
--------------
    mandoc:
        man_html.c
        man_term.c
        man_validate.c

Revision Data
-------------
Index: man_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_validate.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -Lman_validate.c -Lman_validate.c -u -p -r1.157 -r1.158
--- man_validate.c
+++ man_validate.c
@@ -44,7 +44,6 @@
 
 typedef	void	(*v_check)(CHKARGS);
 
-static	void	  check_abort(CHKARGS) __attribute__((__noreturn__));
 static	void	  check_par(CHKARGS);
 static	void	  check_part(CHKARGS);
 static	void	  check_root(CHKARGS);
@@ -69,9 +68,9 @@ static	const v_check man_valids[MAN_MAX 
 	post_SH,    /* SS */
 	post_TP,    /* TP */
 	post_TP,    /* TQ */
-	check_abort,/* LP */
+	check_par,  /* LP */
 	check_par,  /* PP */
-	check_abort,/* P */
+	check_par,  /* P */
 	post_IP,    /* IP */
 	NULL,       /* HP */
 	NULL,       /* SM */
@@ -112,25 +111,11 @@ man_validate(struct roff_man *man)
 	const v_check	 *cp;
 
 	/*
-	 * Translate obsolete macros such that later code
-	 * does not need to look for them.
-	 */
-
-	n = man->last;
-	switch (n->tok) {
-	case MAN_LP:
-	case MAN_P:
-		n->tok = MAN_PP;
-		break;
-	default:
-		break;
-	}
-
-	/*
 	 * Iterate over all children, recursing into each one
 	 * in turn, depth-first.
 	 */
 
+	n = man->last;
 	man->last = man->last->child;
 	while (man->last != NULL) {
 		man_validate(man);
@@ -200,12 +185,6 @@ check_root(CHKARGS)
 		    "(OpenBSD)" : "(NetBSD)");
 }
 
-static void
-check_abort(CHKARGS)
-{
-	abort();
-}
-
 /*
  * Skip leading whitespace, dashes, backslashes, and font escapes,
  * then create a tag if the first following byte is a letter.
@@ -340,7 +319,8 @@ post_SH(CHKARGS)
 		return;
 	}
 
-	if (nc->tok == MAN_PP && nc->body->child != NULL) {
+	if ((nc->tok == MAN_LP || nc->tok == MAN_PP || nc->tok == MAN_P) &&
+	    nc->body->child != NULL) {
 		while (nc->body->last != NULL) {
 			man->next = ROFF_NEXT_CHILD;
 			roff_node_relink(man, nc->body->last);
@@ -348,7 +328,8 @@ post_SH(CHKARGS)
 		}
 	}
 
-	if (nc->tok == MAN_PP || nc->tok == ROFF_sp || nc->tok == ROFF_br) {
+	if (nc->tok == MAN_LP || nc->tok == MAN_PP || nc->tok == MAN_P ||
+	    nc->tok == ROFF_sp || nc->tok == ROFF_br) {
 		mandoc_msg(MANDOCERR_PAR_SKIP, nc->line, nc->pos,
 		    "%s after %s", roff_name[nc->tok], roff_name[n->tok]);
 		roff_node_delete(man, nc);
Index: man_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_term.c,v
retrieving revision 1.241
retrieving revision 1.242
diff -Lman_term.c -Lman_term.c -u -p -r1.241 -r1.242
--- man_term.c
+++ man_term.c
@@ -83,7 +83,6 @@ static	int		  pre_SS(DECL_ARGS);
 static	int		  pre_SY(DECL_ARGS);
 static	int		  pre_TP(DECL_ARGS);
 static	int		  pre_UR(DECL_ARGS);
-static	int		  pre_abort(DECL_ARGS);
 static	int		  pre_alternate(DECL_ARGS);
 static	int		  pre_ign(DECL_ARGS);
 static	int		  pre_in(DECL_ARGS);
@@ -103,9 +102,9 @@ static const struct man_term_act man_ter
 	{ pre_SS, post_SH, 0 }, /* SS */
 	{ pre_TP, post_TP, 0 }, /* TP */
 	{ pre_TP, post_TP, 0 }, /* TQ */
-	{ pre_abort, NULL, 0 }, /* LP */
+	{ pre_PP, NULL, 0 }, /* LP */
 	{ pre_PP, NULL, 0 }, /* PP */
-	{ pre_abort, NULL, 0 }, /* P */
+	{ pre_PP, NULL, 0 }, /* P */
 	{ pre_IP, post_IP, 0 }, /* IP */
 	{ pre_HP, post_HP, 0 }, /* HP */
 	{ NULL, NULL, 0 }, /* SM */
@@ -223,13 +222,6 @@ print_bvspace(struct termp *p, struct ro
 
 	for (i = 0; i < pardist; i++)
 		term_vspace(p);
-}
-
-
-static int
-pre_abort(DECL_ARGS)
-{
-	abort();
 }
 
 static int
Index: man_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_html.c,v
retrieving revision 1.184
retrieving revision 1.185
diff -Lman_html.c -Lman_html.c -u -p -r1.184 -r1.185
--- man_html.c
+++ man_html.c
@@ -60,7 +60,6 @@ static	int		  man_SH_pre(MAN_ARGS);
 static	int		  man_SM_pre(MAN_ARGS);
 static	int		  man_SY_pre(MAN_ARGS);
 static	int		  man_UR_pre(MAN_ARGS);
-static	int		  man_abort_pre(MAN_ARGS);
 static	int		  man_alt_pre(MAN_ARGS);
 static	int		  man_ign_pre(MAN_ARGS);
 static	int		  man_in_pre(MAN_ARGS);
@@ -75,9 +74,9 @@ static	const struct man_html_act man_htm
 	{ man_SH_pre, NULL }, /* SS */
 	{ man_IP_pre, NULL }, /* TP */
 	{ man_IP_pre, NULL }, /* TQ */
-	{ man_abort_pre, NULL }, /* LP */
+	{ man_PP_pre, NULL }, /* LP */
 	{ man_PP_pre, NULL }, /* PP */
-	{ man_abort_pre, NULL }, /* P */
+	{ man_PP_pre, NULL }, /* P */
 	{ man_IP_pre, NULL }, /* IP */
 	{ man_PP_pre, NULL }, /* HP */
 	{ man_SM_pre, NULL }, /* SM */
@@ -406,7 +405,7 @@ man_PP_pre(MAN_ARGS)
 		if (n->child != NULL &&
 		    (n->child->flags & NODE_NOFILL) == 0)
 			print_otag(h, TAG_P, "c",
-			    n->tok == MAN_PP ? "Pp" : "Pp HP");
+			    n->tok == MAN_HP ? "Pp HP" : "Pp");
 		break;
 	default:
 		abort();
@@ -634,10 +633,4 @@ man_UR_pre(MAN_ARGS)
 
 	print_man_nodelist(man, n->child, h);
 	return 0;
-}
-
-static int
-man_abort_pre(MAN_ARGS)
-{
-	abort();
 }
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


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

only message in thread, other threads:[~2023-04-28 20:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28 20:23 mandoc: Do not rewrite MAN_LP and MAN_P to MAN_PP because doing that 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).