]>
Commit | Line | Data |
---|---|---|
a7d135ee ER |
1 | Index: MilkdropPresetFactory/Parser.cpp |
2 | =================================================================== | |
3 | --- MilkdropPresetFactory/Parser.cpp (revision 1510) | |
4 | +++ MilkdropPresetFactory/Parser.cpp (working copy) | |
5 | @@ -1269,28 +1269,13 @@ | |
6 | /* Parses a floating point number */ | |
7 | int Parser::string_to_float(char * string, float * float_ptr) | |
8 | { | |
9 | + std::istringstream stream(string); | |
10 | + stream >> *float_ptr; | |
11 | ||
12 | - char ** error_ptr; | |
13 | - | |
14 | - if (*string == 0) | |
15 | + if (stream.fail()) | |
16 | return PROJECTM_PARSE_ERROR; | |
17 | ||
18 | - error_ptr = (char**)wipemalloc(sizeof(char**)); | |
19 | - | |
20 | - (*float_ptr) = strtod(string, error_ptr); | |
21 | - | |
22 | - /* These imply a succesful parse of the string */ | |
23 | - if ((**error_ptr == '\0') || (**error_ptr == '\r')) | |
24 | - { | |
25 | - free(error_ptr); | |
26 | - error_ptr = NULL; | |
27 | - return PROJECTM_SUCCESS; | |
28 | - } | |
29 | - | |
30 | - (*float_ptr) = 0; | |
31 | - free(error_ptr); | |
32 | - error_ptr = NULL; | |
33 | - return PROJECTM_PARSE_ERROR; | |
34 | + return PROJECTM_SUCCESS; | |
35 | } | |
36 | ||
37 | /* Parses a floating point number */ | |
38 | @@ -1298,11 +1283,9 @@ | |
39 | { | |
40 | ||
41 | char string[MAX_TOKEN_SIZE]; | |
42 | - char ** error_ptr; | |
43 | token_t token; | |
44 | int sign; | |
45 | ||
46 | - error_ptr =(char**) wipemalloc(sizeof(char**)); | |
47 | ||
48 | token = parseToken(fs, string); | |
49 | ||
50 | @@ -1322,28 +1305,13 @@ | |
51 | ||
52 | if (string[0] == 0) | |
53 | { | |
54 | - free(error_ptr); | |
55 | - error_ptr = NULL; | |
56 | return PROJECTM_PARSE_ERROR; | |
57 | } | |
58 | ||
59 | - (*float_ptr) = sign*strtod(string, error_ptr); | |
60 | + std::istringstream stream(string); | |
61 | + stream >> *float_ptr; | |
62 | ||
63 | - /* No conversion was performed */ | |
64 | - if ((**error_ptr == '\0') || (**error_ptr == '\r')) | |
65 | - { | |
66 | - free(error_ptr); | |
67 | - error_ptr = NULL; | |
68 | - return PROJECTM_SUCCESS; | |
69 | - } | |
70 | - | |
71 | - if (PARSE_DEBUG) printf("parse_float: float conversion failed for string \"%s\"\n", string); | |
72 | - | |
73 | - (*float_ptr) = 0; | |
74 | - free(error_ptr); | |
75 | - error_ptr = NULL; | |
76 | - return PROJECTM_PARSE_ERROR; | |
77 | - | |
78 | + return PROJECTM_SUCCESS; | |
79 | } | |
80 | ||
81 | /* Parses a per frame equation. That is, interprets a stream of data as a per frame equation */ |