| 50 | /// Reads bytes until 0 or CHAR_MAX, then appends 0 (meaning "repeat last group"). |
| 51 | #[cfg(unix)] |
| 52 | unsafe fn parse_grouping(grouping: *const libc::c_char) -> Vec<u8> { |
| 53 | let mut result = Vec::new(); |
| 54 | if grouping.is_null() { |
| 55 | return result; |
| 56 | } |
| 57 | unsafe { |
| 58 | let mut ptr = grouping; |
| 59 | while ![0, libc::c_char::MAX].contains(&*ptr) { |
| 60 | result.push(*ptr as u8); |
| 61 | ptr = ptr.add(1); |
| 62 | } |
| 63 | } |
| 64 | if !result.is_empty() { |
| 65 | result.push(0); |
| 66 | } |
| 67 | result |
| 68 | } |
| 69 | |
| 70 | impl IntoPyException for FormatSpecError { |
| 71 | fn into_pyexception(self, vm: &VirtualMachine) -> PyBaseExceptionRef { |