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:
parent
851ce5b460
commit
6ced2b0005
169
include/text.cpp
169
include/text.cpp
@ -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 contains tokenstring separated by @
|
||||||
|
// but with casinations for possible lack of spacing
|
||||||
|
// add spaces if needed
|
||||||
|
for (int i = 0; i < id.len(); i++)
|
||||||
{
|
{
|
||||||
id.insert(" ", i+1);
|
if (id[i] == '@' && id [i+1] == '@')
|
||||||
i+= 2;
|
{
|
||||||
|
id.insert(" ", i+1);
|
||||||
|
i+= 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// parse string
|
||||||
// parse string
|
int len;
|
||||||
int len;
|
TString80 file;
|
||||||
TString80 file;
|
TString16 field;
|
||||||
TString16 field;
|
TString80 format;
|
||||||
TString80 format;
|
char just;
|
||||||
char just;
|
|
||||||
|
|
||||||
file = id.get();
|
file = id.get();
|
||||||
format = id.get();
|
format = id.get();
|
||||||
len = (int)id.get_long();
|
len = (int)id.get_long();
|
||||||
just = id.get_char();
|
just = id.get_char();
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
if ((pos = file.find("->")) == -1)
|
if ((pos = file.find("->")) == -1)
|
||||||
error_box("field specification error");
|
error_box("field specification error");
|
||||||
else
|
|
||||||
{
|
|
||||||
file.cut(pos);
|
|
||||||
field = file.mid(pos+2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len == 0) len = id.len();
|
|
||||||
|
|
||||||
TString txt(512);
|
|
||||||
TFieldtypes type;
|
|
||||||
|
|
||||||
if (_rel != NULL)
|
|
||||||
{
|
|
||||||
// retrieve file and field
|
|
||||||
if (atoi(file) == 0)
|
|
||||||
{
|
|
||||||
// tabella
|
|
||||||
TLocalisamfile& t = _rel->lfile(file);
|
|
||||||
txt = t.get(field);
|
|
||||||
type = t.curr().type(field);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TLocalisamfile& f = _rel->lfile(atoi(file));
|
file.cut(pos);
|
||||||
txt = f.get(field);
|
field = file.mid(pos+2);
|
||||||
type = f.curr().type(field);
|
|
||||||
}
|
}
|
||||||
// apply format to date and number
|
|
||||||
switch (type)
|
if (len == 0) len = id.len();
|
||||||
|
|
||||||
|
TString txt(512);
|
||||||
|
TFieldtypes type;
|
||||||
|
|
||||||
|
if (_rel != NULL)
|
||||||
{
|
{
|
||||||
case _longfld:
|
// retrieve file and field
|
||||||
case _realfld:
|
if (atoi(file) == 0)
|
||||||
{
|
{
|
||||||
real r(txt);
|
// tabella
|
||||||
txt = r.string(format);
|
TLocalisamfile& t = _rel->lfile(file);
|
||||||
}
|
txt = t.get(field);
|
||||||
break;
|
type = t.curr().type(field);
|
||||||
case _datefld:
|
}
|
||||||
{
|
else
|
||||||
TDate dd(txt);
|
{
|
||||||
TFormatted_date d(dd, format);
|
TLocalisamfile& f = _rel->lfile(atoi(file));
|
||||||
txt = d.string();
|
txt = f.get(field);
|
||||||
}
|
type = f.curr().type(field);
|
||||||
break;
|
}
|
||||||
default:
|
// apply format to date and number
|
||||||
break;
|
switch (type)
|
||||||
}
|
|
||||||
// justify as requested
|
|
||||||
if (txt.len() < len)
|
|
||||||
{
|
|
||||||
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) == '['))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user