mirror of
https://github.com/simonask/libyaml-safer
synced 2025-02-16 20:38:30 +00:00
Remove unsafe from some trivially safe functions
This commit is contained in:
parent
2c9973bfae
commit
4a917d95ee
6 changed files with 19 additions and 23 deletions
24
src/api.rs
24
src/api.rs
|
@ -250,7 +250,7 @@ pub unsafe fn yaml_parser_set_input(
|
|||
}
|
||||
|
||||
/// Set the source encoding.
|
||||
pub unsafe fn yaml_parser_set_encoding(parser: &mut yaml_parser_t, encoding: yaml_encoding_t) {
|
||||
pub fn yaml_parser_set_encoding(parser: &mut yaml_parser_t, encoding: yaml_encoding_t) {
|
||||
__assert!(parser.encoding == YAML_ANY_ENCODING);
|
||||
parser.encoding = encoding;
|
||||
}
|
||||
|
@ -370,34 +370,34 @@ pub unsafe fn yaml_emitter_set_output(
|
|||
}
|
||||
|
||||
/// Set the output encoding.
|
||||
pub unsafe fn yaml_emitter_set_encoding(emitter: &mut yaml_emitter_t, encoding: yaml_encoding_t) {
|
||||
pub fn yaml_emitter_set_encoding(emitter: &mut yaml_emitter_t, encoding: yaml_encoding_t) {
|
||||
__assert!(emitter.encoding == YAML_ANY_ENCODING);
|
||||
emitter.encoding = encoding;
|
||||
}
|
||||
|
||||
/// Set if the output should be in the "canonical" format as in the YAML
|
||||
/// specification.
|
||||
pub unsafe fn yaml_emitter_set_canonical(emitter: &mut yaml_emitter_t, canonical: bool) {
|
||||
pub fn yaml_emitter_set_canonical(emitter: &mut yaml_emitter_t, canonical: bool) {
|
||||
emitter.canonical = canonical;
|
||||
}
|
||||
|
||||
/// Set the indentation increment.
|
||||
pub unsafe fn yaml_emitter_set_indent(emitter: &mut yaml_emitter_t, indent: libc::c_int) {
|
||||
pub fn yaml_emitter_set_indent(emitter: &mut yaml_emitter_t, indent: libc::c_int) {
|
||||
emitter.best_indent = if 1 < indent && indent < 10 { indent } else { 2 };
|
||||
}
|
||||
|
||||
/// Set the preferred line width. -1 means unlimited.
|
||||
pub unsafe fn yaml_emitter_set_width(emitter: &mut yaml_emitter_t, width: libc::c_int) {
|
||||
pub fn yaml_emitter_set_width(emitter: &mut yaml_emitter_t, width: libc::c_int) {
|
||||
emitter.best_width = if width >= 0 { width } else { -1 };
|
||||
}
|
||||
|
||||
/// Set if unescaped non-ASCII characters are allowed.
|
||||
pub unsafe fn yaml_emitter_set_unicode(emitter: &mut yaml_emitter_t, unicode: bool) {
|
||||
pub fn yaml_emitter_set_unicode(emitter: &mut yaml_emitter_t, unicode: bool) {
|
||||
emitter.unicode = unicode;
|
||||
}
|
||||
|
||||
/// Set the preferred line break.
|
||||
pub unsafe fn yaml_emitter_set_break(emitter: &mut yaml_emitter_t, line_break: yaml_break_t) {
|
||||
pub fn yaml_emitter_set_break(emitter: &mut yaml_emitter_t, line_break: yaml_break_t) {
|
||||
emitter.line_break = line_break;
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ unsafe fn yaml_check_utf8(start: *const yaml_char_t, length: size_t) -> Result<(
|
|||
}
|
||||
|
||||
/// Create the STREAM-START event.
|
||||
pub unsafe fn yaml_stream_start_event_initialize(
|
||||
pub fn yaml_stream_start_event_initialize(
|
||||
event: &mut yaml_event_t,
|
||||
encoding: yaml_encoding_t,
|
||||
) -> Result<(), ()> {
|
||||
|
@ -496,7 +496,7 @@ pub unsafe fn yaml_stream_start_event_initialize(
|
|||
}
|
||||
|
||||
/// Create the STREAM-END event.
|
||||
pub unsafe fn yaml_stream_end_event_initialize(event: &mut yaml_event_t) -> Result<(), ()> {
|
||||
pub fn yaml_stream_end_event_initialize(event: &mut yaml_event_t) -> Result<(), ()> {
|
||||
*event = yaml_event_t {
|
||||
data: YamlEventData::StreamEnd,
|
||||
..Default::default()
|
||||
|
@ -620,7 +620,7 @@ pub unsafe fn yaml_document_start_event_initialize(
|
|||
///
|
||||
/// The `implicit` argument is considered as a stylistic parameter and may be
|
||||
/// ignored by the emitter.
|
||||
pub unsafe fn yaml_document_end_event_initialize(
|
||||
pub fn yaml_document_end_event_initialize(
|
||||
event: &mut yaml_event_t,
|
||||
implicit: bool,
|
||||
) -> Result<(), ()> {
|
||||
|
@ -814,7 +814,7 @@ pub unsafe fn yaml_sequence_start_event_initialize(
|
|||
}
|
||||
|
||||
/// Create a SEQUENCE-END event.
|
||||
pub unsafe fn yaml_sequence_end_event_initialize(event: &mut yaml_event_t) -> Result<(), ()> {
|
||||
pub fn yaml_sequence_end_event_initialize(event: &mut yaml_event_t) -> Result<(), ()> {
|
||||
*event = yaml_event_t {
|
||||
data: YamlEventData::SequenceEnd,
|
||||
..Default::default()
|
||||
|
@ -891,7 +891,7 @@ pub unsafe fn yaml_mapping_start_event_initialize(
|
|||
}
|
||||
|
||||
/// Create a MAPPING-END event.
|
||||
pub unsafe fn yaml_mapping_end_event_initialize(event: &mut yaml_event_t) -> Result<(), ()> {
|
||||
pub fn yaml_mapping_end_event_initialize(event: &mut yaml_event_t) -> Result<(), ()> {
|
||||
*event = yaml_event_t {
|
||||
data: YamlEventData::MappingEnd,
|
||||
..Default::default()
|
||||
|
|
|
@ -85,7 +85,7 @@ unsafe fn WRITE_BREAK(emitter: &mut yaml_emitter_t, string: &mut yaml_string_t)
|
|||
Ok(())
|
||||
}
|
||||
|
||||
unsafe fn yaml_emitter_set_emitter_error(
|
||||
fn yaml_emitter_set_emitter_error(
|
||||
emitter: &mut yaml_emitter_t,
|
||||
problem: &'static str,
|
||||
) -> Result<(), ()> {
|
||||
|
|
|
@ -210,11 +210,7 @@ mod externs {
|
|||
};
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn __assert_fail(
|
||||
__assertion: &'static str,
|
||||
__file: &'static str,
|
||||
__line: u32,
|
||||
) -> ! {
|
||||
pub(crate) fn __assert_fail(__assertion: &'static str, __file: &'static str, __line: u32) -> ! {
|
||||
struct Abort;
|
||||
impl Drop for Abort {
|
||||
fn drop(&mut self) {
|
||||
|
|
|
@ -74,7 +74,7 @@ pub unsafe fn yaml_parser_load(
|
|||
Err(())
|
||||
}
|
||||
|
||||
unsafe fn yaml_parser_set_composer_error(
|
||||
fn yaml_parser_set_composer_error(
|
||||
parser: &mut yaml_parser_t,
|
||||
problem: &'static str,
|
||||
problem_mark: yaml_mark_t,
|
||||
|
@ -85,7 +85,7 @@ unsafe fn yaml_parser_set_composer_error(
|
|||
Err(())
|
||||
}
|
||||
|
||||
unsafe fn yaml_parser_set_composer_error_context(
|
||||
fn yaml_parser_set_composer_error_context(
|
||||
parser: &mut yaml_parser_t,
|
||||
context: &'static str,
|
||||
context_mark: yaml_mark_t,
|
||||
|
|
|
@ -69,7 +69,7 @@ pub unsafe fn yaml_parser_parse(
|
|||
yaml_parser_state_machine(parser, event)
|
||||
}
|
||||
|
||||
unsafe fn yaml_parser_set_parser_error(
|
||||
fn yaml_parser_set_parser_error(
|
||||
parser: &mut yaml_parser_t,
|
||||
problem: &'static str,
|
||||
problem_mark: yaml_mark_t,
|
||||
|
@ -79,7 +79,7 @@ unsafe fn yaml_parser_set_parser_error(
|
|||
parser.problem_mark = problem_mark;
|
||||
}
|
||||
|
||||
unsafe fn yaml_parser_set_parser_error_context(
|
||||
fn yaml_parser_set_parser_error_context(
|
||||
parser: &mut yaml_parser_t,
|
||||
context: &'static str,
|
||||
context_mark: yaml_mark_t,
|
||||
|
|
|
@ -137,7 +137,7 @@ pub unsafe fn yaml_parser_scan(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
unsafe fn yaml_parser_set_scanner_error(
|
||||
fn yaml_parser_set_scanner_error(
|
||||
parser: &mut yaml_parser_t,
|
||||
context: &'static str,
|
||||
context_mark: yaml_mark_t,
|
||||
|
|
Loading…
Add table
Reference in a new issue