@@ -185,13 +185,14 @@ namespace cage
185185
186186#ifdef CAGE_SYSTEM_MAC
187187 // macOS doesn't support from_chars for floating point yet
188+
188189 void fromString (const char *s, uint32 n, float &value)
189190 {
190191 if (n == 0 )
191192 CAGE_THROW_ERROR (Exception, " empty string cannot be converted to float" );
192193
193194 // Check for leading or trailing whitespace
194- if (n > 0 && (std::isspace (s[0 ]) || std::isspace (s[n- 1 ])))
195+ if (n > 0 && (std::isspace (s[0 ]) || std::isspace (s[n - 1 ])))
195196 {
196197 CAGE_LOG_THROW (Stringizer () + " input string: " + s);
197198 CAGE_THROW_ERROR (Exception, " string with leading or trailing whitespace cannot be converted to float" );
@@ -218,7 +219,7 @@ namespace cage
218219 CAGE_THROW_ERROR (Exception, " empty string cannot be converted to double" );
219220
220221 // Check for leading or trailing whitespace
221- if (n > 0 && (std::isspace (s[0 ]) || std::isspace (s[n- 1 ])))
222+ if (n > 0 && (std::isspace (s[0 ]) || std::isspace (s[n - 1 ])))
222223 {
223224 CAGE_LOG_THROW (Stringizer () + " input string: " + s);
224225 CAGE_THROW_ERROR (Exception, " string with leading or trailing whitespace cannot be converted to double" );
@@ -249,8 +250,10 @@ namespace cage
249250 CAGE_THROW_ERROR (Exception, " failed conversion of float to string" );
250251 // Remove trailing zeros
251252 char *p = s + result - 1 ;
252- while (p > s && *p == ' 0' ) p--;
253- if (*p == ' .' ) p--;
253+ while (p > s && *p == ' 0' )
254+ p--;
255+ if (*p == ' .' )
256+ p--;
254257 *(++p) = ' \0 ' ;
255258 return numeric_cast<uint32>(p - s);
256259 }
@@ -265,27 +268,32 @@ namespace cage
265268 CAGE_THROW_ERROR (Exception, " failed conversion of double to string" );
266269 // Remove trailing zeros
267270 char *p = s + result - 1 ;
268- while (p > s && *p == ' 0' ) p--;
269- if (*p == ' .' ) p--;
271+ while (p > s && *p == ' 0' )
272+ p--;
273+ if (*p == ' .' )
274+ p--;
270275 *(++p) = ' \0 ' ;
271276 return numeric_cast<uint32>(p - s);
272277 }
278+
273279#else // CAGE_SYSTEM_MAC
274- #define GCHL_GENERATE (TYPE ) \
275- uint32 toString (char *s, uint32 n, TYPE value) \
276- { \
277- const auto [p, ec] = std::to_chars (s, s + n, value, std::chars_format::fixed); \
278- if (ec != std::errc ()) \
279- CAGE_THROW_ERROR (Exception, " failed conversion of " CAGE_STRINGIZE (TYPE) " to string" ); \
280- *p = 0 ; \
281- return numeric_cast<uint32>(p - s); \
282- } \
283- GCHL_FROMSTRING (TYPE)
280+
281+ #define GCHL_GENERATE (TYPE ) \
282+ uint32 toString (char *s, uint32 n, TYPE value) \
283+ { \
284+ const auto [p, ec] = std::to_chars (s, s + n, value, std::chars_format::fixed); \
285+ if (ec != std::errc ()) \
286+ CAGE_THROW_ERROR (Exception, " failed conversion of " CAGE_STRINGIZE (TYPE) " to string" ); \
287+ *p = 0 ; \
288+ return numeric_cast<uint32>(p - s); \
289+ } \
290+ GCHL_FROMSTRING (TYPE)
284291
285292 GCHL_GENERATE(float );
286293 GCHL_GENERATE (double );
294+ #undef GCHL_GENERATE
295+
287296#endif // CAGE_SYSTEM_MAC
288- #undef GCHL_GENERATE
289297
290298 uint32 toString (char *s, uint32 n, bool value)
291299 {
0 commit comments