src/misc.cpp

changeset 308
4e2425bd4dc7
parent 286
7a562bf3d829
child 332
3013acb1df53
equal deleted inserted replaced
307:c731a22899a3 308:4e2425bd4dc7
247 list << arg.value (); 247 list << arg.value ();
248 248
249 return list.join (delim); 249 return list.join (delim);
250 } 250 }
251 251
252 double atof( str val )
253 {
254 // Disable the locale while parsing the line or atof's behavior changes
255 // between locales (i.e. fails to read decimals properly). That is
256 // quite undesired...
257 setlocale( LC_NUMERIC, "C" );
258 char* buf = new char[val.length()];
259 char* bufptr = &buf[0];
260
261 for( qchar& c : val )
262 *bufptr++ = c.toAscii();
263 *bufptr = '\0';
264
265 double fval = atof( buf );
266 delete[] buf;
267 return fval;
268 }
252 269
253 // ============================================================================= 270 // =============================================================================
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
255 // ============================================================================= 272 // =============================================================================
256 StringParser::StringParser (str inText, char sep) { 273 StringParser::StringParser (str inText, char sep) {

mercurial