mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core: Atof (comma safe atof)
git-svn-id: svn://ultimatepp.org/upp/trunk@10764 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
4b616bf2db
commit
7063d4d9e1
6 changed files with 14 additions and 4 deletions
|
|
@ -182,6 +182,11 @@ double ScanDouble(const wchar *p, const wchar **endptr, bool accept_comma)
|
|||
return ScanDoubleT(p, endptr, accept_comma);
|
||||
}
|
||||
|
||||
double Atof(const char *s)
|
||||
{
|
||||
return Nvl(ScanDouble(s));
|
||||
}
|
||||
|
||||
Value StrIntValue(const char *s)
|
||||
{
|
||||
if(s && *s) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ int64 ScanInt64(const char *ptr, const char **endptr = NULL, int radix =
|
|||
double ScanDouble(const char *ptr, const char **endptr = NULL, bool accept_comma = true);
|
||||
double ScanDouble(const wchar *ptr, const wchar **endptr = NULL, bool accept_comma = true);
|
||||
|
||||
double Atof(const char *s);
|
||||
|
||||
Value StrIntValue(const char *s);
|
||||
|
||||
inline int StrInt(const char* s) { return ScanInt(s); }
|
||||
|
|
|
|||
|
|
@ -240,6 +240,9 @@ namespace std {
|
|||
#define END_UPP_NAMESPACE }
|
||||
#define UPP Upp
|
||||
|
||||
// #define atof @ // atof is broken, as it depends on setlocale - might want ',' instead of '.' breaking a lot of code
|
||||
// Use Atof instead (which accepts both '.' and ',' as decimal separator)
|
||||
|
||||
namespace Upp {
|
||||
|
||||
#ifndef flagNODEPRECATED
|
||||
|
|
|
|||
|
|
@ -835,7 +835,7 @@ bool RTFParser::ReadField(const char *p)
|
|||
face = Font::FindFaceNameIndex(symdef[f + 1]);
|
||||
f = symdef.Find("\\s");
|
||||
if(f >= 0 && f + 1 < symdef.GetCount())
|
||||
height = PointDots(fround(2 * atof(symdef[f + 1]))) >> 1;
|
||||
height = PointDots(fround(2 * Atof(symdef[f + 1]))) >> 1;
|
||||
if(face < 0)
|
||||
#ifdef PLATFORM_WIN32
|
||||
face = Font::SYMBOL;
|
||||
|
|
|
|||
|
|
@ -212,13 +212,13 @@ Array<double> GetTransformArgs(String str, const char *command) {
|
|||
if ((endpos = str.Find(',', pos)) < 0)
|
||||
break;
|
||||
double &d = args.Add();
|
||||
d = atof(str.Mid(pos, endpos-pos));
|
||||
d = Atof(str.Mid(pos, endpos-pos));
|
||||
pos = endpos+1;
|
||||
}
|
||||
if (args.GetCount() < 2) {
|
||||
if ((endpos = str.Find(')', pos)) >= 0) {
|
||||
double &d = args.Add();
|
||||
d = atof(str.Mid(pos, endpos-pos));
|
||||
d = Atof(str.Mid(pos, endpos-pos));
|
||||
}
|
||||
}
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -641,7 +641,7 @@ void PostgreSQLConnection::GetColumn(int i, Ref f) const
|
|||
f.SetValue(atoi(s));
|
||||
break;
|
||||
case DOUBLE_V:
|
||||
f.SetValue(atof(s));
|
||||
f.SetValue(Atof(s));
|
||||
break;
|
||||
case BOOL_V:
|
||||
f.SetValue(*s == 't' ? "1" : "0");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue