mirror of
https://github.com/simonask/libyaml-safer
synced 2024-11-22 19:33:03 +00:00
Use Rust strings for errors
This commit is contained in:
parent
f26c0c28ae
commit
e3421d5371
5 changed files with 131 additions and 188 deletions
|
@ -76,26 +76,26 @@ pub unsafe fn yaml_parser_load(
|
|||
|
||||
unsafe fn yaml_parser_set_composer_error(
|
||||
parser: &mut yaml_parser_t,
|
||||
problem: *const libc::c_char,
|
||||
problem: &'static str,
|
||||
problem_mark: yaml_mark_t,
|
||||
) -> Result<(), ()> {
|
||||
parser.error = YAML_COMPOSER_ERROR;
|
||||
parser.problem = problem;
|
||||
parser.problem = Some(problem);
|
||||
parser.problem_mark = problem_mark;
|
||||
Err(())
|
||||
}
|
||||
|
||||
unsafe fn yaml_parser_set_composer_error_context(
|
||||
parser: &mut yaml_parser_t,
|
||||
context: *const libc::c_char,
|
||||
context: &'static str,
|
||||
context_mark: yaml_mark_t,
|
||||
problem: *const libc::c_char,
|
||||
problem: &'static str,
|
||||
problem_mark: yaml_mark_t,
|
||||
) -> Result<(), ()> {
|
||||
parser.error = YAML_COMPOSER_ERROR;
|
||||
parser.context = context;
|
||||
parser.context = Some(context);
|
||||
parser.context_mark = context_mark;
|
||||
parser.problem = problem;
|
||||
parser.problem = Some(problem);
|
||||
parser.problem_mark = problem_mark;
|
||||
Err(())
|
||||
}
|
||||
|
@ -199,9 +199,9 @@ unsafe fn yaml_parser_register_anchor(
|
|||
yaml_free(anchor as *mut libc::c_void);
|
||||
return yaml_parser_set_composer_error_context(
|
||||
parser,
|
||||
b"found duplicate anchor; first occurrence\0" as *const u8 as *const libc::c_char,
|
||||
"found duplicate anchor; first occurrence",
|
||||
(*alias_data).mark,
|
||||
b"second occurrence\0" as *const u8 as *const libc::c_char,
|
||||
"second occurrence",
|
||||
(*data).mark,
|
||||
);
|
||||
}
|
||||
|
@ -281,11 +281,7 @@ unsafe fn yaml_parser_load_alias(
|
|||
alias_data = alias_data.wrapping_offset(1);
|
||||
}
|
||||
yaml_free(anchor as *mut libc::c_void);
|
||||
yaml_parser_set_composer_error(
|
||||
parser,
|
||||
b"found undefined alias\0" as *const u8 as *const libc::c_char,
|
||||
(*event).start_mark,
|
||||
)
|
||||
yaml_parser_set_composer_error(parser, "found undefined alias", (*event).start_mark)
|
||||
}
|
||||
|
||||
unsafe fn yaml_parser_load_scalar(
|
||||
|
|
|
@ -76,25 +76,25 @@ pub unsafe fn yaml_parser_parse(
|
|||
|
||||
unsafe fn yaml_parser_set_parser_error(
|
||||
parser: &mut yaml_parser_t,
|
||||
problem: *const libc::c_char,
|
||||
problem: &'static str,
|
||||
problem_mark: yaml_mark_t,
|
||||
) {
|
||||
parser.error = YAML_PARSER_ERROR;
|
||||
parser.problem = problem;
|
||||
parser.problem = Some(problem);
|
||||
parser.problem_mark = problem_mark;
|
||||
}
|
||||
|
||||
unsafe fn yaml_parser_set_parser_error_context(
|
||||
parser: &mut yaml_parser_t,
|
||||
context: *const libc::c_char,
|
||||
context: &'static str,
|
||||
context_mark: yaml_mark_t,
|
||||
problem: *const libc::c_char,
|
||||
problem: &'static str,
|
||||
problem_mark: yaml_mark_t,
|
||||
) {
|
||||
parser.error = YAML_PARSER_ERROR;
|
||||
parser.context = context;
|
||||
parser.context = Some(context);
|
||||
parser.context_mark = context_mark;
|
||||
parser.problem = problem;
|
||||
parser.problem = Some(problem);
|
||||
parser.problem_mark = problem_mark;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ unsafe fn yaml_parser_parse_stream_start(
|
|||
if (*token).type_ != YAML_STREAM_START_TOKEN {
|
||||
yaml_parser_set_parser_error(
|
||||
parser,
|
||||
b"did not find expected <stream-start>\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected <stream-start>",
|
||||
(*token).start_mark,
|
||||
);
|
||||
return Err(());
|
||||
|
@ -256,7 +256,7 @@ unsafe fn yaml_parser_parse_document_start(
|
|||
if (*token).type_ != YAML_DOCUMENT_START_TOKEN {
|
||||
yaml_parser_set_parser_error(
|
||||
parser,
|
||||
b"did not find expected <document start>\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected <document start>",
|
||||
(*token).start_mark,
|
||||
);
|
||||
} else {
|
||||
|
@ -484,9 +484,9 @@ unsafe fn yaml_parser_parse_node(
|
|||
if tag.is_null() {
|
||||
yaml_parser_set_parser_error_context(
|
||||
parser,
|
||||
b"while parsing a node\0" as *const u8 as *const libc::c_char,
|
||||
"while parsing a node",
|
||||
start_mark,
|
||||
b"found undefined tag handle\0" as *const u8 as *const libc::c_char,
|
||||
"found undefined tag handle",
|
||||
tag_mark,
|
||||
);
|
||||
current_block = 17786380918591080555;
|
||||
|
@ -609,12 +609,12 @@ unsafe fn yaml_parser_parse_node(
|
|||
yaml_parser_set_parser_error_context(
|
||||
parser,
|
||||
if block {
|
||||
b"while parsing a block node\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a block node"
|
||||
} else {
|
||||
b"while parsing a flow node\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a flow node"
|
||||
},
|
||||
start_mark,
|
||||
b"did not find expected node content\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected node content",
|
||||
(*token).start_mark,
|
||||
);
|
||||
}
|
||||
|
@ -670,9 +670,9 @@ unsafe fn yaml_parser_parse_block_sequence_entry(
|
|||
let mark = POP!(parser.marks);
|
||||
yaml_parser_set_parser_error_context(
|
||||
parser,
|
||||
b"while parsing a block collection\0" as *const u8 as *const libc::c_char,
|
||||
"while parsing a block collection",
|
||||
mark,
|
||||
b"did not find expected '-' indicator\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected '-' indicator",
|
||||
(*token).start_mark,
|
||||
);
|
||||
Err(())
|
||||
|
@ -761,9 +761,9 @@ unsafe fn yaml_parser_parse_block_mapping_key(
|
|||
let mark = POP!(parser.marks);
|
||||
yaml_parser_set_parser_error_context(
|
||||
parser,
|
||||
b"while parsing a block mapping\0" as *const u8 as *const libc::c_char,
|
||||
"while parsing a block mapping",
|
||||
mark,
|
||||
b"did not find expected key\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected key",
|
||||
(*token).start_mark,
|
||||
);
|
||||
Err(())
|
||||
|
@ -829,9 +829,9 @@ unsafe fn yaml_parser_parse_flow_sequence_entry(
|
|||
let mark = POP!(parser.marks);
|
||||
yaml_parser_set_parser_error_context(
|
||||
parser,
|
||||
b"while parsing a flow sequence\0" as *const u8 as *const libc::c_char,
|
||||
"while parsing a flow sequence",
|
||||
mark,
|
||||
b"did not find expected ',' or ']'\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected ',' or ']'",
|
||||
(*token).start_mark,
|
||||
);
|
||||
return Err(());
|
||||
|
@ -960,9 +960,9 @@ unsafe fn yaml_parser_parse_flow_mapping_key(
|
|||
let mark = POP!(parser.marks);
|
||||
yaml_parser_set_parser_error_context(
|
||||
parser,
|
||||
b"while parsing a flow mapping\0" as *const u8 as *const libc::c_char,
|
||||
"while parsing a flow mapping",
|
||||
mark,
|
||||
b"did not find expected ',' or '}'\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected ',' or '}'",
|
||||
(*token).start_mark,
|
||||
);
|
||||
return Err(());
|
||||
|
@ -1098,7 +1098,7 @@ unsafe fn yaml_parser_process_directives(
|
|||
if !version_directive.is_null() {
|
||||
yaml_parser_set_parser_error(
|
||||
parser,
|
||||
b"found duplicate %YAML directive\0" as *const u8 as *const libc::c_char,
|
||||
"found duplicate %YAML directive",
|
||||
(*token).start_mark,
|
||||
);
|
||||
current_block = 17143798186130252483;
|
||||
|
@ -1109,7 +1109,7 @@ unsafe fn yaml_parser_process_directives(
|
|||
{
|
||||
yaml_parser_set_parser_error(
|
||||
parser,
|
||||
b"found incompatible YAML document\0" as *const u8 as *const libc::c_char,
|
||||
"found incompatible YAML document",
|
||||
(*token).start_mark,
|
||||
);
|
||||
current_block = 17143798186130252483;
|
||||
|
@ -1213,11 +1213,7 @@ unsafe fn yaml_parser_append_tag_directive(
|
|||
if allow_duplicates {
|
||||
return Ok(());
|
||||
}
|
||||
yaml_parser_set_parser_error(
|
||||
parser,
|
||||
b"found duplicate %TAG directive\0" as *const u8 as *const libc::c_char,
|
||||
mark,
|
||||
);
|
||||
yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark);
|
||||
return Err(());
|
||||
}
|
||||
tag_directive = tag_directive.wrapping_offset(1);
|
||||
|
|
|
@ -9,12 +9,12 @@ use core::ptr::addr_of_mut;
|
|||
|
||||
unsafe fn yaml_parser_set_reader_error(
|
||||
parser: &mut yaml_parser_t,
|
||||
problem: *const libc::c_char,
|
||||
problem: &'static str,
|
||||
offset: size_t,
|
||||
value: libc::c_int,
|
||||
) -> Result<(), ()> {
|
||||
parser.error = YAML_READER_ERROR;
|
||||
parser.problem = problem;
|
||||
parser.problem = Some(problem);
|
||||
parser.problem_offset = offset;
|
||||
parser.problem_value = value;
|
||||
Err(())
|
||||
|
@ -119,12 +119,7 @@ unsafe fn yaml_parser_update_raw_buffer(parser: &mut yaml_parser_t) -> Result<()
|
|||
addr_of_mut!(size_read),
|
||||
) == 0
|
||||
{
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"input error\0" as *const u8 as *const libc::c_char,
|
||||
parser.offset,
|
||||
-1,
|
||||
);
|
||||
return yaml_parser_set_reader_error(parser, "input error", parser.offset, -1);
|
||||
}
|
||||
parser.raw_buffer.last = parser.raw_buffer.last.wrapping_offset(size_read as isize);
|
||||
if size_read == 0 {
|
||||
|
@ -197,7 +192,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
if width == 0 {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"invalid leading UTF-8 octet\0" as *const u8 as *const libc::c_char,
|
||||
"invalid leading UTF-8 octet",
|
||||
parser.offset,
|
||||
octet as libc::c_int,
|
||||
);
|
||||
|
@ -206,8 +201,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
if parser.eof {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"incomplete UTF-8 octet sequence\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"incomplete UTF-8 octet sequence",
|
||||
parser.offset,
|
||||
-1,
|
||||
);
|
||||
|
@ -231,8 +225,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
if octet & 0xC0 != 0x80 {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"invalid trailing UTF-8 octet\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"invalid trailing UTF-8 octet",
|
||||
parser.offset.force_add(k),
|
||||
octet as libc::c_int,
|
||||
);
|
||||
|
@ -247,8 +240,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
{
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"invalid length of a UTF-8 sequence\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"invalid length of a UTF-8 sequence",
|
||||
parser.offset,
|
||||
-1,
|
||||
);
|
||||
|
@ -256,7 +248,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"invalid Unicode character\0" as *const u8 as *const libc::c_char,
|
||||
"invalid Unicode character",
|
||||
parser.offset,
|
||||
value as libc::c_int,
|
||||
);
|
||||
|
@ -278,8 +270,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
if parser.eof {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"incomplete UTF-16 character\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"incomplete UTF-16 character",
|
||||
parser.offset,
|
||||
-1,
|
||||
);
|
||||
|
@ -294,8 +285,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
if value & 0xFC00 == 0xDC00 {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"unexpected low surrogate area\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"unexpected low surrogate area",
|
||||
parser.offset,
|
||||
value as libc::c_int,
|
||||
);
|
||||
|
@ -306,8 +296,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
if parser.eof {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"incomplete UTF-16 surrogate pair\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"incomplete UTF-16 surrogate pair",
|
||||
parser.offset,
|
||||
-1,
|
||||
);
|
||||
|
@ -329,8 +318,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
if value2 & 0xFC00 != 0xDC00 {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"expected low surrogate area\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"expected low surrogate area",
|
||||
parser.offset.force_add(2_u64),
|
||||
value2 as libc::c_int,
|
||||
);
|
||||
|
@ -360,7 +348,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
{
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"control characters are not allowed\0" as *const u8 as *const libc::c_char,
|
||||
"control characters are not allowed",
|
||||
parser.offset,
|
||||
value as libc::c_int,
|
||||
);
|
||||
|
@ -415,12 +403,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
|
|||
}
|
||||
}
|
||||
if parser.offset >= (!0_u64).wrapping_div(2_u64) {
|
||||
return yaml_parser_set_reader_error(
|
||||
parser,
|
||||
b"input is too long\0" as *const u8 as *const libc::c_char,
|
||||
parser.offset,
|
||||
-1,
|
||||
);
|
||||
return yaml_parser_set_reader_error(parser, "input is too long", parser.offset, -1);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
196
src/scanner.rs
196
src/scanner.rs
|
@ -145,14 +145,14 @@ pub unsafe fn yaml_parser_scan(
|
|||
|
||||
unsafe fn yaml_parser_set_scanner_error(
|
||||
parser: &mut yaml_parser_t,
|
||||
context: *const libc::c_char,
|
||||
context: &'static str,
|
||||
context_mark: yaml_mark_t,
|
||||
problem: *const libc::c_char,
|
||||
problem: &'static str,
|
||||
) {
|
||||
parser.error = YAML_SCANNER_ERROR;
|
||||
parser.context = context;
|
||||
parser.context = Some(context);
|
||||
parser.context_mark = context_mark;
|
||||
parser.problem = problem;
|
||||
parser.problem = Some(problem);
|
||||
parser.problem_mark = parser.mark;
|
||||
}
|
||||
|
||||
|
@ -302,9 +302,9 @@ unsafe fn yaml_parser_fetch_next_token(parser: &mut yaml_parser_t) -> Result<(),
|
|||
}
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning for the next token\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning for the next token",
|
||||
parser.mark,
|
||||
b"found character that cannot start any token\0" as *const u8 as *const libc::c_char,
|
||||
"found character that cannot start any token",
|
||||
);
|
||||
Err(())
|
||||
}
|
||||
|
@ -320,9 +320,9 @@ unsafe fn yaml_parser_stale_simple_keys(parser: &mut yaml_parser_t) -> Result<()
|
|||
if (*simple_key).required {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a simple key\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a simple key",
|
||||
(*simple_key).mark,
|
||||
b"could not find expected ':'\0" as *const u8 as *const libc::c_char,
|
||||
"could not find expected ':'",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -359,9 +359,9 @@ unsafe fn yaml_parser_remove_simple_key(parser: &mut yaml_parser_t) -> Result<()
|
|||
if (*simple_key).required {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a simple key\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a simple key",
|
||||
(*simple_key).mark,
|
||||
b"could not find expected ':'\0" as *const u8 as *const libc::c_char,
|
||||
"could not find expected ':'",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -601,10 +601,9 @@ unsafe fn yaml_parser_fetch_block_entry(parser: &mut yaml_parser_t) -> Result<()
|
|||
if !parser.simple_key_allowed {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
ptr::null::<libc::c_char>(),
|
||||
"",
|
||||
parser.mark,
|
||||
b"block sequence entries are not allowed in this context\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"block sequence entries are not allowed in this context",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -642,10 +641,9 @@ unsafe fn yaml_parser_fetch_key(parser: &mut yaml_parser_t) -> Result<(), ()> {
|
|||
if !parser.simple_key_allowed {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
ptr::null::<libc::c_char>(),
|
||||
"",
|
||||
parser.mark,
|
||||
b"mapping keys are not allowed in this context\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"mapping keys are not allowed in this context",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -706,10 +704,9 @@ unsafe fn yaml_parser_fetch_value(parser: &mut yaml_parser_t) -> Result<(), ()>
|
|||
if !parser.simple_key_allowed {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
ptr::null::<libc::c_char>(),
|
||||
"",
|
||||
parser.mark,
|
||||
b"mapping values are not allowed in this context\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"mapping values are not allowed in this context",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -842,11 +839,7 @@ unsafe fn yaml_parser_scan_directive(
|
|||
let start_mark: yaml_mark_t = parser.mark;
|
||||
SKIP(parser);
|
||||
if let Ok(()) = yaml_parser_scan_directive_name(parser, start_mark, addr_of_mut!(name)) {
|
||||
if strcmp(
|
||||
name as *mut libc::c_char,
|
||||
b"YAML\0" as *const u8 as *const libc::c_char,
|
||||
) == 0
|
||||
{
|
||||
if strcmp(name as *mut libc::c_char, b"YAML\0".as_ptr() as _) == 0 {
|
||||
if let Err(()) = yaml_parser_scan_version_directive_value(
|
||||
parser,
|
||||
start_mark,
|
||||
|
@ -864,11 +857,7 @@ unsafe fn yaml_parser_scan_directive(
|
|||
(*token).data.version_directive.minor = minor;
|
||||
current_block = 17407779659766490442;
|
||||
}
|
||||
} else if strcmp(
|
||||
name as *mut libc::c_char,
|
||||
b"TAG\0" as *const u8 as *const libc::c_char,
|
||||
) == 0
|
||||
{
|
||||
} else if strcmp(name as *mut libc::c_char, b"TAG\0".as_ptr() as _) == 0 {
|
||||
if let Err(()) = yaml_parser_scan_tag_directive_value(
|
||||
parser,
|
||||
start_mark,
|
||||
|
@ -889,9 +878,9 @@ unsafe fn yaml_parser_scan_directive(
|
|||
} else {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a directive\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a directive",
|
||||
start_mark,
|
||||
b"found unknown directive name\0" as *const u8 as *const libc::c_char,
|
||||
"found unknown directive name",
|
||||
);
|
||||
current_block = 11397968426844348457;
|
||||
}
|
||||
|
@ -928,10 +917,9 @@ unsafe fn yaml_parser_scan_directive(
|
|||
if !IS_BREAKZ!(parser.buffer) {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a directive\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a directive",
|
||||
start_mark,
|
||||
b"did not find expected comment or line break\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"did not find expected comment or line break",
|
||||
);
|
||||
} else {
|
||||
if IS_BREAK!(parser.buffer) {
|
||||
|
@ -984,17 +972,16 @@ unsafe fn yaml_parser_scan_directive_name(
|
|||
if string.start == string.pointer {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a directive\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a directive",
|
||||
start_mark,
|
||||
b"could not find expected directive name\0" as *const u8 as *const libc::c_char,
|
||||
"could not find expected directive name",
|
||||
);
|
||||
} else if !IS_BLANKZ!(parser.buffer) {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a directive\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a directive",
|
||||
start_mark,
|
||||
b"found unexpected non-alphabetical character\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"found unexpected non-alphabetical character",
|
||||
);
|
||||
} else {
|
||||
*name = string.start;
|
||||
|
@ -1021,9 +1008,9 @@ unsafe fn yaml_parser_scan_version_directive_value(
|
|||
if !CHECK!(parser.buffer, b'.') {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a %YAML directive\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a %YAML directive",
|
||||
start_mark,
|
||||
b"did not find expected digit or '.' character\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected digit or '.' character",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -1046,9 +1033,9 @@ unsafe fn yaml_parser_scan_version_directive_number(
|
|||
if length > MAX_NUMBER_LENGTH {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a %YAML directive\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a %YAML directive",
|
||||
start_mark,
|
||||
b"found extremely long version number\0" as *const u8 as *const libc::c_char,
|
||||
"found extremely long version number",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -1059,9 +1046,9 @@ unsafe fn yaml_parser_scan_version_directive_number(
|
|||
if length == 0 {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a %YAML directive\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a %YAML directive",
|
||||
start_mark,
|
||||
b"did not find expected version number\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected version number",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -1115,11 +1102,9 @@ unsafe fn yaml_parser_scan_tag_directive_value(
|
|||
if !IS_BLANK!(parser.buffer) {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a %TAG directive\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"while scanning a %TAG directive",
|
||||
start_mark,
|
||||
b"did not find expected whitespace\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"did not find expected whitespace",
|
||||
);
|
||||
current_block = 5231181710497607163;
|
||||
} else {
|
||||
|
@ -1148,11 +1133,9 @@ unsafe fn yaml_parser_scan_tag_directive_value(
|
|||
if !IS_BLANKZ!(parser.buffer) {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a %TAG directive\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"while scanning a %TAG directive",
|
||||
start_mark,
|
||||
b"did not find expected whitespace or line break\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"did not find expected whitespace or line break",
|
||||
);
|
||||
current_block = 5231181710497607163;
|
||||
} else {
|
||||
|
@ -1208,13 +1191,12 @@ unsafe fn yaml_parser_scan_anchor(
|
|||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
if type_ == YAML_ANCHOR_TOKEN {
|
||||
b"while scanning an anchor\0" as *const u8 as *const libc::c_char
|
||||
"while scanning an anchor"
|
||||
} else {
|
||||
b"while scanning an alias\0" as *const u8 as *const libc::c_char
|
||||
"while scanning an alias"
|
||||
},
|
||||
start_mark,
|
||||
b"did not find expected alphabetic or numeric character\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"did not find expected alphabetic or numeric character",
|
||||
);
|
||||
} else {
|
||||
if type_ == YAML_ANCHOR_TOKEN {
|
||||
|
@ -1265,9 +1247,9 @@ unsafe fn yaml_parser_scan_tag(
|
|||
} else if !CHECK!(parser.buffer, b'>') {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a tag\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a tag",
|
||||
start_mark,
|
||||
b"did not find the expected '>'\0" as *const u8 as *const libc::c_char,
|
||||
"did not find the expected '>'",
|
||||
);
|
||||
current_block = 17708497480799081542;
|
||||
} else {
|
||||
|
@ -1325,10 +1307,9 @@ unsafe fn yaml_parser_scan_tag(
|
|||
if parser.flow_level == 0 || !CHECK!(parser.buffer, b',') {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a tag\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a tag",
|
||||
start_mark,
|
||||
b"did not find expected whitespace or line break\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"did not find expected whitespace or line break",
|
||||
);
|
||||
current_block = 17708497480799081542;
|
||||
} else {
|
||||
|
@ -1369,12 +1350,12 @@ unsafe fn yaml_parser_scan_tag_handle(
|
|||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
if directive {
|
||||
b"while scanning a tag directive\0" as *const u8 as *const libc::c_char
|
||||
"while scanning a tag directive"
|
||||
} else {
|
||||
b"while scanning a tag\0" as *const u8 as *const libc::c_char
|
||||
"while scanning a tag"
|
||||
},
|
||||
start_mark,
|
||||
b"did not find expected '!'\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected '!'",
|
||||
);
|
||||
} else {
|
||||
READ(parser, &mut string);
|
||||
|
@ -1400,9 +1381,9 @@ unsafe fn yaml_parser_scan_tag_handle(
|
|||
{
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while parsing a tag directive\0" as *const u8 as *const libc::c_char,
|
||||
"while parsing a tag directive",
|
||||
start_mark,
|
||||
b"did not find expected '!'\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected '!'",
|
||||
);
|
||||
current_block = 1771849829115608806;
|
||||
} else {
|
||||
|
@ -1515,13 +1496,12 @@ unsafe fn yaml_parser_scan_tag_uri(
|
|||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
if directive {
|
||||
b"while parsing a %TAG directive\0" as *const u8
|
||||
as *const libc::c_char
|
||||
"while parsing a %TAG directive"
|
||||
} else {
|
||||
b"while parsing a tag\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a tag"
|
||||
},
|
||||
start_mark,
|
||||
b"did not find expected tag URI\0" as *const u8 as *const libc::c_char,
|
||||
"did not find expected tag URI",
|
||||
);
|
||||
current_block = 15265153392498847348;
|
||||
} else {
|
||||
|
@ -1550,12 +1530,12 @@ unsafe fn yaml_parser_scan_uri_escapes(
|
|||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
if directive {
|
||||
b"while parsing a %TAG directive\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a %TAG directive"
|
||||
} else {
|
||||
b"while parsing a tag\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a tag"
|
||||
},
|
||||
start_mark,
|
||||
b"did not find URI escaped octet\0" as *const u8 as *const libc::c_char,
|
||||
"did not find URI escaped octet",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -1577,12 +1557,12 @@ unsafe fn yaml_parser_scan_uri_escapes(
|
|||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
if directive {
|
||||
b"while parsing a %TAG directive\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a %TAG directive"
|
||||
} else {
|
||||
b"while parsing a tag\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a tag"
|
||||
},
|
||||
start_mark,
|
||||
b"found an incorrect leading UTF-8 octet\0" as *const u8 as *const libc::c_char,
|
||||
"found an incorrect leading UTF-8 octet",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -1590,12 +1570,12 @@ unsafe fn yaml_parser_scan_uri_escapes(
|
|||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
if directive {
|
||||
b"while parsing a %TAG directive\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a %TAG directive"
|
||||
} else {
|
||||
b"while parsing a tag\0" as *const u8 as *const libc::c_char
|
||||
"while parsing a tag"
|
||||
},
|
||||
start_mark,
|
||||
b"found an incorrect trailing UTF-8 octet\0" as *const u8 as *const libc::c_char,
|
||||
"found an incorrect trailing UTF-8 octet",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -1643,10 +1623,9 @@ unsafe fn yaml_parser_scan_block_scalar(
|
|||
if CHECK!(parser.buffer, b'0') {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a block scalar\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a block scalar",
|
||||
start_mark,
|
||||
b"found an indentation indicator equal to 0\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"found an indentation indicator equal to 0",
|
||||
);
|
||||
current_block = 14984465786483313892;
|
||||
} else {
|
||||
|
@ -1661,10 +1640,9 @@ unsafe fn yaml_parser_scan_block_scalar(
|
|||
if CHECK!(parser.buffer, b'0') {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a block scalar\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a block scalar",
|
||||
start_mark,
|
||||
b"found an indentation indicator equal to 0\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"found an indentation indicator equal to 0",
|
||||
);
|
||||
current_block = 14984465786483313892;
|
||||
} else {
|
||||
|
@ -1716,11 +1694,9 @@ unsafe fn yaml_parser_scan_block_scalar(
|
|||
if !IS_BREAKZ!(parser.buffer) {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a block scalar\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"while scanning a block scalar",
|
||||
start_mark,
|
||||
b"did not find expected comment or line break\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"did not find expected comment or line break",
|
||||
);
|
||||
} else {
|
||||
if IS_BREAK!(parser.buffer) {
|
||||
|
@ -1870,10 +1846,9 @@ unsafe fn yaml_parser_scan_block_scalar_breaks(
|
|||
{
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a block scalar\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a block scalar",
|
||||
start_mark,
|
||||
b"found a tab character where an indentation space is expected\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"found a tab character where an indentation space is expected",
|
||||
);
|
||||
return Err(());
|
||||
}
|
||||
|
@ -1930,18 +1905,18 @@ unsafe fn yaml_parser_scan_flow_scalar(
|
|||
{
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a quoted scalar\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a quoted scalar",
|
||||
start_mark,
|
||||
b"found unexpected document indicator\0" as *const u8 as *const libc::c_char,
|
||||
"found unexpected document indicator",
|
||||
);
|
||||
current_block = 8114179180390253173;
|
||||
break;
|
||||
} else if IS_Z!(parser.buffer) {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a quoted scalar\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a quoted scalar",
|
||||
start_mark,
|
||||
b"found unexpected end of stream\0" as *const u8 as *const libc::c_char,
|
||||
"found unexpected end of stream",
|
||||
);
|
||||
current_block = 8114179180390253173;
|
||||
break;
|
||||
|
@ -2098,11 +2073,9 @@ unsafe fn yaml_parser_scan_flow_scalar(
|
|||
_ => {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while parsing a quoted scalar\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"while parsing a quoted scalar",
|
||||
start_mark,
|
||||
b"found unknown escape character\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"found unknown escape character",
|
||||
);
|
||||
current_block = 8114179180390253173;
|
||||
break 's_58;
|
||||
|
@ -2122,11 +2095,9 @@ unsafe fn yaml_parser_scan_flow_scalar(
|
|||
if !IS_HEX_AT!(parser.buffer, k as isize) {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while parsing a quoted scalar\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"while parsing a quoted scalar",
|
||||
start_mark,
|
||||
b"did not find expected hexdecimal number\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"did not find expected hexdecimal number",
|
||||
);
|
||||
current_block = 8114179180390253173;
|
||||
break 's_58;
|
||||
|
@ -2141,11 +2112,9 @@ unsafe fn yaml_parser_scan_flow_scalar(
|
|||
if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF {
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while parsing a quoted scalar\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"while parsing a quoted scalar",
|
||||
start_mark,
|
||||
b"found invalid Unicode character escape code\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"found invalid Unicode character escape code",
|
||||
);
|
||||
current_block = 8114179180390253173;
|
||||
break 's_58;
|
||||
|
@ -2342,9 +2311,9 @@ unsafe fn yaml_parser_scan_plain_scalar(
|
|||
{
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a plain scalar\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a plain scalar",
|
||||
start_mark,
|
||||
b"found unexpected ':'\0" as *const u8 as *const libc::c_char,
|
||||
"found unexpected ':'",
|
||||
);
|
||||
current_block = 16642808987012640029;
|
||||
break 's_57;
|
||||
|
@ -2408,10 +2377,9 @@ unsafe fn yaml_parser_scan_plain_scalar(
|
|||
{
|
||||
yaml_parser_set_scanner_error(
|
||||
parser,
|
||||
b"while scanning a plain scalar\0" as *const u8 as *const libc::c_char,
|
||||
"while scanning a plain scalar",
|
||||
start_mark,
|
||||
b"found a tab character that violates indentation\0" as *const u8
|
||||
as *const libc::c_char,
|
||||
"found a tab character that violates indentation",
|
||||
);
|
||||
current_block = 16642808987012640029;
|
||||
break 's_57;
|
||||
|
|
|
@ -859,7 +859,7 @@ pub struct yaml_parser_t {
|
|||
#[cfg(doc)]
|
||||
pub problem: *const libc::c_char,
|
||||
#[cfg(not(doc))]
|
||||
pub(crate) problem: *const libc::c_char,
|
||||
pub(crate) problem: Option<&'static str>,
|
||||
/// The byte about which the problem occured.
|
||||
#[cfg(doc)]
|
||||
pub problem_offset: size_t,
|
||||
|
@ -879,7 +879,7 @@ pub struct yaml_parser_t {
|
|||
#[cfg(doc)]
|
||||
pub context: *const libc::c_char,
|
||||
#[cfg(not(doc))]
|
||||
pub(crate) context: *const libc::c_char,
|
||||
pub(crate) context: Option<&'static str>,
|
||||
/// The context position.
|
||||
#[cfg(doc)]
|
||||
pub context_mark: yaml_mark_t,
|
||||
|
|
Loading…
Reference in a new issue