version 1.29, 2010/04/13 22:41:48 |
version 1.30, 2010/04/23 00:23:47 |
|
|
perror(NULL); |
perror(NULL); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
p->tabwidth = 5; |
p->enc = enc; |
p->enc = enc; |
return(p); |
return(p); |
} |
} |
|
|
* breaking the line. |
* breaking the line. |
*/ |
*/ |
|
|
vis = vend = i = 0; |
vis = i = 0; |
while (i < (int)p->col) { |
while (i < (int)p->col) { |
|
|
/* |
/* |
|
|
vbl = (size_t)(ASCII_EOS == p->buf[i] ? 2 : |
vbl = (size_t)(ASCII_EOS == p->buf[i] ? 2 : |
(0 == vis ? 0 : 1)); |
(0 == vis ? 0 : 1)); |
vis += vbl; |
vis += vbl; |
|
vend = vis; |
|
|
/* |
/* |
|
* Handle literal tab characters. |
|
*/ |
|
for (j = i; j < (int)p->col; j++) { |
|
if ('\t' != p->buf[j]) |
|
break; |
|
/* Collapse tab with inter-word spacing. */ |
|
if (vis > 0 && j == i) |
|
vend = vis - 1; |
|
vend = (vend/p->tabwidth+1)*p->tabwidth; |
|
vbl += vend - vis; |
|
vis = vend; |
|
} |
|
|
|
/* |
* Count up visible word characters. Control sequences |
* Count up visible word characters. Control sequences |
* (starting with the CSI) aren't counted. A space |
* (starting with the CSI) aren't counted. A space |
* generates a non-printing word, which is valid (the |
* generates a non-printing word, which is valid (the |
|
|
*/ |
*/ |
|
|
/* LINTED */ |
/* LINTED */ |
for (j = i, jhy = 0, vend = vis; j < (int)p->col; j++) { |
for (jhy = 0; j < (int)p->col; j++) { |
if (j && ' ' == p->buf[j]) |
if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j]) |
break; |
break; |
else if (8 == p->buf[j]) |
else if (8 == p->buf[j]) |
vend--; |
vend--; |
|
|
} |
} |
|
|
/* |
/* |
|
* Skip leading tabs, they were handled above. |
|
*/ |
|
while (i < (int)p->col && '\t' == p->buf[i]) |
|
i++; |
|
|
|
/* |
* Finally, write out the word. |
* Finally, write out the word. |
*/ |
*/ |
for ( ; i < (int)p->col; i++) { |
for ( ; i < (int)p->col; i++) { |
if (vend > bp && jhy > 0 && i > jhy) |
if (vend > bp && jhy > 0 && i > jhy) |
|
break; |
|
if ('\t' == p->buf[i]) |
break; |
break; |
if (' ' == p->buf[i]) { |
if (' ' == p->buf[i]) { |
i++; |
i++; |