summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/out.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-09-13 22:04:02 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-09-13 22:04:02 +0000
commit69daa2237de0bcc6b4d1ec395ef5fedeca9df9ad (patch)
tree3d1a67bbcc427bdd0668bdd4388dc5fe4c27dffd /usr.bin/mandoc/out.c
parentadbda52fbb890551925233cce5dda0908c890d5c (diff)
Parse and ignore the \k, \o, \w, and \z roff escapes, and recursively
ignore embedded escapes and mathematical roff subexpressions. In roff copy mode, resolve "\\" to '\'. Allow ".xx\}" where xx is a macro to close roff conditional scope. Mandoc now handles the special character definitions in the pod2man(1) preamble, so remove the explicit redefinitions in chars.c/chars.in. From kristaps@. I have checked that this causes no relevant change to the Perl manuals. The only change introduced is that some non-ASCII characters rendered incorrectly before are now rendered incorrectly in a different way. For example, e accent aigu was "e", now is "e'" and c cedille was "c", now is "c,".
Diffstat (limited to 'usr.bin/mandoc/out.c')
-rw-r--r--usr.bin/mandoc/out.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/usr.bin/mandoc/out.c b/usr.bin/mandoc/out.c
index 4da5bb43634..6e1f812fa29 100644
--- a/usr.bin/mandoc/out.c
+++ b/usr.bin/mandoc/out.c
@@ -1,4 +1,4 @@
-/* $Id: out.c,v 1.7 2010/08/18 02:38:40 schwarze Exp $ */
+/* $Id: out.c,v 1.8 2010/09/13 22:04:01 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -168,6 +168,7 @@ a2roffdeco(enum roffdeco *d, const char **word, size_t *sz)
int i, j, lim;
char term, c;
const char *wp;
+ enum roffdeco dd;
*d = DECO_NONE;
lim = i = 0;
@@ -215,6 +216,8 @@ a2roffdeco(enum roffdeco *d, const char **word, size_t *sz)
break;
}
break;
+ case ('k'):
+ /* FALLTHROUGH */
case ('M'):
/* FALLTHROUGH */
case ('m'):
@@ -271,7 +274,27 @@ a2roffdeco(enum roffdeco *d, const char **word, size_t *sz)
return(i);
i++;
}
-
+
+ /* Handle embedded numerical subexp or escape. */
+
+ if ('(' == wp[i]) {
+ while (wp[i] && ')' != wp[i])
+ if ('\\' == wp[i++]) {
+ /* Handle embedded escape. */
+ *word = &wp[i];
+ i += a2roffdeco(&dd, word, sz);
+ }
+
+ if (')' == wp[i++])
+ break;
+
+ *d = DECO_NONE;
+ return(i - 1);
+ } else if ('\\' == wp[i]) {
+ *word = &wp[++i];
+ i += a2roffdeco(&dd, word, sz);
+ }
+
break;
case ('['):
*d = DECO_SPECIAL;
@@ -280,6 +303,22 @@ a2roffdeco(enum roffdeco *d, const char **word, size_t *sz)
case ('c'):
*d = DECO_NOSPACE;
return(i);
+ case ('z'):
+ *d = DECO_NONE;
+ if ('\\' == wp[i]) {
+ *word = &wp[++i];
+ return(i + a2roffdeco(&dd, word, sz));
+ } else
+ lim = 1;
+ break;
+ case ('o'):
+ /* FALLTHROUGH */
+ case ('w'):
+ if ('\'' == wp[i++]) {
+ term = '\'';
+ break;
+ }
+ /* FALLTHROUGH */
default:
*d = DECO_SSPECIAL;
i--;