source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Centralize handling of literal tabs in term_flushln() in one
@ 2010-08-20 23:34 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2010-08-20 23:34 UTC (permalink / raw)
  To: source

Log Message:
-----------
Centralize handling of literal tabs in term_flushln() in one place,
making the code simpler and easier to understand.
No functional change.

Modified Files:
--------------
    mdocml:
        term.c

Revision Data
-------------
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.168
retrieving revision 1.169
diff -Lterm.c -Lterm.c -u -p -r1.168 -r1.169
--- term.c
+++ term.c
@@ -169,12 +169,11 @@ term_flushln(struct termp *p)
 		 * Handle literal tab characters: collapse all
 		 * subsequent tabs into a single huge set of spaces.
 		 */
-		for (j = i; j < (int)p->col; j++) {
-			if ('\t' != p->buf[j])
-				break;
+		while (i < (int)p->col && '\t' == p->buf[i]) {
 			vend = (vis / p->tabwidth + 1) * p->tabwidth;
 			vbl += vend - vis;
 			vis = vend;
+			i++;
 		}
 
 		/*
@@ -185,7 +184,7 @@ term_flushln(struct termp *p)
 		 */
 
 		/* LINTED */
-		for (jhy = 0; j < (int)p->col; j++) {
+		for (j = i, jhy = 0; j < (int)p->col; j++) {
 			if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j])
 				break;
 
@@ -227,12 +226,6 @@ term_flushln(struct termp *p)
 				p->overstep;
 			p->overstep = 0;
 		}
-
-		/*
-		 * Skip leading tabs, they were handled above.
-		 */
-		while (i < (int)p->col && '\t' == p->buf[i])
-			i++;
 
 		/* Write out the [remaining] word. */
 		for ( ; i < (int)p->col; i++) {
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-20 23:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-20 23:34 mdocml: Centralize handling of literal tabs in term_flushln() in one schwarze

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).