summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-08-20 23:34:01 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-08-20 23:34:01 +0000
commit572165e5370b314eeadcb5b453f0a39b85f43c4a (patch)
tree5f7f405ce948209754a9883296ab53fad8797063 /usr.bin/mandoc/term.c
parent0d03f3eb060bde2ef50b58aba19d6dfc7852da4e (diff)
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 'usr.bin/mandoc/term.c')
-rw-r--r--usr.bin/mandoc/term.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 8a88309dfe4..4f307967d9b 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.48 2010/08/20 23:22:07 schwarze Exp $ */
+/* $Id: term.c,v 1.49 2010/08/20 23:34:00 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -165,12 +165,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++;
}
/*
@@ -181,7 +180,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;
@@ -224,12 +223,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)