summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-07-11 13:53:35 +0200
committerYorhel <git@yorhel.nl>2012-07-11 13:53:35 +0200
commiteb3e6cf9299abac88d3a0de09f289e30c66ca851 (patch)
tree14c3de620cf7bd3b16cc1d3d15d16ec2352429b6 /lib
parent5f87ab9069f2361db2642726ce875a03e61313d0 (diff)
ManUtils: Fix display of double-formatted characters
Grotty outputs double-formatted characters for some (old) manual pages. This fix ignores the second part of the double-formatting, thus making things readable again.
Diffstat (limited to 'lib')
-rw-r--r--lib/ManUtils/ManUtils.xs20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/ManUtils/ManUtils.xs b/lib/ManUtils/ManUtils.xs
index 834c9fe..711cdde 100644
--- a/lib/ManUtils/ManUtils.xs
+++ b/lib/ManUtils/ManUtils.xs
@@ -238,18 +238,28 @@ static void parselines(ctx_t *x) {
while(*buf) {
int c1 = UTF8SKIP(buf);
+ // Escape character right after a formatting code? Ignore the escape
+ // character and formatting code after that. Grotty sometimes
+ // double-formats a character, so you get "f ESC c ESC f ESC c", which you
+ // should read as "(f ESC c) ESC (f ESC c)".
+ if(*buf == 8 && buf[1] && buf[1+UTF8SKIP(buf+1)] == 8 && buf[2+UTF8SKIP(buf+1)]) {
+ int c2 = UTF8SKIP(buf+1);
+ buf += 2 + c2 + UTF8SKIP(buf+1+c2);
+ continue;
+ }
+ // Formatting code
if(buf[c1] == 8 && buf[c1+1]) {
int c2 = UTF8SKIP(buf+c1+1);
for(i=0; i<c2; i++)
appendline(x, buf[c1+i+1], *buf == '_' ? LI : LB);
buf += c1+c2+1;
continue;
- } else {
- if(*buf == '\n' && !buf[1])
- x->noref = 1;
- appendline(x, *buf, 0);
- buf++;
}
+ // Regular character
+ if(*buf == '\n' && !buf[1])
+ x->noref = 1;
+ appendline(x, *buf, 0);
+ buf++;
}
x->noref = 1;
appendline(x, '\n', 0);