mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-02-06 04:06:36 -05:00
spa: add locale independent spa_dtoa
And use this in spa_json_format_float() where we also avoid invalid json floats. Use json float format in some places where we serialize json floats. Add a unit test. See #2223
This commit is contained in:
parent
5f4d031db0
commit
2b16df4e89
6 changed files with 40 additions and 13 deletions
|
|
@ -354,6 +354,16 @@ static inline bool spa_atod(const char *str, double *val)
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline char *spa_dtoa(char *str, size_t size, double val)
|
||||
{
|
||||
int i, l;
|
||||
l = spa_scnprintf(str, size, "%f", val);
|
||||
for (i = 0; i < l; i++)
|
||||
if (str[i] == ',')
|
||||
str[i] = '.';
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue