aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-21 20:33:25 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-21 20:33:25 +0000
commit2c8780108e37e85285813e3f999444c3e861a456 (patch)
tree6539e8d252bac96f53212ea11bb5ea88a23d2379 /term.c
parent73f85b8d5a3ab767a78772963e344e8759ccb1d7 (diff)
downloadmandoc-2c8780108e37e85285813e3f999444c3e861a456.tar.gz
mandoc-2c8780108e37e85285813e3f999444c3e861a456.tar.zst
mandoc-2c8780108e37e85285813e3f999444c3e861a456.zip
Rudimentary implementation of the roff(7) \o escape sequence (overstrike).
This is of some relevance because the pod2man(1) preamble abuses it for the icelandic letter Thorn, instead of simply using \(TP and \(Tp. Missing feature found by sthen@ in DateTime::Locale::is_IS(3p).
Diffstat (limited to 'term.c')
-rw-r--r--term.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/term.c b/term.c
index e6e3f641..7ce90bcb 100644
--- a/term.c
+++ b/term.c
@@ -1,7 +1,7 @@
-/* $Id: term.c,v 1.242 2014/12/24 23:32:42 schwarze Exp $ */
+/* $Id: term.c,v 1.243 2015/01/21 20:33:25 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -495,6 +495,17 @@ term_word(struct termp *p, const char *word)
case ESCAPE_SKIPCHAR:
p->flags |= TERMP_SKIPCHAR;
continue;
+ case ESCAPE_OVERSTRIKE:
+ cp = seq + sz;
+ while (seq < cp) {
+ if (*seq == '\\') {
+ mandoc_escape(&seq, NULL, NULL);
+ continue;
+ }
+ encode1(p, *seq++);
+ if (seq < cp)
+ encode(p, "\b", 1);
+ }
default:
continue;
}
@@ -716,6 +727,20 @@ term_strlen(const struct termp *p, const char *cp)
case ESCAPE_SKIPCHAR:
skip = 1;
continue;
+ case ESCAPE_OVERSTRIKE:
+ rsz = 0;
+ rhs = seq + ssz;
+ while (seq < rhs) {
+ if (*seq == '\\') {
+ mandoc_escape(&seq, NULL, NULL);
+ continue;
+ }
+ i = (*p->width)(p, *seq++);
+ if (rsz < i)
+ rsz = i;
+ }
+ sz += rsz;
+ continue;
default:
continue;
}