diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2013-06-20 22:29:39 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2013-06-20 22:29:39 +0000 |
commit | 07a861bf4089b3b357a0dfd968099a685d0f25e7 (patch) | |
tree | 6cbdb132228b227730110fef52df58ea399ddbc2 /usr.bin | |
parent | 8f00e4f16cf85c50b2b5d75ef62d64a699603bbe (diff) |
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.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/chars.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/chars.in | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.c | 30 |
3 files changed, 28 insertions, 9 deletions
diff --git a/usr.bin/mandoc/chars.c b/usr.bin/mandoc/chars.c index 57c0eea83ee..d8a7a1d3b23 100644 --- a/usr.bin/mandoc/chars.c +++ b/usr.bin/mandoc/chars.c @@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.24 2013/05/18 16:38:54 schwarze Exp $ */ +/* $Id: chars.c,v 1.25 2013/06/20 22:29:38 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -33,7 +33,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/usr.bin/mandoc/chars.in b/usr.bin/mandoc/chars.in index e3bdbbfd760..fb905aee193 100644 --- a/usr.bin/mandoc/chars.in +++ b/usr.bin/mandoc/chars.in @@ -1,4 +1,4 @@ -/* $Id: chars.in,v 1.18 2011/10/09 17:59:56 schwarze Exp $ */ +/* $Id: chars.in,v 1.19 2013/06/20 22:29:38 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -42,6 +42,7 @@ CHAR("&", "", 0) CHAR("^", "", 0) CHAR("|", "", 0) CHAR("}", "", 0) +CHAR("t", "", 0) /* Accents. */ CHAR("a\"", "\"", 779) diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c index 768a23b10a0..e4903aa7b18 100644 --- a/usr.bin/mandoc/mandoc.c +++ b/usr.bin/mandoc/mandoc.c @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.35 2012/07/07 18:27:36 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.36 2013/06/20 22:29:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -428,17 +428,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. */ |