mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
The code can be simplified by using clock_gettime(2)'s CLOCK_REALTIME
instead of gettimeofday(2). From Scott Cheloha, ok jca
This commit is contained in:
parent
bf42a57297
commit
77b728da66
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: grdc.c,v 1.27 2017/07/13 02:57:52 tb Exp $ */
|
||||
/* $OpenBSD: grdc.c,v 1.28 2017/12/11 23:33:44 tb Exp $ */
|
||||
/*
|
||||
*
|
||||
* Copyright 2002 Amos Shapir. Public domain.
|
||||
@ -18,6 +18,7 @@
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define XLENGTH 58
|
||||
@ -61,8 +62,7 @@ main(int argc, char *argv[])
|
||||
int i, j, s, k;
|
||||
int scrol;
|
||||
int n = 0;
|
||||
struct timeval nowtv, endtv;
|
||||
struct timespec delay;
|
||||
struct timespec delay, end;
|
||||
const char *errstr;
|
||||
long scroldelay = 50000000;
|
||||
int xbase;
|
||||
@ -119,10 +119,9 @@ main(int argc, char *argv[])
|
||||
curs_set(0);
|
||||
sigwinched = 1; /* force initial sizing */
|
||||
|
||||
gettimeofday(&nowtv, NULL);
|
||||
TIMEVAL_TO_TIMESPEC(&nowtv, &now);
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
if (n)
|
||||
endtv.tv_sec = nowtv.tv_sec + n - 1;
|
||||
end.tv_sec = now.tv_sec + n - 1;
|
||||
do {
|
||||
if (sigwinched) {
|
||||
sigwinched = 0;
|
||||
@ -205,8 +204,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
if (scrol && k <= 4) {
|
||||
gettimeofday(&nowtv, NULL);
|
||||
TIMEVAL_TO_TIMESPEC(&nowtv, &now);
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
delay.tv_sec = 0;
|
||||
delay.tv_nsec = 1000000000 - now.tv_nsec
|
||||
- (4-k) * scroldelay;
|
||||
@ -217,8 +215,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
move(6, 0);
|
||||
refresh();
|
||||
gettimeofday(&nowtv, NULL);
|
||||
TIMEVAL_TO_TIMESPEC(&nowtv, &now);
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
delay.tv_sec = 0;
|
||||
delay.tv_nsec = (1000000000 - now.tv_nsec);
|
||||
/* want scrolling to END on the second */
|
||||
@ -234,7 +231,7 @@ main(int argc, char *argv[])
|
||||
endwin();
|
||||
errx(1, "terminated by signal %d", sigtermed);
|
||||
}
|
||||
} while (n == 0 || nowtv.tv_sec < endtv.tv_sec);
|
||||
} while (n == 0 || now.tv_sec < end.tv_sec);
|
||||
standend();
|
||||
clear();
|
||||
refresh();
|
||||
|
Loading…
Reference in New Issue
Block a user