Change yaml_mark_t.index to count bytes not codepoints

This commit is contained in:
David Tolnay 2022-07-23 00:55:40 -07:00
parent c7752de455
commit a59ca716e8
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -29,13 +29,11 @@ unsafe fn CACHE(parser: *mut yaml_parser_t, length: size_t) -> i32 {
}
unsafe fn SKIP(parser: *mut yaml_parser_t) {
(*parser).mark.index = (*parser).mark.index.wrapping_add(1);
let width = WIDTH!((*parser).buffer);
(*parser).mark.index = (*parser).mark.index.wrapping_add(width as u64);
(*parser).mark.column = (*parser).mark.column.wrapping_add(1);
(*parser).unread = (*parser).unread.wrapping_sub(1);
(*parser).buffer.pointer = (*parser)
.buffer
.pointer
.wrapping_offset(WIDTH!((*parser).buffer) as isize);
(*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(width as isize);
}
unsafe fn SKIP_LINE(parser: *mut yaml_parser_t) {
@ -46,21 +44,20 @@ unsafe fn SKIP_LINE(parser: *mut yaml_parser_t) {
(*parser).unread = (*parser).unread.wrapping_sub(2);
(*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(2);
} else if IS_BREAK!((*parser).buffer) {
(*parser).mark.index = (*parser).mark.index.wrapping_add(1);
let width = WIDTH!((*parser).buffer);
(*parser).mark.index = (*parser).mark.index.wrapping_add(width as u64);
(*parser).mark.column = 0;
(*parser).mark.line = (*parser).mark.line.wrapping_add(1);
(*parser).unread = (*parser).unread.wrapping_sub(1);
(*parser).buffer.pointer = (*parser)
.buffer
.pointer
.wrapping_offset(WIDTH!((*parser).buffer) as isize);
(*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(width as isize);
};
}
unsafe fn READ(parser: *mut yaml_parser_t, string: *mut yaml_string_t) -> i32 {
if STRING_EXTEND!(parser, *string) != 0 {
let width = WIDTH!((*parser).buffer);
COPY!(*string, (*parser).buffer);
(*parser).mark.index = (*parser).mark.index.wrapping_add(1);
(*parser).mark.index = (*parser).mark.index.wrapping_add(width as u64);
(*parser).mark.column = (*parser).mark.column.wrapping_add(1);
(*parser).unread = (*parser).unread.wrapping_sub(1);
1_i32
@ -92,7 +89,7 @@ unsafe fn READ_LINE(parser: *mut yaml_parser_t, string: *mut yaml_string_t) -> i
*(*string).pointer = b'\n';
(*string).pointer = (*string).pointer.wrapping_offset(1);
(*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(2);
(*parser).mark.index = (*parser).mark.index.wrapping_add(1);
(*parser).mark.index = (*parser).mark.index.wrapping_add(2);
(*parser).mark.column = 0;
(*parser).mark.line = (*parser).mark.line.wrapping_add(1);
(*parser).unread = (*parser).unread.wrapping_sub(1);
@ -109,7 +106,7 @@ unsafe fn READ_LINE(parser: *mut yaml_parser_t, string: *mut yaml_string_t) -> i
*(*string).pointer = *(*parser).buffer.pointer;
(*string).pointer = (*string).pointer.wrapping_offset(1);
(*parser).buffer.pointer = (*parser).buffer.pointer.wrapping_offset(1);
(*parser).mark.index = (*parser).mark.index.wrapping_add(1);
(*parser).mark.index = (*parser).mark.index.wrapping_add(3);
(*parser).mark.column = 0;
(*parser).mark.line = (*parser).mark.line.wrapping_add(1);
(*parser).unread = (*parser).unread.wrapping_sub(1);