| 261 | */ |
| 262 | |
| 263 | static int |
| 264 | yaml_parser_register_anchor(yaml_parser_t *parser, |
| 265 | int index, yaml_char_t *anchor) |
| 266 | { |
| 267 | yaml_alias_data_t data; |
| 268 | yaml_alias_data_t *alias_data; |
| 269 | |
| 270 | if (!anchor) return 1; |
| 271 | |
| 272 | data.anchor = anchor; |
| 273 | data.index = index; |
| 274 | data.mark = parser->document->nodes.start[index-1].start_mark; |
| 275 | |
| 276 | for (alias_data = parser->aliases.start; |
| 277 | alias_data != parser->aliases.top; alias_data ++) { |
| 278 | if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) { |
| 279 | yaml_free(anchor); |
| 280 | return yaml_parser_set_composer_error_context(parser, |
| 281 | "found duplicate anchor; first occurrence", |
| 282 | alias_data->mark, "second occurrence", data.mark); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | if (!PUSH(parser, parser->aliases, data)) { |
| 287 | yaml_free(anchor); |
| 288 | return 0; |
| 289 | } |
| 290 | |
| 291 | return 1; |
| 292 | } |
| 293 | |
| 294 | /* |
| 295 | * Compose node into its parent in the stree. |
no test coverage detected