* mdocml: Improve handling of the roff(7) "\t" escape sequence: * Parsing
@ 2013-06-20 22:39 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2013-06-20 22:39 UTC (permalink / raw)
To: source
Log Message:
-----------
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.
Modified Files:
--------------
mdocml:
chars.c
chars.in
mandoc.c
Revision Data
-------------
Index: mandoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -Lmandoc.c -Lmandoc.c -u -p -r1.66 -r1.67
--- mandoc.c
+++ mandoc.c
@@ -432,17 +432,35 @@ mandoc_getarg(struct mparse *parse, char
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. */
Index: chars.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -Lchars.c -Lchars.c -u -p -r1.53 -r1.54
--- chars.c
+++ 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) },
Index: chars.in
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.in,v
retrieving revision 1.42
retrieving revision 1.43
diff -Lchars.in -Lchars.in -u -p -r1.42 -r1.43
--- chars.in
+++ chars.in
@@ -42,6 +42,7 @@ CHAR("&", "", 0)
CHAR("^", "", 0)
CHAR("|", "", 0)
CHAR("}", "", 0)
+CHAR("t", "", 0)
/* Accents. */
CHAR("a\"", "\"", 779)
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-06-20 22:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-20 22:39 mdocml: Improve handling of the roff(7) "\t" escape sequence: * Parsing schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).