From 4e957717ad89c68ef09435675e11743d569642be Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 17 Feb 2010 19:28:11 +0000 Subject: Made `Xr' compatible with groff calling conventions where arguments following the trailing section are implicitly `Ns'd. Based on a patch submitted by Ingo Schwarze. --- mdoc_macro.c | 22 +++++++++++++++++++--- mdoc_validate.c | 6 ++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/mdoc_macro.c b/mdoc_macro.c index 4065cd77..c6ee9e89 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.41 2010/01/30 08:42:20 kristaps Exp $ */ +/* $Id: mdoc_macro.c,v 1.42 2010/02/17 19:28:11 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -100,7 +100,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* St */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Va */ { ctx_synopsis, MDOC_CALLABLE | MDOC_PARSED }, /* Vt */ - { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Xr */ + { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Xr */ { in_line_eoln, 0 }, /* %A */ { in_line_eoln, 0 }, /* %B */ { in_line_eoln, 0 }, /* %D */ @@ -1180,6 +1180,9 @@ in_line_argn(MACRO_PROT_ARGS) case (MDOC_Ux): maxargs = 0; break; + case (MDOC_Xr): + maxargs = 2; + break; default: maxargs = 1; break; @@ -1245,7 +1248,20 @@ in_line_argn(MACRO_PROT_ARGS) return(0); flushed = 1; } - + + /* + * XXX: this is a hack to work around groff's ugliness + * as regards `Xr' and extraneous arguments. It should + * ideally be deprecated behaviour, but because this is + * code is no here, it's unlikely to be removed. + */ + if (MDOC_Xr == tok && j == maxargs) { + if ( ! mdoc_elem_alloc(m, line, ppos, MDOC_Ns, NULL)) + return(0); + if ( ! rew_elem(m, MDOC_Ns)) + return(0); + } + if ( ! mdoc_word_alloc(m, line, la, p)) return(0); } diff --git a/mdoc_validate.c b/mdoc_validate.c index b4a50cdd..b92e89c5 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.57 2010/01/30 08:42:21 kristaps Exp $ */ +/* $Id: mdoc_validate.c,v 1.58 2010/02/17 19:28:11 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -72,7 +72,6 @@ static int ebool(POST_ARGS); static int eerr_eq0(POST_ARGS); static int eerr_eq1(POST_ARGS); static int eerr_ge1(POST_ARGS); -static int eerr_le2(POST_ARGS); static int eerr_le1(POST_ARGS); static int ewarn_ge1(POST_ARGS); static int herr_eq0(POST_ARGS); @@ -134,7 +133,7 @@ static v_post posts_text1[] = { eerr_eq1, NULL }; static v_post posts_vt[] = { post_vt, NULL }; static v_post posts_wline[] = { bwarn_ge1, herr_eq0, NULL }; static v_post posts_wtext[] = { ewarn_ge1, NULL }; -static v_post posts_xr[] = { eerr_ge1, eerr_le2, NULL }; +static v_post posts_xr[] = { eerr_ge1, NULL }; static v_pre pres_an[] = { pre_an, NULL }; static v_pre pres_bd[] = { pre_display, pre_bd, NULL }; static v_pre pres_bl[] = { pre_bl, NULL }; @@ -408,7 +407,6 @@ CHECK_BODY_DEFN(ge1, warn, warn_child_gt, 0) /* bwarn_ge1() */ CHECK_BODY_DEFN(ge1, err, err_child_gt, 0) /* berr_ge1() */ CHECK_ELEM_DEFN(ge1, warn, warn_child_gt, 0) /* ewarn_gt1() */ CHECK_ELEM_DEFN(eq1, err, err_child_eq, 1) /* eerr_eq1() */ -CHECK_ELEM_DEFN(le2, err, err_child_lt, 3) /* eerr_le2() */ CHECK_ELEM_DEFN(le1, err, err_child_lt, 2) /* eerr_le1() */ CHECK_ELEM_DEFN(eq0, err, err_child_eq, 0) /* eerr_eq0() */ CHECK_ELEM_DEFN(ge1, err, err_child_gt, 0) /* eerr_ge1() */ -- cgit v1.2.3-56-ge451