summaryrefslogtreecommitdiffstats
path: root/term_ps.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-11 15:26:39 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-11 15:26:39 +0000
commit8c998f6fb38c48a3f834b396046a65cb28997c05 (patch)
tree856fff713d73cf3e054d4c87bc368accdebf25b7 /term_ps.c
parent4320829a9974a95546e94df94a6b70b6b4831a68 (diff)
downloadmandoc-8c998f6fb38c48a3f834b396046a65cb28997c05.tar.gz
Delay opening a word state until a character is ready to be output.
This paves the way for closing/reopening scope in the event that a font changes.
Diffstat (limited to 'term_ps.c')
-rw-r--r--term_ps.c61
1 files changed, 41 insertions, 20 deletions
diff --git a/term_ps.c b/term_ps.c
index 36304bdc..0fbc499b 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -58,6 +58,7 @@ static void ps_begin(struct termp *);
static void ps_end(struct termp *);
static void ps_advance(struct termp *, size_t);
static void ps_endline(struct termp *);
+static void ps_pletter(struct termp *, char);
static void ps_printf(struct termp *, const char *, ...);
static void ps_putchar(struct termp *, char);
@@ -161,6 +162,8 @@ ps_end(struct termp *p)
* well as just one.
*/
+ assert(0 == p->engine.ps.psstate);
+ assert('\0' == p->engine.ps.last);
assert(p->engine.ps.psmarg && p->engine.ps.psmarg[0]);
printf("%s", p->engine.ps.psmarg);
printf("showpage\n");
@@ -226,9 +229,8 @@ ps_begin(struct termp *p)
static void
-ps_letter(struct termp *p, char c)
+ps_pletter(struct termp *p, char c)
{
- char cc;
if ( ! (PS_INLINE & p->engine.ps.psstate)) {
/*
@@ -241,24 +243,6 @@ ps_letter(struct termp *p, char c)
p->engine.ps.psstate |= PS_INLINE;
}
- if ('\0' == p->engine.ps.last) {
- assert(8 != c);
- p->engine.ps.last = c;
- return;
- } else if (8 == p->engine.ps.last) {
- assert(8 != c);
- p->engine.ps.last = c;
- return;
- } else if (8 == c) {
- assert(8 != p->engine.ps.last);
- p->engine.ps.last = c;
- return;
- } else {
- cc = p->engine.ps.last;
- p->engine.ps.last = c;
- c = cc;
- }
-
/*
* We need to escape these characters as per the PostScript
* specification. We would also escape non-graphable characters
@@ -285,10 +269,42 @@ ps_letter(struct termp *p, char c)
static void
+ps_letter(struct termp *p, char c)
+{
+ char cc;
+
+ if ('\0' == p->engine.ps.last) {
+ assert(8 != c);
+ p->engine.ps.last = c;
+ return;
+ } else if (8 == p->engine.ps.last) {
+ assert(8 != c);
+ p->engine.ps.last = c;
+ return;
+ } else if (8 == c) {
+ assert(8 != p->engine.ps.last);
+ p->engine.ps.last = c;
+ return;
+ } else {
+ cc = p->engine.ps.last;
+ p->engine.ps.last = c;
+ c = cc;
+ }
+
+ return(ps_pletter(p, c));
+}
+
+
+static void
ps_advance(struct termp *p, size_t len)
{
size_t i;
+ if ('\0' != p->engine.ps.last) {
+ ps_pletter(p, p->engine.ps.last);
+ p->engine.ps.last = '\0';
+ }
+
if (PS_INLINE & p->engine.ps.psstate) {
assert(8 != p->engine.ps.last);
if (p->engine.ps.last)
@@ -308,6 +324,11 @@ static void
ps_endline(struct termp *p)
{
+ if ('\0' != p->engine.ps.last) {
+ ps_pletter(p, p->engine.ps.last);
+ p->engine.ps.last = '\0';
+ }
+
if (PS_INLINE & p->engine.ps.psstate) {
assert(8 != p->engine.ps.last);
if (p->engine.ps.last)