Skip to content

Commit

Permalink
moved ctermid from nt to posix - defined ctermid inline
Browse files Browse the repository at this point in the history
  • Loading branch information
AthulMuralidhar committed Jan 26, 2021
1 parent cf4c7a9 commit aec87be
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions vm/src/stdlib/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2280,6 2280,20 @@ mod posix {
})
}

extern "C" {
fn ctermid(s: *mut libc::c_char) -> *mut libc::c_char;
}
#[pyfunction]
fn _ctermid(vm: &VirtualMachine) -> PyResult{
let returned = unsafe { ctermid(std::ptr::null_mut()) };
if returned.is_null(){
Err(errno_err(vm))
} else {
let ret = unsafe { ffi::CStr::from_ptr(ret) }.to_str().unwrap();
Ok(vm.ctx.new_str(name))
}
}

pub(super) fn support_funcs(vm: &VirtualMachine) -> Vec<SupportFunc> {
vec![
SupportFunc::new(vm, "chmod", chmod, Some(false), Some(false), Some(false)),
Expand Down Expand Up @@ -2652,16 2666,6 @@ mod nt {
}
}

#[pyfunction]
fn ctermid(vm: &VirtualMachine) -> PyResult{
let ret = unsafe { libc::ctermid() };
if ret.is_null(){
Err(errno_err(vm))
} else {
let ret = unsafe { ffi::CStr::from_ptr(ret) }.to_str().unwrap();
Ok(vm.ctx.new_str(name))
}
}

pub(super) fn support_funcs(_vm: &VirtualMachine) -> Vec<SupportFunc> {
Vec::new()
Expand Down

0 comments on commit aec87be

Please sign in to comment.