summaryrefslogtreecommitdiffstats
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
commitc500969cd29883cefdff3c8fce36724a6004a567 (patch)
treeafb27ce6f6808a5341661db218f8a00923d8cf86
parent46df402950b28191cf436117d4ec8cbf981a4a75 (diff)
downloadmandoc-c500969cd29883cefdff3c8fce36724a6004a567.tar.gz
Centralize handling of literal tabs in term_flushln() in one place,
making the code simpler and easier to understand. No functional change.
-rw-r--r--term.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/term.c b/term.c
index eb8eee83..01d9fd54 100644
--- a/term.c
+++ b/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;
@@ -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)