MCPcopy Create free account
hub / github.com/antirez/ds4 / json_bool

Function json_bool

ds4_server.c:290–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288 if (end == *p) return false;
289 *p = end;
290 *out = v;
291 return true;
292}
293
294static bool json_int(const char **p, int *out) {
295 double v = 0.0;
296 if (!json_number(p, &v)) return false;
297 /* json_number() uses strtod(), which accepts "NaN"/"Infinity". NaN fails
298 * every comparison, so a plain `v < 0` clamp would let it through to the
299 * (int) cast, which is undefined for NaN; `!(v >= 0)` folds NaN (and
300 * negatives) to 0. +/-Infinity are handled by the two clamps. */
301 if (!(v >= 0)) v = 0;
302 if (v > INT_MAX) v = INT_MAX;
303 *out = (int)v;
304 return true;

Callers 6

parse_stream_optionsFunction · 0.85
parse_chat_requestFunction · 0.85
parse_anthropic_requestFunction · 0.85
parse_responses_requestFunction · 0.85
parse_completion_requestFunction · 0.85

Calls 2

json_wsFunction · 0.85
json_litFunction · 0.85

Tested by

no test coverage detected