if .in is used inside the .TP head, it's always relative
authorschwarze <schwarze@openbsd.org>
Sat, 17 Jun 2017 16:47:29 +0000 (16:47 +0000)
committerschwarze <schwarze@openbsd.org>
Sat, 17 Jun 2017 16:47:29 +0000 (16:47 +0000)
regress/usr.bin/mandoc/man/TP/Makefile
regress/usr.bin/mandoc/man/TP/indent.in [new file with mode: 0644]
regress/usr.bin/mandoc/man/TP/indent.out_ascii [new file with mode: 0644]
usr.bin/mandoc/man_macro.c
usr.bin/mandoc/man_validate.c

index 6c9fc6b..6c76bbb 100644 (file)
@@ -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 (file)
index 0000000..5480da6
--- /dev/null
@@ -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 (file)
index 0000000..9e015b2
--- /dev/null
@@ -0,0 +1,20 @@
+TP-INDENT(1)                General Commands Manual               TP-INDENT(1)
+
+
+
+N\bNA\bAM\bME\bE
+       TP-indent - indent request inside TP head
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+       initial text
+
+       tag
+         indented
+
+          tag  indented
+
+       final text
+
+
+
+OpenBSD                          June 17, 2017                    TP-INDENT(1)
index f0cbbbf..d27acf9 100644 (file)
@@ -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 <kristaps@bsd.lv>
  * Copyright (c) 2012-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 */
index bf59a01..8e85eba 100644 (file)
@@ -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 <kristaps@bsd.lv>
  * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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)
 {