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

Function yaml_parser_process_directives

external/libyaml/src/parser.c:1240–1347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1238 */
1239
1240static int
1241yaml_parser_process_directives(yaml_parser_t *parser,
1242 yaml_version_directive_t **version_directive_ref,
1243 yaml_tag_directive_t **tag_directives_start_ref,
1244 yaml_tag_directive_t **tag_directives_end_ref)
1245{
1246 yaml_tag_directive_t default_tag_directives[] = {
1247 {(yaml_char_t *)"!", (yaml_char_t *)"!"},
1248 {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"},
1249 {NULL, NULL}
1250 };
1251 yaml_tag_directive_t *default_tag_directive;
1252 yaml_version_directive_t *version_directive = NULL;
1253 struct {
1254 yaml_tag_directive_t *start;
1255 yaml_tag_directive_t *end;
1256 yaml_tag_directive_t *top;
1257 } tag_directives = { NULL, NULL, NULL };
1258 yaml_token_t *token;
1259
1260 if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
1261 goto error;
1262
1263 token = PEEK_TOKEN(parser);
1264 if (!token) goto error;
1265
1266 while (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
1267 token->type == YAML_TAG_DIRECTIVE_TOKEN)
1268 {
1269 if (token->type == YAML_VERSION_DIRECTIVE_TOKEN) {
1270 if (version_directive) {
1271 yaml_parser_set_parser_error(parser,
1272 "found duplicate %YAML directive", token->start_mark);
1273 goto error;
1274 }
1275 if (token->data.version_directive.major != 1
1276 || (
1277 token->data.version_directive.minor != 1
1278 && token->data.version_directive.minor != 2
1279 )) {
1280 yaml_parser_set_parser_error(parser,
1281 "found incompatible YAML document", token->start_mark);
1282 goto error;
1283 }
1284 version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t);
1285 if (!version_directive) {
1286 parser->error = YAML_MEMORY_ERROR;
1287 goto error;
1288 }
1289 version_directive->major = token->data.version_directive.major;
1290 version_directive->minor = token->data.version_directive.minor;
1291 }
1292
1293 else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) {
1294 yaml_tag_directive_t value;
1295 value.handle = token->data.tag_directive.handle;
1296 value.prefix = token->data.tag_directive.prefix;
1297

Callers 1

Calls 3

yaml_freeFunction · 0.85

Tested by

no test coverage detected