Replace sprintf with rust fmt

This commit is contained in:
David Tolnay 2022-07-03 20:05:55 -07:00
parent f0110f61b4
commit 64531de7a9
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -1,8 +1,9 @@
use crate::externs::__assert_fail; use crate::externs::__assert_fail;
use crate::libc; use crate::libc;
use crate::yaml::*; use crate::yaml::*;
use std::io::Write;
use std::slice;
extern "C" { extern "C" {
fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int;
fn yaml_malloc(size: size_t) -> *mut libc::c_void; fn yaml_malloc(size: size_t) -> *mut libc::c_void;
fn yaml_free(ptr: *mut libc::c_void); fn yaml_free(ptr: *mut libc::c_void);
fn yaml_emitter_emit( fn yaml_emitter_emit(
@ -421,11 +422,8 @@ unsafe extern "C" fn yaml_emitter_generate_anchor(
if anchor.is_null() { if anchor.is_null() {
return 0 as *mut yaml_char_t; return 0 as *mut yaml_char_t;
} }
sprintf( let mut buffer = slice::from_raw_parts_mut(anchor.cast(), 16);
anchor as *mut libc::c_char, let _ = write!(buffer, "id{:03}\0", anchor_id);
b"id%03d\0" as *const u8 as *const libc::c_char,
anchor_id,
);
return anchor; return anchor;
} }
unsafe extern "C" fn yaml_emitter_dump_node( unsafe extern "C" fn yaml_emitter_dump_node(