(string: PyUtf8StrRef, vm: &VirtualMachine)
| 157 | |
| 158 | #[pyfunction] |
| 159 | fn strxfrm(string: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult { |
| 160 | // https://github.com/python/cpython/blob/eaae563b6878aa050b4ad406b67728b6b066220e/Modules/_localemodule.c#L390-L442 |
| 161 | let n1 = string.byte_len() + 1; |
| 162 | let mut buff = vec![0u8; n1]; |
| 163 | |
| 164 | let cstr = CString::new(string.as_str()).map_err(|e| e.to_pyexception(vm))?; |
| 165 | let n2 = unsafe { libc::strxfrm(buff.as_mut_ptr() as _, cstr.as_ptr(), n1) }; |
| 166 | buff = vec![0u8; n2 + 1]; |
| 167 | unsafe { |
| 168 | libc::strxfrm(buff.as_mut_ptr() as _, cstr.as_ptr(), n2 + 1); |
| 169 | } |
| 170 | Ok(vm.new_pyobj(String::from_utf8(buff).expect("strxfrm returned invalid utf-8 string"))) |
| 171 | } |
| 172 | |
| 173 | #[pyfunction] |
| 174 | fn localeconv(vm: &VirtualMachine) -> PyResult<PyDictRef> { |
nothing calls this directly
no test coverage detected