Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
0f8d223c
Commit
0f8d223c
authored
Feb 09, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
protocol/ArgParser: move strtof()/strtod() switch to util/NumberParser.hxx
parent
19a2885f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
ArgParser.cxx
src/protocol/ArgParser.cxx
+2
-6
NumberParser.hxx
src/util/NumberParser.hxx
+5
-0
No files found.
src/protocol/ArgParser.cxx
View file @
0f8d223c
...
...
@@ -21,6 +21,7 @@
#include "ArgParser.hxx"
#include "Ack.hxx"
#include "Chrono.hxx"
#include "util/NumberParser.hxx"
#include <stdlib.h>
...
...
@@ -151,12 +152,7 @@ float
ParseCommandArgFloat
(
const
char
*
s
)
{
char
*
endptr
;
#ifdef ANDROID
/* strtof() requires API level 21 */
auto
value
=
strtod
(
s
,
&
endptr
);
#else
auto
value
=
strtof
(
s
,
&
endptr
);
#endif
auto
value
=
ParseFloat
(
s
,
&
endptr
);
if
(
endptr
==
s
||
*
endptr
!=
0
)
throw
FormatProtocolError
(
ACK_ERROR_ARG
,
"Float expected: %s"
,
s
);
...
...
src/util/NumberParser.hxx
View file @
0f8d223c
...
...
@@ -78,7 +78,12 @@ ParseDouble(const char *p, char **endptr=nullptr)
static
inline
float
ParseFloat
(
const
char
*
p
,
char
**
endptr
=
nullptr
)
{
#if defined(__BIONIC__) && __ANDROID_API__ < 21
/* strtof() requires API level 21 */
return
(
float
)
ParseDouble
(
p
,
endptr
);
#else
return
strtof
(
p
,
endptr
);
#endif
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment