mirror of
https://github.com/simonask/libyaml-safer
synced 2025-02-17 04:48:29 +00:00
Create a macros module
This commit is contained in:
parent
758da1eb9e
commit
7b30e560c9
3 changed files with 26 additions and 24 deletions
|
@ -21,30 +21,6 @@ use crate::{
|
|||
};
|
||||
use core::ptr::{self, addr_of_mut};
|
||||
|
||||
macro_rules! MOVE {
|
||||
($string:expr) => {
|
||||
$string.pointer = $string.pointer.wrapping_offset(
|
||||
(if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0x80_i32 == 0_i32 {
|
||||
1_i32
|
||||
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xe0_i32
|
||||
== 0xc0_i32
|
||||
{
|
||||
2_i32
|
||||
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xf0_i32
|
||||
== 0xe0_i32
|
||||
{
|
||||
3_i32
|
||||
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xf8_i32
|
||||
== 0xf0_i32
|
||||
{
|
||||
4_i32
|
||||
} else {
|
||||
0_i32
|
||||
}) as isize,
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
unsafe fn yaml_emitter_set_emitter_error(
|
||||
mut emitter: *mut yaml_emitter_t,
|
||||
problem: *const libc::c_char,
|
||||
|
|
|
@ -244,6 +244,9 @@ impl<T> PointerExt for *mut T {
|
|||
}
|
||||
}
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
mod api;
|
||||
mod dumper;
|
||||
mod emitter;
|
||||
|
|
23
src/macros.rs
Normal file
23
src/macros.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
macro_rules! MOVE {
|
||||
($string:expr) => {
|
||||
$string.pointer = $string.pointer.wrapping_offset(
|
||||
(if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0x80_i32 == 0_i32 {
|
||||
1_i32
|
||||
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xe0_i32
|
||||
== 0xc0_i32
|
||||
{
|
||||
2_i32
|
||||
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xf0_i32
|
||||
== 0xe0_i32
|
||||
{
|
||||
3_i32
|
||||
} else if *$string.pointer.wrapping_offset(0_isize) as libc::c_int & 0xf8_i32
|
||||
== 0xf0_i32
|
||||
{
|
||||
4_i32
|
||||
} else {
|
||||
0_i32
|
||||
}) as isize,
|
||||
)
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue