MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fpconv_update_locale

Function fpconv_update_locale

app/redis-6.2.6/deps/lua/src/fpconv.c:52–66  ·  view source on GitHub ↗

In theory multibyte decimal_points are possible, but * Lua CJSON only supports UTF-8 and known locales only have * single byte decimal points ([.,]). * * localconv() may not be thread safe (=>crash), and nl_langinfo() is * not supported on some platforms. Use sprintf() instead - if the * locale does change, at least Lua CJSON won't crash. */

Source from the content-addressed store, hash-verified

50 * not supported on some platforms. Use sprintf() instead - if the
51 * locale does change, at least Lua CJSON won't crash. */
52static void fpconv_update_locale()
53{
54 char buf[8];
55
56 snprintf(buf, sizeof(buf), "%g", 0.5);
57
58 /* Failing this test might imply the platform has a buggy dtoa
59 * implementation or wide characters */
60 if (buf[0] != '0' || buf[2] != '5' || buf[3] != 0) {
61 fprintf(stderr, "Error: wide characters found or printf() bug.");
62 abort();
63 }
64
65 locale_decimal_point = buf[1];
66}
67
68/* Check for a valid number character: [-+0-9a-yA-Y.]
69 * Eg: -0.6e+5, infinity, 0xF0.F0pF0

Callers 1

fpconv_initFunction · 0.85

Calls 2

snprintfFunction · 0.85
abortClass · 0.85

Tested by

no test coverage detected