| 302 | */ |
| 303 | |
| 304 | static int |
| 305 | yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event) |
| 306 | { |
| 307 | yaml_node_t node; |
| 308 | int index; |
| 309 | yaml_char_t *tag = first_event->data.scalar.tag; |
| 310 | |
| 311 | if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; |
| 312 | |
| 313 | if (!tag || strcmp((char *)tag, "!") == 0) { |
| 314 | yaml_free(tag); |
| 315 | tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG); |
| 316 | if (!tag) goto error; |
| 317 | } |
| 318 | |
| 319 | SCALAR_NODE_INIT(node, tag, first_event->data.scalar.value, |
| 320 | first_event->data.scalar.length, first_event->data.scalar.style, |
| 321 | first_event->start_mark, first_event->end_mark); |
| 322 | |
| 323 | if (!PUSH(parser, parser->document->nodes, node)) goto error; |
| 324 | |
| 325 | index = (int)(parser->document->nodes.top - parser->document->nodes.start); |
| 326 | |
| 327 | if (!yaml_parser_register_anchor(parser, index, |
| 328 | first_event->data.scalar.anchor)) return 0; |
| 329 | |
| 330 | return index; |
| 331 | |
| 332 | error: |
| 333 | yaml_free(tag); |
| 334 | yaml_free(first_event->data.scalar.anchor); |
| 335 | yaml_free(first_event->data.scalar.value); |
| 336 | return 0; |
| 337 | } |
| 338 | |
| 339 | /* |
| 340 | * Compose a sequence node. |
no test coverage detected