Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
7f1990ea
Commit
7f1990ea
authored
2 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
parameter_to_double: allow parameter ending with character f
parent
01f49562
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/param_conversion.cc
+11
-10
11 additions, 10 deletions
src/param_conversion.cc
with
11 additions
and
10 deletions
src/param_conversion.cc
+
11
−
10
View file @
7f1990ea
...
...
@@ -37,7 +37,7 @@ parameter_to_word(const char *cstring)
}
static
inline
void
parameter
E
rror
(
const
char
*
name
,
const
char
*
cstring
,
const
char
*
endptr
)
parameter
_e
rror
(
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
)
parameter
E
rror
(
"Integer"
,
cstring
,
endptr
);
if
(
*
endptr
)
parameter
_e
rror
(
"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
)
parameter
E
rror
(
"Integer"
,
cstring
,
endptr
);
if
(
*
endptr
)
parameter
_e
rror
(
"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
)
parameter
E
rror
(
"Integer"
,
cstring
,
endptr
);
if
(
*
endptr
)
parameter
_e
rror
(
"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
)
parameter
E
rror
(
"Integer"
,
cstring
,
endptr
);
if
(
*
endptr
&&
*
endptr
!=
'/'
&&
(
endptr
-
cstring
)
==
0
)
parameter
_e
rror
(
"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
)
parameter
E
rror
(
"Integer"
,
startptr
,
endptr
);
if
(
*
endptr
!=
0
&&
*
endptr
!=
'/'
&&
(
endptr
-
startptr
)
==
0
)
parameter
_e
rror
(
"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
)
parameter
E
rror
(
"Integer"
,
startptr
,
endptr
);
if
(
*
endptr
!=
0
&&
*
endptr
!=
'/'
&&
(
endptr
-
startptr
)
==
0
)
parameter
_e
rror
(
"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
)
parameter
E
rror
(
"Integer"
,
startptr
,
endptr
);
if
(
*
endptr
!=
0
&&
(
endptr
-
startptr
)
==
0
)
parameter
_e
rror
(
"Integer"
,
startptr
,
endptr
);
inc
=
ival
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment