aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-02-17 19:28:11 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-02-17 19:28:11 +0000
commit4e957717ad89c68ef09435675e11743d569642be (patch)
treefc22d15520ec38867d22880510ddd94d1a6fa5f0 /mdoc_macro.c
parentc0900b4fe8fcf2e19807556533a1f575ed036481 (diff)
downloadmandoc-4e957717ad89c68ef09435675e11743d569642be.tar.gz
mandoc-4e957717ad89c68ef09435675e11743d569642be.tar.zst
mandoc-4e957717ad89c68ef09435675e11743d569642be.zip
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.
Diffstat (limited to 'mdoc_macro.c')
-rw-r--r--mdoc_macro.c22
1 files changed, 19 insertions, 3 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 <kristaps@kth.se>
*
@@ -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);
}