mirror of
https://github.com/wez/wezterm.git
synced 2024-11-27 12:23:46 +03:00
Use right char type for ffi binding
On aarch64, `char` is unsigned (unlike x86-64 where it's signed), so use `c_char` for the pointer so that it always matches the architecture.
This commit is contained in:
parent
37a3f7db5f
commit
bf962c8b1a
@ -6,7 +6,7 @@ pub use fontconfig::*;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::os::raw::c_int;
|
||||
use std::os::raw::{c_char, c_int};
|
||||
use std::ptr;
|
||||
use std::sync::Mutex;
|
||||
|
||||
@ -208,7 +208,7 @@ impl Pattern {
|
||||
let s = FcPatternFormat(self.pat, fmt.as_ptr() as *const u8);
|
||||
ensure!(!s.is_null(), "failed to format pattern");
|
||||
|
||||
let res = CStr::from_ptr(s as *const i8)
|
||||
let res = CStr::from_ptr(s as *const c_char)
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
FcStrFree(s);
|
||||
@ -313,7 +313,7 @@ impl Pattern {
|
||||
if !res.succeeded() {
|
||||
Err(res.as_err())
|
||||
} else {
|
||||
Ok(CStr::from_ptr(ptr as *const i8)
|
||||
Ok(CStr::from_ptr(ptr as *const c_char)
|
||||
.to_string_lossy()
|
||||
.into_owned())
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ pub use harfbuzz::*;
|
||||
|
||||
use anyhow::{ensure, Error};
|
||||
use std::mem;
|
||||
use std::os::raw::c_char;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
@ -42,7 +43,7 @@ hb_coretext_font_get_ct_font (hb_font_t *font);
|
||||
|
||||
pub fn language_from_string(s: &str) -> Result<hb_language_t, Error> {
|
||||
unsafe {
|
||||
let lang = hb_language_from_string(s.as_ptr() as *const i8, s.len() as i32);
|
||||
let lang = hb_language_from_string(s.as_ptr() as *const c_char, s.len() as i32);
|
||||
ensure!(!lang.is_null(), "failed to convert {} to language");
|
||||
Ok(lang)
|
||||
}
|
||||
@ -53,7 +54,7 @@ pub fn feature_from_string(s: &str) -> Result<hb_feature_t, Error> {
|
||||
let mut feature = mem::zeroed();
|
||||
ensure!(
|
||||
hb_feature_from_string(
|
||||
s.as_ptr() as *const i8,
|
||||
s.as_ptr() as *const c_char,
|
||||
s.len() as i32,
|
||||
&mut feature as *mut _,
|
||||
) != 0,
|
||||
@ -92,7 +93,7 @@ impl Blob {
|
||||
fn from_slice(data: &[u8]) -> Result<Self, Error> {
|
||||
let blob = unsafe {
|
||||
hb_blob_create(
|
||||
data.as_ptr() as *const i8,
|
||||
data.as_ptr() as *const c_char,
|
||||
data.len() as u32,
|
||||
hb_memory_mode_t::HB_MEMORY_MODE_READONLY,
|
||||
ptr::null_mut(),
|
||||
@ -250,7 +251,7 @@ impl Buffer {
|
||||
unsafe {
|
||||
hb_buffer_add_utf8(
|
||||
self.buf,
|
||||
buf.as_ptr() as *const i8,
|
||||
buf.as_ptr() as *const c_char,
|
||||
buf.len() as i32,
|
||||
0,
|
||||
buf.len() as i32,
|
||||
|
Loading…
Reference in New Issue
Block a user