aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-12-09 00:49:01 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-12-09 00:49:01 +0000
commit15f7805ab7d044633a350c184879f241494dbdef (patch)
treeb7e00923768f35063dfcf76da3574c9c2bb35fe3 /mandocdb.c
parent2671d8b5f928661e34f3b3a25984aa41fadeef1c (diff)
downloadmandoc-15f7805ab7d044633a350c184879f241494dbdef.tar.gz
mandoc-15f7805ab7d044633a350c184879f241494dbdef.tar.zst
mandoc-15f7805ab7d044633a350c184879f241494dbdef.zip
Strip backspace encoding from preformatted manuals. This cleans up a lot
of catpage entries in the mandoc databases.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 81e27a0e..aaa80a46 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.28 2011/12/08 09:19:13 kristaps Exp $ */
+/* $Id: mandocdb.c,v 1.29 2011/12/09 00:49:01 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -1336,6 +1336,18 @@ pformatted(DB *hash, struct buf *buf, struct buf *dbuf,
p[plen] = '\0';
}
+ /* Strip backspace-encoding from line. */
+
+ while (NULL != (line = memchr(p, '\b', plen))) {
+ len = line - p;
+ if (0 == len) {
+ memmove(line, line + 1, plen--);
+ continue;
+ }
+ memmove(line - 1, line + 1, plen - len);
+ plen -= 2;
+ }
+
buf_appendb(dbuf, p, plen + 1);
buf->len = 0;
buf_appendb(buf, p, plen + 1);