Rif. mod. 96/4. Variazione a TParagraph_string::tokenize().

La variazione riguarda il contemporaneo scanning di eventuali '\n',
sostituendoli con '|', pur mantenendo il precedente algoritmo di
separazione (separa all'ultimo spazio prima della larghezza o
altrimenti tronca alla larghezza massima).


git-svn-id: svn://10.65.10.50/trunk@2386 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1996-01-03 16:09:17 +00:00
parent 0b75887d1c
commit 2d3cfcb803

View File

@ -1330,24 +1330,27 @@ const TString& TParagraph_string::operator =(const char* s)
}
void TParagraph_string::tokenize()
{
int start = 0;
for (int end = start+_width; end < len(); end = start+_width)
{
int last_space = 0;
int chars_in_row = 0;
TString stmp;
for (int start = 0; start < len(); start++)
{
for (int i = end; i >= start; i--)
if (is_space(_str[i])) break;
if (i < start)
switch (_str[start])
{
insert("|", end);
start = end+1;
case '\n': _str[start]='|'; last_space = 0;chars_in_row=0; break;
case ' ' : last_space = start; chars_in_row++; break;
default : chars_in_row++; break;
}
else
stmp<<_str[start];
if (chars_in_row == _width)
{
_str[i] = '|';
start = i+1;
if (last_space!=0) stmp[last_space] = '|';
else stmp<<"|";
last_space = 0; chars_in_row = 0;
}
}
TToken_string::operator=(stmp);
}
///////////////////////////////////////////////////////////