source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Delay opening a word state until a character is ready to be
Date: Fri, 11 Jun 2010 11:26:39 -0400 (EDT)	[thread overview]
Message-ID: <201006111526.o5BFQdvA006804@krisdoz.my.domain> (raw)

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        term_ps.c

Revision Data
-------------
Index: term_ps.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.7 -r1.8
--- term_ps.c
+++ 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)
@@ -307,6 +323,11 @@ ps_advance(struct termp *p, size_t len)
 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);
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2010-06-11 15:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201006111526.o5BFQdvA006804@krisdoz.my.domain \
    --to=kristaps@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).