mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: simplify custom strtod() interface
The strtod_flags() function allowed for fine control of how to
parse strings. However, only two different modes were actually
used: ascii mode ("C" locale) and permissive mode (accept ","
and "." as decimal separator).
The former had already its own function name (ascii_strtod).
Make the latter a separatge function as well (permissive_strtod)
and remove all the flags rigmarole.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
628e2fe933
commit
092035d883
8 changed files with 57 additions and 73 deletions
|
|
@ -1240,7 +1240,7 @@ QStringList stringToList(const QString &s)
|
|||
weight_t string_to_weight(const char *str)
|
||||
{
|
||||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
double value = permissive_strtod(str, &end);
|
||||
QString rest = QString(end).trimmed();
|
||||
QString local_kg = gettextFromC::tr("kg");
|
||||
QString local_lbs = gettextFromC::tr("lbs");
|
||||
|
|
@ -1264,7 +1264,7 @@ lbs:
|
|||
depth_t string_to_depth(const char *str)
|
||||
{
|
||||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
double value = permissive_strtod(str, &end);
|
||||
QString rest = QString(end).trimmed();
|
||||
QString local_ft = gettextFromC::tr("ft");
|
||||
QString local_m = gettextFromC::tr("m");
|
||||
|
|
@ -1289,7 +1289,7 @@ ft:
|
|||
pressure_t string_to_pressure(const char *str)
|
||||
{
|
||||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
double value = permissive_strtod(str, &end);
|
||||
QString rest = QString(end).trimmed();
|
||||
QString local_psi = gettextFromC::tr("psi");
|
||||
QString local_bar = gettextFromC::tr("bar");
|
||||
|
|
@ -1312,7 +1312,7 @@ psi:
|
|||
volume_t string_to_volume(const char *str, pressure_t workp)
|
||||
{
|
||||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
double value = permissive_strtod(str, &end);
|
||||
QString rest = QString(end).trimmed();
|
||||
QString local_l = gettextFromC::tr("l");
|
||||
QString local_cuft = gettextFromC::tr("cuft");
|
||||
|
|
@ -1343,7 +1343,7 @@ l:
|
|||
fraction_t string_to_fraction(const char *str)
|
||||
{
|
||||
const char *end;
|
||||
double value = strtod_flags(str, &end, 0);
|
||||
double value = permissive_strtod(str, &end);
|
||||
fraction_t fraction;
|
||||
|
||||
fraction.permille = lrint(value * 10);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue