MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / yaml_parser_load_node_add

Function yaml_parser_load_node_add

external/libyaml/src/loader.c:298–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296 */
297
298static int
299yaml_parser_load_node_add(yaml_parser_t *parser, struct loader_ctx *ctx,
300 int index)
301{
302 struct yaml_node_s *parent;
303 int parent_index;
304
305 if (STACK_EMPTY(parser, *ctx)) {
306 /* This is the root node, there's no tree to add it to. */
307 return 1;
308 }
309
310 parent_index = *((*ctx).top - 1);
311 parent = &parser->document->nodes.start[parent_index-1];
312
313 switch (parent->type) {
314 case YAML_SEQUENCE_NODE:
315 if (!STACK_LIMIT(parser, parent->data.sequence.items, INT_MAX-1))
316 return 0;
317 if (!PUSH(parser, parent->data.sequence.items, index))
318 return 0;
319 break;
320 case YAML_MAPPING_NODE: {
321 yaml_node_pair_t pair;
322 if (!STACK_EMPTY(parser, parent->data.mapping.pairs)) {
323 yaml_node_pair_t *p = parent->data.mapping.pairs.top - 1;
324 if (p->key != 0 && p->value == 0) {
325 p->value = index;
326 break;
327 }
328 }
329
330 pair.key = index;
331 pair.value = 0;
332 if (!STACK_LIMIT(parser, parent->data.mapping.pairs, INT_MAX-1))
333 return 0;
334 if (!PUSH(parser, parent->data.mapping.pairs, pair))
335 return 0;
336
337 break;
338 }
339 default:
340 assert(0); /* Could not happen. */
341 return 0;
342 }
343 return 1;
344}
345
346/*
347 * Compose a node corresponding to an alias.

Callers 4

yaml_parser_load_aliasFunction · 0.85
yaml_parser_load_scalarFunction · 0.85
yaml_parser_load_mappingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected