aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2021-09-10 13:24:38 +0000
committerIngo Schwarze <schwarze@openbsd.org>2021-09-10 13:24:38 +0000
commitb9a697e3a95d6c38aadb272f08d465e1dead2de6 (patch)
treecea2277bc542d7be21eec771584391f5bcd10dd9
parent750312944a3f1072216eaef256ced25d9a0ee385 (diff)
downloadmandoc-b9a697e3a95d6c38aadb272f08d465e1dead2de6.tar.gz
mandoc-b9a697e3a95d6c38aadb272f08d465e1dead2de6.tar.zst
mandoc-b9a697e3a95d6c38aadb272f08d465e1dead2de6.zip
Quirk-compatibility with GNU tbl(1):
With the "nospaces" option, skip space characters before and after "T{", in addition to skipping those at the beginning and end of data cells. Minor issue reported by <Oliver dot Corff at email dot de>.
-rw-r--r--tbl_data.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/tbl_data.c b/tbl_data.c
index 1efaa496..fe0259f9 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_data.c,v 1.58 2021/09/10 12:07:21 schwarze Exp $ */
+/* $Id: tbl_data.c,v 1.59 2021/09/10 13:24:38 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011,2015,2017-2019,2021 Ingo Schwarze <schwarze@openbsd.org>
@@ -147,25 +147,28 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp,
dp->last->next = dat;
dp->last = dat;
+ /* Strip leading and trailing spaces, if requested. */
+
+ endpos = *pos;
+ if (dp->opts->opts & TBL_OPT_NOSPACE) {
+ while (p[startpos] == ' ')
+ startpos++;
+ while (endpos > startpos && p[endpos - 1] == ' ')
+ endpos--;
+ }
+
/*
* Check for a continued-data scope opening. This consists of a
* trailing `T{' at the end of the line. Subsequent lines,
* until a standalone `T}', are included in our cell.
*/
- if (*pos - startpos == 2 &&
+ if (endpos - startpos == 2 &&
p[startpos] == 'T' && p[startpos + 1] == '{') {
tbl->part = TBL_PART_CDATA;
return;
}
- endpos = *pos;
- if (dp->opts->opts & TBL_OPT_NOSPACE) {
- while (p[startpos] == ' ')
- startpos++;
- while (endpos > startpos && p[endpos - 1] == ' ')
- endpos--;
- }
dat->string = mandoc_strndup(p + startpos, endpos - startpos);
if (p[*pos] != '\0')