MCPcopy Index your code
hub / github.com/RustPython/RustPython / copy_grouping

Function copy_grouping

crates/stdlib/src/locale.rs:81–100  ·  view source on GitHub ↗
(group: *const libc::c_char, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

79 }
80
81 unsafe fn copy_grouping(group: *const libc::c_char, vm: &VirtualMachine) -> PyListRef {
82 let mut group_vec: Vec<PyObjectRef> = Vec::new();
83 if group.is_null() {
84 return vm.ctx.new_list(group_vec);
85 }
86
87 unsafe {
88 let mut ptr = group;
89 while ![0, libc::c_char::MAX].contains(&*ptr) {
90 let val = vm.ctx.new_int(*ptr);
91 group_vec.push(val.into());
92 ptr = ptr.add(1);
93 }
94 }
95 // https://github.com/python/cpython/blob/677320348728ce058fa3579017e985af74a236d4/Modules/_localemodule.c#L80
96 if !group_vec.is_empty() {
97 group_vec.push(vm.ctx.new_int(0).into());
98 }
99 vm.ctx.new_list(group_vec)
100 }
101
102 unsafe fn pystr_from_raw_cstr(vm: &VirtualMachine, raw_ptr: *const libc::c_char) -> PyResult {
103 let slice = unsafe { CStr::from_ptr(raw_ptr) };

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
new_listMethod · 0.80
containsMethod · 0.45
new_intMethod · 0.45
pushMethod · 0.45
addMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected