Skip to content
Snippets Groups Projects
Commit 7f1990ea authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

parameter_to_double: allow parameter ending with character f

parent 01f49562
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ parameter_to_word(const char *cstring)
}
static inline void
parameterError(const char *name, const char *cstring, const char *endptr)
parameter_error(const char *name, const char *cstring, const char *endptr)
{
cdo_abort("%s parameter >%s< contains invalid character at position %d!", name, cstring, (int) (endptr - cstring + 1));
}
......@@ -47,7 +47,8 @@ parameter_to_double(const char *const cstring)
{
char *endptr = nullptr;
const auto fval = strtod(cstring, &endptr);
if (*endptr) parameterError("Float", cstring, endptr);
if (*endptr && *endptr == 'f') endptr++;
if (*endptr) parameter_error("Float", cstring, endptr);
return fval;
}
......@@ -56,7 +57,7 @@ parameter_to_int(const char *const cstring)
{
char *endptr = nullptr;
const auto ival = (int) strtol(cstring, &endptr, 10);
if (*endptr) parameterError("Integer", cstring, endptr);
if (*endptr) parameter_error("Integer", cstring, endptr);
return ival;
}
......@@ -65,7 +66,7 @@ parameter_to_long(const char *const cstring)
{
char *endptr = nullptr;
const auto ival = strtol(cstring, &endptr, 10);
if (*endptr) parameterError("Integer", cstring, endptr);
if (*endptr) parameter_error("Integer", cstring, endptr);
return ival;
}
......@@ -74,7 +75,7 @@ parameter_to_size_t(const char *const cstring)
{
char *endptr = nullptr;
const auto ival = (size_t) strtoimax(cstring, &endptr, 10);
if (*endptr) parameterError("Integer", cstring, endptr);
if (*endptr) parameter_error("Integer", cstring, endptr);
return ival;
}
......@@ -83,7 +84,7 @@ parameter_to_intlist(const char *const cstring)
{
char *endptr = nullptr;
const auto ival = (int) strtol(cstring, &endptr, 10);
if (*endptr && *endptr != '/' && (endptr - cstring) == 0) parameterError("Integer", cstring, endptr);
if (*endptr && *endptr != '/' && (endptr - cstring) == 0) parameter_error("Integer", cstring, endptr);
return ival;
}
......@@ -167,7 +168,7 @@ radius_str_to_deg(const char *string)
cdo_abort("Float parameter >%s< contains invalid character at position %d!", string, (int) (endptr - string + 1));
}
if (radius > 180.) radius = 180.;
if (radius > 180.0) radius = 180.0;
return radius;
}
......@@ -350,7 +351,7 @@ split_intstring(const char *const intstr, int &first, int &last, int &inc)
auto startptr = intstr;
char *endptr = nullptr;
auto ival = (int) strtol(startptr, &endptr, 10);
if (*endptr != 0 && *endptr != '/' && (endptr - startptr) == 0) parameterError("Integer", startptr, endptr);
if (*endptr != 0 && *endptr != '/' && (endptr - startptr) == 0) parameter_error("Integer", startptr, endptr);
first = ival;
last = ival;
inc = 1;
......@@ -360,7 +361,7 @@ split_intstring(const char *const intstr, int &first, int &last, int &inc)
startptr = endptr + 1;
endptr = nullptr;
ival = (int) strtol(startptr, &endptr, 10);
if (*endptr != 0 && *endptr != '/' && (endptr - startptr) == 0) parameterError("Integer", startptr, endptr);
if (*endptr != 0 && *endptr != '/' && (endptr - startptr) == 0) parameter_error("Integer", startptr, endptr);
last = ival;
if (first > last) inc = -1;
......@@ -369,7 +370,7 @@ split_intstring(const char *const intstr, int &first, int &last, int &inc)
startptr = endptr + 1;
endptr = nullptr;
ival = (int) strtol(startptr, &endptr, 10);
if (*endptr != 0 && (endptr - startptr) == 0) parameterError("Integer", startptr, endptr);
if (*endptr != 0 && (endptr - startptr) == 0) parameter_error("Integer", startptr, endptr);
inc = ival;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment