MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / valid_number_character

Function valid_number_character

deps/lua/src/fpconv.c:75–90  ·  view source on GitHub ↗

Check for a valid number character: [-+0-9a-yA-Y.] * Eg: -0.6e+5, infinity, 0xF0.F0pF0 * * Used to find the probable end of a number. It doesn't matter if * invalid characters are counted - strtod() will find the valid * number if it exists. The risk is that slightly more memory might * be allocated before a parse error occurs. */

Source from the content-addressed store, hash-verified

73 * number if it exists. The risk is that slightly more memory might
74 * be allocated before a parse error occurs. */
75static inline int valid_number_character(char ch)
76{
77 char lower_ch;
78
79 if ('0' <= ch && ch <= '9')
80 return 1;
81 if (ch == '-' || ch == '+' || ch == '.')
82 return 1;
83
84 /* Hex digits, exponent (e), base (p), "infinity",.. */
85 lower_ch = ch | 0x20;
86 if ('a' <= lower_ch && lower_ch <= 'y')
87 return 1;
88
89 return 0;
90}
91
92/* Calculate the size of the buffer required for a strtod locale
93 * conversion. */

Callers 1

strtod_buffer_sizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected