Skip to content

Commit

Permalink
implement nonstrict mode
Browse files Browse the repository at this point in the history
optionally allow certian reader errors.
needed for perl YAML validation tests.
See ingydotnet/yaml-libyaml-pm#44
  • Loading branch information
Reini Urban committed Mar 9, 2016
1 parent bcb24a9 commit 658fee0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event)
/* No events after the end of the stream or error. */

if (parser->stream_end_produced ||
parser->error ||
parser->state == YAML_PARSE_END_STATE) {
(parser->error &&
/* continue in nonstrict and READER_ERROR */
(!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)) ||
parser->state == YAML_PARSE_END_STATE) {
return 1;
}

Expand Down
4 changes: 3 additions & 1 deletion src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,9 @@ yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
/* No tokens after STREAM-END or error. */

if (parser->stream_end_produced
|| parser->error)
|| (parser->error
/* continue in nonstrict and READER_ERROR */
&& (!parser->problem_nonstrict || parser->error != YAML_READER_ERROR)))
return 1;

/* Ensure that the tokens queue contains enough tokens. */
Expand Down

0 comments on commit 658fee0

Please sign in to comment.