mirror of
https://github.com/simonask/libyaml-safer
synced 2024-11-23 11:53:03 +00:00
Factor out WIDTH_AT macro
This commit is contained in:
parent
5305f1811a
commit
440e55a6af
2 changed files with 20 additions and 20 deletions
|
@ -2500,25 +2500,7 @@ unsafe fn yaml_emitter_write_folded_scalar(
|
||||||
{
|
{
|
||||||
let mut k: libc::c_int = 0_i32;
|
let mut k: libc::c_int = 0_i32;
|
||||||
while IS_BREAK_AT!(string, k as isize) {
|
while IS_BREAK_AT!(string, k as isize) {
|
||||||
k += if *string.pointer.wrapping_offset(k as isize) as libc::c_int & 0x80_i32
|
k += WIDTH_AT!(string, k as isize);
|
||||||
== 0_i32
|
|
||||||
{
|
|
||||||
1_i32
|
|
||||||
} else if *string.pointer.wrapping_offset(k as isize) as libc::c_int & 0xe0_i32
|
|
||||||
== 0xc0_i32
|
|
||||||
{
|
|
||||||
2_i32
|
|
||||||
} else if *string.pointer.wrapping_offset(k as isize) as libc::c_int & 0xf0_i32
|
|
||||||
== 0xe0_i32
|
|
||||||
{
|
|
||||||
3_i32
|
|
||||||
} else if *string.pointer.wrapping_offset(k as isize) as libc::c_int & 0xf8_i32
|
|
||||||
== 0xf0_i32
|
|
||||||
{
|
|
||||||
4_i32
|
|
||||||
} else {
|
|
||||||
0_i32
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if !IS_BLANKZ_AT!(string, k) {
|
if !IS_BLANKZ_AT!(string, k) {
|
||||||
if !(PUT_BREAK!(emitter)) {
|
if !(PUT_BREAK!(emitter)) {
|
||||||
|
|
|
@ -351,7 +351,25 @@ macro_rules! IS_BLANKZ {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! WIDTH_AT {
|
macro_rules! WIDTH_AT {
|
||||||
() => {}; // TODO
|
($string:expr, $offset:expr) => {
|
||||||
|
if *$string.pointer.wrapping_offset($offset as isize) as libc::c_int & 0x80_i32 == 0_i32 {
|
||||||
|
1_i32
|
||||||
|
} else if *$string.pointer.wrapping_offset($offset as isize) as libc::c_int & 0xe0_i32
|
||||||
|
== 0xc0_i32
|
||||||
|
{
|
||||||
|
2_i32
|
||||||
|
} else if *$string.pointer.wrapping_offset($offset as isize) as libc::c_int & 0xf0_i32
|
||||||
|
== 0xe0_i32
|
||||||
|
{
|
||||||
|
3_i32
|
||||||
|
} else if *$string.pointer.wrapping_offset($offset as isize) as libc::c_int & 0xf8_i32
|
||||||
|
== 0xf0_i32
|
||||||
|
{
|
||||||
|
4_i32
|
||||||
|
} else {
|
||||||
|
0_i32
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! WIDTH {
|
macro_rules! WIDTH {
|
||||||
|
|
Loading…
Reference in a new issue