From bd1f33663109650ff780168b923581e7d15e30a8 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 20 Aug 2010 23:34:02 +0000 Subject: Centralize handling of literal tabs in term_flushln() in one place, making the code simpler and easier to understand. No functional change. --- term.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/term.c b/term.c index c2bcd158..79a0f45f 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.168 2010/08/20 23:22:09 schwarze Exp $ */ +/* $Id: term.c,v 1.169 2010/08/20 23:34:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -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; @@ -228,12 +227,6 @@ term_flushln(struct termp *p) 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++) { if (vend > bp && jhy > 0 && i > jhy) -- cgit v1.2.3