summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-06-20 22:39:30 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-06-20 22:39:30 +0000
commit7d5d7db4acbef7399cc00837c2424a8b25ccd8e4 (patch)
treeb039cc491c0a240e9307b89b2735ab5313653677
parent02147107a75ec2ff2290c4341da118dda7bab836 (diff)
downloadmandoc-7d5d7db4acbef7399cc00837c2424a8b25ccd8e4.tar.gz
Improve handling of the roff(7) "\t" escape sequence:
* Parsing macro arguments has to be done in copy mode, which implies replacing "\t" by a literal tab character. * Otherwise, render "\t" as the empty string, not as a 't' character. This fixes formatting of the distfile example in the oldrdist(1) manual. This also shows up in the unzip(1) manual as one of several issues preventing the removal of USE_GROFF from the archivers/unzip port. Thanks to espie@ for attracting my attention to the unzip(1) manual.
-rw-r--r--chars.c2
-rw-r--r--chars.in1
-rw-r--r--mandoc.c28
3 files changed, 25 insertions, 6 deletions
diff --git a/chars.c b/chars.c
index e7947f51..ad3ffd40 100644
--- a/chars.c
+++ b/chars.c
@@ -37,7 +37,7 @@ struct ln {
int unicode;
};
-#define LINES_MAX 328
+#define LINES_MAX 329
#define CHAR(in, ch, code) \
{ NULL, (in), (ch), (code) },
diff --git a/chars.in b/chars.in
index 0d6959de..28a37eaa 100644
--- a/chars.in
+++ b/chars.in
@@ -42,6 +42,7 @@ CHAR("&", "", 0)
CHAR("^", "", 0)
CHAR("|", "", 0)
CHAR("}", "", 0)
+CHAR("t", "", 0)
/* Accents. */
CHAR("a\"", "\"", 779)
diff --git a/mandoc.c b/mandoc.c
index 55419dc1..156bd689 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -432,17 +432,35 @@ mandoc_getarg(struct mparse *parse, char **cpp, int ln, int *pos)
pairs = 0;
white = 0;
for (cp = start; '\0' != *cp; cp++) {
- /* Move left after quoted quotes and escaped backslashes. */
+
+ /*
+ * Move the following text left
+ * after quoted quotes and after "\\" and "\t".
+ */
if (pairs)
cp[-pairs] = cp[0];
+
if ('\\' == cp[0]) {
- if ('\\' == cp[1]) {
- /* Poor man's copy mode. */
+ /*
+ * In copy mode, translate double to single
+ * backslashes and backslash-t to literal tabs.
+ */
+ switch (cp[1]) {
+ case ('t'):
+ cp[0] = '\t';
+ /* FALLTHROUGH */
+ case ('\\'):
pairs++;
cp++;
- } else if (0 == quoted && ' ' == cp[1])
+ break;
+ case (' '):
/* Skip escaped blanks. */
- cp++;
+ if (0 == quoted)
+ cp++;
+ break;
+ default:
+ break;
+ }
} else if (0 == quoted) {
if (' ' == cp[0]) {
/* Unescaped blanks end unquoted args. */