Correzione MI3623, relativo alla stampa di righe che terminano

proprio con il carattere <.


git-svn-id: svn://10.65.10.50/trunk@5385 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1997-10-16 13:56:15 +00:00
parent 851ce5b460
commit 6ced2b0005

View File

@ -234,6 +234,8 @@ void TTextfile::read_line (
{ {
// merge field if rel != NULL; // merge field if rel != NULL;
// else fill with whitespace // else fill with whitespace
const char * save_sp = sp;
TToken_string id(80, '@'); TToken_string id(80, '@');
sp++; sp++;
bool terminated = FALSE; bool terminated = FALSE;
@ -241,102 +243,109 @@ void TTextfile::read_line (
if (ch != '\0') if (ch != '\0')
id << ch; id << ch;
else terminated = TRUE; else terminated = TRUE;
if (terminated) break; // Esce dal ciclo se non trova la matching > if (!terminated) // Prosegue normalmente se non trova la matching >
// id contains tokenstring separated by @
// but with casinations for possible lack of spacing
// add spaces if needed
for (int i = 0; i < id.len(); i++)
{
if (id[i] == '@' && id [i+1] == '@')
{
id.insert(" ", i+1);
i+= 2;
}
}
// parse string
int len;
TString80 file;
TString16 field;
TString80 format;
char just;
file = id.get();
format = id.get();
len = (int)id.get_long();
just = id.get_char();
int pos = 0;
if ((pos = file.find("->")) == -1)
error_box("field specification error");
else
{ {
file.cut(pos); // id contains tokenstring separated by @
field = file.mid(pos+2); // but with casinations for possible lack of spacing
} // add spaces if needed
for (int i = 0; i < id.len(); i++)
if (len == 0) len = id.len(); {
if (id[i] == '@' && id [i+1] == '@')
TString txt(512); {
TFieldtypes type; id.insert(" ", i+1);
i+= 2;
if (_rel != NULL) }
{ }
// retrieve file and field // parse string
if (atoi(file) == 0) int len;
{ TString80 file;
// tabella TString16 field;
TLocalisamfile& t = _rel->lfile(file); TString80 format;
txt = t.get(field); char just;
type = t.curr().type(field);
} file = id.get();
format = id.get();
len = (int)id.get_long();
just = id.get_char();
int pos = 0;
if ((pos = file.find("->")) == -1)
error_box("field specification error");
else else
{
TLocalisamfile& f = _rel->lfile(atoi(file));
txt = f.get(field);
type = f.curr().type(field);
}
// apply format to date and number
switch (type)
{ {
case _longfld: file.cut(pos);
case _realfld: field = file.mid(pos+2);
{
real r(txt);
txt = r.string(format);
} }
break;
case _datefld: if (len == 0) len = id.len();
{
TDate dd(txt); TString txt(512);
TFormatted_date d(dd, format); TFieldtypes type;
txt = d.string();
} if (_rel != NULL)
break; {
default: // retrieve file and field
break; if (atoi(file) == 0)
} {
// justify as requested // tabella
if (txt.len() < len) TLocalisamfile& t = _rel->lfile(file);
{ txt = t.get(field);
switch(type) type = t.curr().type(field);
}
else
{
TLocalisamfile& f = _rel->lfile(atoi(file));
txt = f.get(field);
type = f.curr().type(field);
}
// apply format to date and number
switch (type)
{ {
case _longfld: case _longfld:
case _realfld: case _realfld:
txt.right_just(len); {
break; real r(txt);
default: txt = r.string(format);
txt.left_just(len); }
break; break;
case _datefld:
{
TDate dd(txt);
TFormatted_date d(dd, format);
txt = d.string();
}
break;
default:
break;
}
// justify as requested
if (txt.len() < len)
{
switch(type)
{
case _longfld:
case _realfld:
txt.right_just(len);
break;
default:
txt.left_just(len);
break;
}
} }
} }
} else
else {
txt.left_just(len);
}
// ficca il testo cola' dove si puote
for (int k = 0; k < txt.len(); k++)
TEXT_TMP[ndx++] = txt[k];
} // see (!terminated) above
else // Restore sp pointer
{ {
txt.left_just(len); sp = save_sp;
ch = '<';
} }
// ficca il testo cola' dove si puote
for (int k = 0; k < txt.len(); k++)
TEXT_TMP[ndx++] = txt[k];
} }
if (ch == '@' || (ch == '$' && *(sp) == '[')) if (ch == '@' || (ch == '$' && *(sp) == '['))