From 66e00d369efc7d617cca7dc729d5ccc04ae5cc6f Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 5 Jan 2017 07:32:32 +0000 Subject: [PATCH] Core: Format(%.2f) now produces '.' despite setlocale git-svn-id: svn://ultimatepp.org/upp/trunk@10642 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Format.cpp | 30 ++++++++++-------------------- uppsrc/ide/ide.key | 2 +- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/uppsrc/Core/Format.cpp b/uppsrc/Core/Format.cpp index 0ef3b563c..08a63a624 100644 --- a/uppsrc/Core/Format.cpp +++ b/uppsrc/Core/Format.cpp @@ -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 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 ah(n + 1); sprintf(ah, fmt, d); + sFixPoint(ah); return String(ah, n); } if(n < 0) return String(); + sFixPoint(h); return String(h, n); } diff --git a/uppsrc/ide/ide.key b/uppsrc/ide/ide.key index 1290fa597..66164c128 100644 --- a/uppsrc/ide/ide.key +++ b/uppsrc/ide/ide.key @@ -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)