From 318aa4c1419c357a217caeb555137a18fdf03b64 Mon Sep 17 00:00:00 2001 From: schwarze Date: Sat, 17 Jun 2017 16:47:29 +0000 Subject: [PATCH] if .in is used inside the .TP head, it's always relative --- regress/usr.bin/mandoc/man/TP/Makefile | 4 ++-- regress/usr.bin/mandoc/man/TP/indent.in | 14 +++++++++++ .../usr.bin/mandoc/man/TP/indent.out_ascii | 20 ++++++++++++++++ usr.bin/mandoc/man_macro.c | 4 ++-- usr.bin/mandoc/man_validate.c | 23 ++++++++++++++++--- 5 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 regress/usr.bin/mandoc/man/TP/indent.in create mode 100644 regress/usr.bin/mandoc/man/TP/indent.out_ascii diff --git a/regress/usr.bin/mandoc/man/TP/Makefile b/regress/usr.bin/mandoc/man/TP/Makefile index 6c9fc6b9de4..6c76bbbbe17 100644 --- a/regress/usr.bin/mandoc/man/TP/Makefile +++ b/regress/usr.bin/mandoc/man/TP/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.13 2017/06/03 15:54:09 schwarze Exp $ +# $OpenBSD: Makefile,v 1.14 2017/06/17 16:47:29 schwarze Exp $ -REGRESS_TARGETS = badarg broken double eof fill literal longhead +REGRESS_TARGETS = badarg broken double eof fill indent literal longhead REGRESS_TARGETS += macrotag manyargs sameline spacing width LINT_TARGETS = broken double eof diff --git a/regress/usr.bin/mandoc/man/TP/indent.in b/regress/usr.bin/mandoc/man/TP/indent.in new file mode 100644 index 00000000000..5480da67d2c --- /dev/null +++ b/regress/usr.bin/mandoc/man/TP/indent.in @@ -0,0 +1,14 @@ +.TH TP-INDENT 1 "June 17, 2017" OpenBSD +.SH NAME +TP-indent \- indent request inside TP head +.SH DESCRIPTION +initial text +.TP 2n +tag +indented +.TP 8n +.in 3n +tag +indented +.PP +final text diff --git a/regress/usr.bin/mandoc/man/TP/indent.out_ascii b/regress/usr.bin/mandoc/man/TP/indent.out_ascii new file mode 100644 index 00000000000..9e015b21b51 --- /dev/null +++ b/regress/usr.bin/mandoc/man/TP/indent.out_ascii @@ -0,0 +1,20 @@ +TP-INDENT(1) General Commands Manual TP-INDENT(1) + + + +NNAAMMEE + TP-indent - indent request inside TP head + +DDEESSCCRRIIPPTTIIOONN + initial text + + tag + indented + + tag indented + + final text + + + +OpenBSD June 17, 2017 TP-INDENT(1) diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index f0cbbbf3f60..d27acf9088f 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_macro.c,v 1.83 2017/06/13 19:33:24 schwarze Exp $ */ +/* $OpenBSD: man_macro.c,v 1.84 2017/06/17 16:47:29 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2012-2015, 2017 Ingo Schwarze @@ -67,7 +67,7 @@ const struct man_macro __man_macros[MAN_MAX - MAN_TH] = { { in_line_eoln, 0 }, /* UC */ { in_line_eoln, MAN_NSCOPED }, /* PD */ { in_line_eoln, 0 }, /* AT */ - { in_line_eoln, 0 }, /* in */ + { in_line_eoln, MAN_NSCOPED }, /* in */ { in_line_eoln, 0 }, /* OP */ { in_line_eoln, MAN_BSCOPE }, /* EX */ { in_line_eoln, MAN_BSCOPE }, /* EE */ diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index bf59a013f06..8e85eba162a 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_validate.c,v 1.99 2017/06/11 19:36:31 schwarze Exp $ */ +/* $OpenBSD: man_validate.c,v 1.100 2017/06/17 16:47:29 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012-2017 Ingo Schwarze @@ -45,11 +45,12 @@ static void check_text(CHKARGS); static void post_AT(CHKARGS); static void post_IP(CHKARGS); -static void post_vs(CHKARGS); static void post_OP(CHKARGS); static void post_TH(CHKARGS); static void post_UC(CHKARGS); static void post_UR(CHKARGS); +static void post_in(CHKARGS); +static void post_vs(CHKARGS); static const v_check __man_valids[MAN_MAX - MAN_TH] = { post_TH, /* TH */ @@ -80,7 +81,7 @@ static const v_check __man_valids[MAN_MAX - MAN_TH] = { post_UC, /* UC */ NULL, /* PD */ post_AT, /* AT */ - NULL, /* in */ + post_in, /* in */ post_OP, /* OP */ NULL, /* EX */ NULL, /* EE */ @@ -432,6 +433,22 @@ post_AT(CHKARGS) man->meta.os = mandoc_strdup(p); } +static void +post_in(CHKARGS) +{ + char *s; + + if (n->parent->tok != MAN_TP || + n->parent->type != ROFFT_HEAD || + n->child == NULL || + *n->child->string == '+' || + *n->child->string == '-') + return; + mandoc_asprintf(&s, "+%s", n->child->string); + free(n->child->string); + n->child->string = s; +} + static void post_vs(CHKARGS) { -- 2.20.1