Aggiunta gestione pictures all'americana (+E alla fine se ambigue)

git-svn-id: svn://10.65.10.50/trunk@2503 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1996-01-25 11:39:50 +00:00
parent 276fc1b5bc
commit c0af0706e0

View File

@ -1163,10 +1163,35 @@ char* real::points (int dec) const
}
HIDDEN int get_picture_decimals (const TString& picture)
HIDDEN int get_picture_decimals (const TString& picture, char& decsep)
{
int decimali = 0;
const int virgola = picture.find (',');
int decimali = 0;
int virgola = -1;
if (decsep == ',')
{
int firstcomma = -1, lastcomma = -1, firstdot = -1, lastdot = -1;
for (int i = 0; picture[i]; i++)
{
if (picture[i] == ',')
{
if (firstcomma < 0) firstcomma = i;
lastcomma = i;
}
else if (picture[i] == '.')
{
if (firstdot < 0) firstdot = i;
lastdot = i;
}
}
if (lastcomma >= 0 && lastdot >= 0)
{
virgola = lastcomma > lastdot ? lastcomma : lastdot;
decsep = picture[virgola];
}
}
else virgola = picture.find('.');
if (virgola >= 0)
{
const int len = picture.len ();
@ -1187,10 +1212,17 @@ char* real::string(const char *picture) const
return literals ();
TString v (string());
TString f (picture);
const int voluti = get_picture_decimals (f);
const int virgola = v.find ('.');
TString f (picture);
char decsep = ',';
if (f[f.len() - 1] == 'E')
{
f.rtrim(1);
decsep = '.';
}
const int voluti = get_picture_decimals (f, decsep);
const int virgola = v.find ('.'); // v e' la nostra cifra, certamente in english format
int decimali = (virgola >= 0) ? v.len () - virgola - 1 : 0;
for (; voluti > decimali; decimali++)
@ -1214,7 +1246,7 @@ char* real::string(const char *picture) const
if (c == '@')
c = (z == '@') ? '0' : ' ';
else
if (c == '-' && f[i+1] == '.')
if (c == '-' && f[i+1] == decsep)
{
f[i+1] = '-';
c = ' ';
@ -1230,6 +1262,7 @@ char* real::string(const char *picture) const
case '#':
case '^':
case '.':
case ',':
f[i] = ' ';
break;
case '@':