| 219 | flag_block_comment = 1 << 14; |
| 220 | |
| 221 | json_value * json_parse_ex (json_settings * settings, |
| 222 | const json_char * json, |
| 223 | size_t length, |
| 224 | char * error_buf) |
| 225 | { |
| 226 | json_char error [json_error_max]; |
| 227 | const json_char * end; |
| 228 | json_value * top, * root, * alloc = 0; |
| 229 | json_state state = { 0 }; |
| 230 | long flags; |
| 231 | long num_digits = 0, num_e = 0; |
| 232 | json_int_t num_fraction = 0; |
| 233 | |
| 234 | /* Skip UTF-8 BOM |
| 235 | */ |
| 236 | if (length >= 3 && ((unsigned char) json [0]) == 0xEF |
| 237 | && ((unsigned char) json [1]) == 0xBB |
| 238 | && ((unsigned char) json [2]) == 0xBF) |
| 239 | { |
| 240 | json += 3; |
| 241 | length -= 3; |
| 242 | } |
| 243 | |
| 244 | error[0] = '\0'; |
| 245 | end = (json + length); |
| 246 | |
| 247 | memcpy (&state.settings, settings, sizeof (json_settings)); |
| 248 | |
| 249 | if (!state.settings.mem_alloc) |
| 250 | state.settings.mem_alloc = default_alloc; |
| 251 | |
| 252 | if (!state.settings.mem_free) |
| 253 | state.settings.mem_free = default_free; |
| 254 | |
| 255 | memset (&state.uint_max, 0xFF, sizeof (state.uint_max)); |
| 256 | memset (&state.ulong_max, 0xFF, sizeof (state.ulong_max)); |
| 257 | |
| 258 | state.uint_max -= 8; /* limit of how much can be added before next check */ |
| 259 | state.ulong_max -= 8; |
| 260 | |
| 261 | for (state.first_pass = 1; state.first_pass >= 0; -- state.first_pass) |
| 262 | { |
| 263 | json_uchar uchar; |
| 264 | unsigned char uc_b1, uc_b2, uc_b3, uc_b4; |
| 265 | json_char * string = 0; |
| 266 | unsigned int string_length = 0; |
| 267 | |
| 268 | top = root = 0; |
| 269 | flags = flag_seek_value; |
| 270 | |
| 271 | state.cur_line = 1; |
| 272 | |
| 273 | for (state.ptr = json ;; ++ state.ptr) |
| 274 | { |
| 275 | json_char b = (state.ptr == end ? 0 : *state.ptr); |
| 276 | |
| 277 | if (flags & flag_string) |
| 278 | { |
no test coverage detected