Skip to content

Commit

Permalink
fff
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
  • Loading branch information
otavio committed Mar 1, 2021
1 parent 560d9ee commit f995cf6
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,10 @@ unsafe fn restore_locale(old_locale: libc::locale_t) {
}

#[cfg(windows)]
unsafe fn set_utf8_locale() -> Option<ffi::CString> {
unsafe fn set_utf8_locale() -> *mut i8 {
let locale = b".UTF-8\0";

let old_locale = {
let old_locale = libc::setlocale(libc::LC_CTYPE, ptr::null());
if old_locale.is_null() {
None
} else {
Some(ffi::CStr::from_ptr(old_locale).to_owned())
}
};
let old_locale = libc::setlocale(libc::LC_CTYPE, ptr::null());

libc::setlocale(
libc::LC_CTYPE,
Expand All @@ -73,8 +66,6 @@ unsafe fn set_utf8_locale() -> Option<ffi::CString> {
}

#[cfg(windows)]
unsafe fn restore_locale(old_locale: Option<ffi::CString>) {
if let Some(old_locale) = old_locale {
libc::setlocale(libc::LC_CTYPE, old_locale.as_ptr());
}
unsafe fn restore_locale(old_locale: *mut i8) {
libc::setlocale(libc::LC_CTYPE, old_locale);
}

0 comments on commit f995cf6

Please sign in to comment.