aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2010-08-20 23:34:02 +0000
committerIngo Schwarze <schwarze@openbsd.org>2010-08-20 23:34:02 +0000
commitbd1f33663109650ff780168b923581e7d15e30a8 (patch)
treea22419af35bbcf70a367d192f37e272aa553d2ed /term.c
parentd34d29a6e166f6fdc775dd433c5bc56281628597 (diff)
downloadmandoc-bd1f33663109650ff780168b923581e7d15e30a8.tar.gz
mandoc-bd1f33663109650ff780168b923581e7d15e30a8.tar.zst
mandoc-bd1f33663109650ff780168b923581e7d15e30a8.zip
Centralize handling of literal tabs in term_flushln() in one place,
making the code simpler and easier to understand. No functional change.
Diffstat (limited to 'term.c')
-rw-r--r--term.c15
1 files 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 <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -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)