Skip to content

Commit

Permalink
rename scrotWaitUntil -> scrotSleepUntil
Browse files Browse the repository at this point in the history
also merge the two comments with similar purpose into one.
  • Loading branch information
N-R-K committed May 26, 2023
1 parent 521544c commit d797864
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/scrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static Imlib_Image scrotGrabFocused(void);
static void applyFilterIfRequired(void);
static Imlib_Image scrotGrabAutoselect(void);
static long miliToNanoSec(int);
static void scrotWaitUntil(const struct timespec *);
static void scrotSleepUntil(const struct timespec *);
static Imlib_Image scrotGrabShotMulti(void);
static Imlib_Image scrotGrabShotMonitor(void);
static Imlib_Image scrotGrabStackWindows(void);
Expand Down Expand Up @@ -337,12 +337,12 @@ void scrotDoDelay(void)
for (int i = opt.delay; i > 0; i--) {
dprintf(STDERR_FILENO, "%d.. ", i);
opt.delayStart.tv_sec++;
scrotWaitUntil(&opt.delayStart);
scrotSleepUntil(&opt.delayStart);
}
dprintf(STDERR_FILENO, "0.\n");
} else {
opt.delayStart.tv_sec += opt.delay;
scrotWaitUntil(&opt.delayStart);
scrotSleepUntil(&opt.delayStart);
}
}

Expand All @@ -361,16 +361,14 @@ void scrotSleepFor(int ms)
bool overflow = tmp.tv_nsec >= miliToNanoSec(1000);
tmp.tv_sec += overflow;
tmp.tv_nsec -= overflow ? miliToNanoSec(1000) : 0;
scrotWaitUntil(&tmp);
scrotSleepUntil(&tmp);
}

/* scrotWaitUntil: clock_nanosleep with a simpler interface and no EINTR nagging
/* OpenBSD and OS X lack clock_nanosleep(), so we use nanosleep() and a trivial
* algorithm to correct for drift. Also takes care of EINTR.
*/
static void scrotWaitUntil(const struct timespec *time)
static void scrotSleepUntil(const struct timespec *time)
{
/* OpenBSD and OS X lack clock_nanosleep(), so we use a trivial algorithm to
* correct for drift and call nanosleep() everywhere.
*/
struct timespec tmp;
do {
clock_gettime(CONTINUOUS_CLOCK, &tmp);
Expand Down

0 comments on commit d797864

Please sign in to comment.