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; int decimali = 0;
const int virgola = picture.find (','); 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) if (virgola >= 0)
{ {
const int len = picture.len (); const int len = picture.len ();
@ -1188,9 +1213,16 @@ char* real::string(const char *picture) const
TString v (string()); TString v (string());
TString f (picture); TString f (picture);
char decsep = ',';
const int voluti = get_picture_decimals (f); if (f[f.len() - 1] == 'E')
const int virgola = v.find ('.'); {
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; int decimali = (virgola >= 0) ? v.len () - virgola - 1 : 0;
for (; voluti > decimali; decimali++) for (; voluti > decimali; decimali++)
@ -1214,7 +1246,7 @@ char* real::string(const char *picture) const
if (c == '@') if (c == '@')
c = (z == '@') ? '0' : ' '; c = (z == '@') ? '0' : ' ';
else else
if (c == '-' && f[i+1] == '.') if (c == '-' && f[i+1] == decsep)
{ {
f[i+1] = '-'; f[i+1] = '-';
c = ' '; c = ' ';
@ -1230,6 +1262,7 @@ char* real::string(const char *picture) const
case '#': case '#':
case '^': case '^':
case '.': case '.':
case ',':
f[i] = ' '; f[i] = ' ';
break; break;
case '@': case '@':