Skip to content
Snippets Groups Projects
Verified Commit 9e9b850b authored by jD91mZM2's avatar jD91mZM2
Browse files

Untested fix for pwd.h on redox

parent a0b4e21b
No related branches found
No related tags found
No related merge requests found
Pipeline #1343 failed
pub fn split(line: &[u8]) -> [&[u8]; 7] {
let mut parts: [&[u8]; 7] = [&[]; 7];
for (i, part) in line.splitn(7, |b| *b == b':').enumerate() {
parts[i] = part;
}
parts
}
......@@ -6,9 +6,14 @@ use c_str::CStr;
use header::{errno, fcntl};
use platform;
use platform::types::*;
use platform::Sys;
use platform::{Line, RawFile, RawLineBuffer};
#[cfg(target_os = "linux")] mod linux;
#[cfg(target_os = "redox")] mod redox;
#[cfg(target_os = "linux")] use self::linux as sys;
#[cfg(target_os = "redox")] use self::redox as sys;
#[repr(C)]
pub struct passwd {
pw_name: *mut c_char,
......@@ -65,14 +70,9 @@ where
};
// Parse into passwd
let mut parts: [&[u8]; 7] = [&[]; 7];
for (i, part) in line.splitn(7, |b| *b == b':').enumerate() {
parts[i] = part;
}
let mut parts: [&[u8]; 7] = sys::split(line);
if !callback(&parts) {
// TODO when nll becomes a thing:
// buf.drain(..newline + 1);
continue;
}
......
pub fn split(line: &[u8]) -> [&[u8]; 7] {
let mut parts: [&[u8]; 7] = [&[]; 7];
let mut iter = line.split(|b| *b == b';');
parts[0] = iter.next().unwrap_or(&[]);
// Skip passwd
for i in 0..2 {
parts[2+i] = iter.next().unwrap_or(&[]);
}
// Skip gecos
for i in 0..2 {
parts[5+i] = iter.next().unwrap_or(&[]);
}
parts
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment