diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2021-09-10 13:24:38 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2021-09-10 13:24:38 +0000 |
commit | fe314769a22a871f87140dbcfe4aa261c7099262 (patch) | |
tree | 98f16c092b23f710d6931fdcf80224a6b7f59208 | |
parent | 52e21ce7cae2a2af0d7d3650265cb434d65222e8 (diff) | |
download | mandoc-fe314769a22a871f87140dbcfe4aa261c7099262.tar.gz |
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.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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') |