diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2010-08-20 23:34:02 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2010-08-20 23:34:02 +0000 |
commit | c500969cd29883cefdff3c8fce36724a6004a567 (patch) | |
tree | afb27ce6f6808a5341661db218f8a00923d8cf86 | |
parent | 46df402950b28191cf436117d4ec8cbf981a4a75 (diff) | |
download | mandoc-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.c | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -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) |