diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-09-13 22:04:02 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-09-13 22:04:02 +0000 |
commit | 69daa2237de0bcc6b4d1ec395ef5fedeca9df9ad (patch) | |
tree | 3d1a67bbcc427bdd0668bdd4388dc5fe4c27dffd /usr.bin/mandoc/mandoc.c | |
parent | adbda52fbb890551925233cce5dda0908c890d5c (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/mandoc.c')
-rw-r--r-- | usr.bin/mandoc/mandoc.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c index 9abaced9a54..8d0421f11bd 100644 --- a/usr.bin/mandoc/mandoc.c +++ b/usr.bin/mandoc/mandoc.c @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.18 2010/08/20 00:53:35 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.19 2010/09/13 22:04:01 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -51,14 +51,10 @@ mandoc_special(char *p) /* FALLTHROUGH */ case ('x'): /* FALLTHROUGH */ - case ('w'): - /* FALLTHROUGH */ case ('S'): /* FALLTHROUGH */ case ('R'): /* FALLTHROUGH */ - case ('o'): - /* FALLTHROUGH */ case ('N'): /* FALLTHROUGH */ case ('l'): @@ -126,6 +122,27 @@ mandoc_special(char *p) p++; } + /* Handle embedded numerical subexp or escape. */ + + if ('(' == *p) { + while (*p && ')' != *p) + if ('\\' == *p++) { + i = mandoc_special(--p); + if (0 == i) + return(0); + p += i; + } + + if (')' == *p++) + break; + + return(0); + } else if ('\\' == *p) { + if (0 == (i = mandoc_special(p))) + return(0); + p += i; + } + break; #if 0 case ('Y'): @@ -136,9 +153,9 @@ mandoc_special(char *p) /* FALLTHROUGH */ case ('n'): /* FALLTHROUGH */ +#endif case ('k'): /* FALLTHROUGH */ -#endif case ('M'): /* FALLTHROUGH */ case ('m'): @@ -167,6 +184,23 @@ mandoc_special(char *p) case ('['): term = ']'; break; + case ('z'): + len = 1; + if ('\\' == *p) { + if (0 == (i = mandoc_special(p))) + return(0); + p += i; + return(*p ? (int)(p - sv) : 0); + } + break; + case ('o'): + /* FALLTHROUGH */ + case ('w'): + if ('\'' == *p++) { + term = '\''; + break; + } + /* FALLTHROUGH */ default: len = 1; p--; |