Core: Format(%.2f) now produces '.' despite setlocale

git-svn-id: svn://ultimatepp.org/upp/trunk@10642 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2017-01-05 07:32:32 +00:00
parent 50adfc8a3b
commit 66e00d369e
2 changed files with 11 additions and 21 deletions

View file

@ -676,28 +676,16 @@ String StringFormatter(const Formatting& f)
if(!lpad)
r.Cat(q);
return r;
}
/*
if(f.format.GetCount())
String fmt = '%' + f.format + f.id;
char h[256];
#ifdef COMPILER_MSC
int n = _snprintf(h, 256, fmt, ~s);
if(n < 0)
#else
int n = snprintf(h, 255, fmt, ~s);
if(n >= 254)
#endif
{
#ifdef COMPILER_MSC
n = _scprintf(fmt, ~s);
#endif
Buffer<char> ah(n + 1);
sprintf(ah, fmt, ~s);
return String(ah, n);
static inline
void sFixPoint(char *s) // We do not want locale to affect decimal point, convert ',' to '.'
{
while(*s) {
if(*s == ',')
*s = '.';
s++;
}
return String(h, n);
*/
}
String FloatFormatter(const Formatting& f)
@ -718,10 +706,12 @@ String FloatFormatter(const Formatting& f)
#endif
Buffer<char> ah(n + 1);
sprintf(ah, fmt, d);
sFixPoint(ah);
return String(ah, n);
}
if(n < 0)
return String();
sFixPoint(h);
return String(h, n);
}

View file

@ -1,5 +1,5 @@
KEY(SETMAIN, "Set main package..", K_CTRL_M)
KEY(EDITFILE, "Open file", K_CTRL_O)
KEY(EDITFILE, "Edit file", K_CTRL_O)
KEY(OPPOSITE, "Opposite file", K_ALT_O)
KEY(SAVEFILE, "Save", K_CTRL_S)
KEY(READONLY, "Read only", 0)