1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

pinky: obtain correct timestamp

This commit is contained in:
Knight 2016-08-04 22:39:01 +08:00
parent 0020d5c80c
commit 833d50e192
3 changed files with 6 additions and 25 deletions

View file

@ -373,8 +373,6 @@ impl Pinky {
}
}
// WARNING: Because of the definition of `struct utmp`,
// pinky cannot get the correct value of utmp.ut_tv
print!(" {}", time_string(&ut));
if self.include_where && ut.ut_host[0] != 0 {

View file

@ -6,37 +6,30 @@
// file that was distributed with this source code.
//
extern crate uucore;
use uucore::utmpx::c_utmp;
use uucore::utmpx;
use std::ptr;
#[cfg(unix)]
extern "C" {
fn getutxent() -> *const c_utmp;
fn setutxent();
fn endutxent();
}
pub struct UtmpIter;
impl UtmpIter {
fn new() -> Self {
unsafe {
setutxent();
utmpx::setutxent();
}
UtmpIter
}
}
impl Iterator for UtmpIter {
type Item = c_utmp;
type Item = utmpx::c_utmp;
fn next(&mut self) -> Option<Self::Item> {
unsafe {
let line = getutxent();
let line = utmpx::getutxent();
if line.is_null() {
endutxent();
utmpx::endutxent();
return None;
}

View file

@ -46,18 +46,8 @@ fn test_long_format() {
#[cfg(target_os = "linux")]
#[test]
#[ignore]
fn test_short_format() {
let scene = TestScenario::new(UTIL_NAME);
let args = ["-s"];
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
let args = ["-f"];
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
let args = ["-w"];
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
let args = ["-i"];
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
@ -68,5 +58,5 @@ fn test_short_format() {
#[cfg(target_os = "linux")]
fn expected_result(args: &[&str]) -> String {
TestScenario::new(UTIL_NAME).cmd(UTIL_NAME).args(args).run().stdout
TestScenario::new(UTIL_NAME).cmd_keepenv(UTIL_NAME).args(args).run().stdout
}