aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-03-28 23:26:25 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-03-28 23:26:25 +0000
commit08b72b8f1a54d84a06924f40ca973826190c215b (patch)
treec96341f205775e45c19308440a7f61a8cc3069a7
parent23c5b114a08a25aa328f42f87c2923240872bcb1 (diff)
downloadmandoc-08b72b8f1a54d84a06924f40ca973826190c215b.tar.gz
mandoc-08b72b8f1a54d84a06924f40ca973826190c215b.tar.zst
mandoc-08b72b8f1a54d84a06924f40ca973826190c215b.zip
Allow leading and trailing vertical lines,
and format them in the same way as groff. While here, do not require whitespace before vertical lines in layout specifications. Issues found by bentley@ in mpv(1).
-rw-r--r--mandoc.h3
-rw-r--r--tbl_layout.c13
-rw-r--r--tbl_term.c10
3 files changed, 19 insertions, 7 deletions
diff --git a/mandoc.h b/mandoc.h
index a6900ee6..8d5100ea 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.118 2014/03/23 11:25:26 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.119 2014/03/28 23:26:25 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -240,6 +240,7 @@ struct tbl_row {
struct tbl_row *next;
struct tbl_cell *first;
struct tbl_cell *last;
+ int vert; /* trailing vertical line */
};
enum tbl_datt {
diff --git a/tbl_layout.c b/tbl_layout.c
index c30ea25b..94a48d18 100644
--- a/tbl_layout.c
+++ b/tbl_layout.c
@@ -1,7 +1,7 @@
-/* $Id: tbl_layout.c,v 1.24 2014/03/23 11:25:26 schwarze Exp $ */
+/* $Id: tbl_layout.c,v 1.25 2014/03/28 23:26:25 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -100,6 +100,8 @@ mod:
case (','):
/* FALLTHROUGH */
case ('.'):
+ /* FALLTHROUGH */
+ case ('|'):
return(1);
default:
break;
@@ -218,6 +220,13 @@ cell(struct tbl_node *tbl, struct tbl_row *rp,
while (' ' == p[*pos])
(*pos)++;
+ /* Handle trailing vertical lines */
+
+ if ('.' == p[*pos] || '\0' == p[*pos]) {
+ rp->vert = vert;
+ return(1);
+ }
+
/* Parse the column position (`c', `l', `r', ...). */
for (i = 0; i < KEYS_MAX; i++)
diff --git a/tbl_term.c b/tbl_term.c
index e8411ffe..7941cd5a 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -1,7 +1,7 @@
-/* $Id: tbl_term.c,v 1.25 2013/05/31 21:37:17 schwarze Exp $ */
+/* $Id: tbl_term.c,v 1.26 2014/03/28 23:26:25 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -105,7 +105,8 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
/* Vertical frame at the start of each row. */
- if (TBL_OPT_BOX & sp->opts->opts || TBL_OPT_DBOX & sp->opts->opts)
+ if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
+ sp->head->vert)
term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
TBL_SPAN_DHORIZ == sp->pos ? "+" : "|");
@@ -159,7 +160,8 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
/* Vertical frame at the end of each row. */
- if (TBL_OPT_BOX & sp->opts->opts || TBL_OPT_DBOX & sp->opts->opts)
+ if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
+ sp->layout->vert)
term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
TBL_SPAN_DHORIZ == sp->pos ? "+" : " |");
term_flushln(tp);