1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 11:19:18 +01:00
Clementine-audio-player-Mac.../3rdparty/libprojectm/patches/06-fix-numeric-locale.patch

82 lines
1.9 KiB
Diff

Index: MilkdropPresetFactory/Parser.cpp
===================================================================
--- MilkdropPresetFactory/Parser.cpp (revision 1510)
+++ MilkdropPresetFactory/Parser.cpp (working copy)
@@ -1269,28 +1269,13 @@
/* Parses a floating point number */
int Parser::string_to_float(char * string, float * float_ptr)
{
+ std::istringstream stream(string);
+ stream >> *float_ptr;
- char ** error_ptr;
-
- if (*string == 0)
+ if (stream.fail())
return PROJECTM_PARSE_ERROR;
- error_ptr = (char**)wipemalloc(sizeof(char**));
-
- (*float_ptr) = strtod(string, error_ptr);
-
- /* These imply a succesful parse of the string */
- if ((**error_ptr == '\0') || (**error_ptr == '\r'))
- {
- free(error_ptr);
- error_ptr = NULL;
- return PROJECTM_SUCCESS;
- }
-
- (*float_ptr) = 0;
- free(error_ptr);
- error_ptr = NULL;
- return PROJECTM_PARSE_ERROR;
+ return PROJECTM_SUCCESS;
}
/* Parses a floating point number */
@@ -1298,11 +1283,9 @@
{
char string[MAX_TOKEN_SIZE];
- char ** error_ptr;
token_t token;
int sign;
- error_ptr =(char**) wipemalloc(sizeof(char**));
token = parseToken(fs, string);
@@ -1322,28 +1305,13 @@
if (string[0] == 0)
{
- free(error_ptr);
- error_ptr = NULL;
return PROJECTM_PARSE_ERROR;
}
- (*float_ptr) = sign*strtod(string, error_ptr);
+ std::istringstream stream(string);
+ stream >> *float_ptr;
- /* No conversion was performed */
- if ((**error_ptr == '\0') || (**error_ptr == '\r'))
- {
- free(error_ptr);
- error_ptr = NULL;
- return PROJECTM_SUCCESS;
- }
-
- if (PARSE_DEBUG) printf("parse_float: float conversion failed for string \"%s\"\n", string);
-
- (*float_ptr) = 0;
- free(error_ptr);
- error_ptr = NULL;
- return PROJECTM_PARSE_ERROR;
-
+ return PROJECTM_SUCCESS;
}
/* Parses a per frame equation. That is, interprets a stream of data as a per frame equation */