mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-03 02:10:50 +02:00
commit bash-20200207 snapshot
This commit is contained in:
@@ -67,6 +67,32 @@ addtimeval (d, t1, t2)
|
||||
return d;
|
||||
}
|
||||
|
||||
struct timeval *
|
||||
multimeval (d, m)
|
||||
struct timeval *d;
|
||||
int m;
|
||||
{
|
||||
time_t t;
|
||||
|
||||
t = d->tv_usec * m;
|
||||
d->tv_sec = d->tv_sec * m + t / 1000000;
|
||||
d->tv_usec = t % 1000000;
|
||||
return d;
|
||||
}
|
||||
|
||||
struct timeval *
|
||||
divtimeval (d, m)
|
||||
struct timeval *d;
|
||||
int m;
|
||||
{
|
||||
time_t t;
|
||||
|
||||
t = d->tv_sec;
|
||||
d->tv_sec = t / m;
|
||||
d->tv_usec = (d->tv_usec + 1000000 * (t % m)) / m;
|
||||
return d;
|
||||
}
|
||||
|
||||
/* Do "cpu = ((user + sys) * 10000) / real;" with timevals.
|
||||
Barely-tested code from Deven T. Corzine <deven@ties.org>. */
|
||||
int
|
||||
@@ -149,4 +175,5 @@ print_timeval (fp, tvp)
|
||||
|
||||
fprintf (fp, "%ldm%d%c%03ds", minutes, seconds, locale_decpoint (), seconds_fraction);
|
||||
}
|
||||
|
||||
#endif /* HAVE_TIMEVAL */
|
||||
|
||||
+20
-3
@@ -1,7 +1,7 @@
|
||||
/* uconvert - convert string representations of decimal numbers into whole
|
||||
number/fractional value pairs. */
|
||||
|
||||
/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2008,2009,2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
do { \
|
||||
if (ip) *ip = ipart * mult; \
|
||||
if (up) *up = upart; \
|
||||
if (ep) *ep = p; \
|
||||
return (x); \
|
||||
} while (0)
|
||||
|
||||
@@ -61,12 +62,14 @@ static int multiplier[7] = { 1, 100000, 10000, 1000, 100, 10, 1 };
|
||||
/* Take a decimal number int-part[.[micro-part]] and convert it to the whole
|
||||
and fractional portions. The fractional portion is returned in
|
||||
millionths (micro); callers are responsible for multiplying appropriately.
|
||||
EP, if non-null, gets the address of the character where conversion stops.
|
||||
Return 1 if value converted; 0 if invalid integer for either whole or
|
||||
fractional parts. */
|
||||
int
|
||||
uconvert(s, ip, up)
|
||||
uconvert(s, ip, up, ep)
|
||||
char *s;
|
||||
long *ip, *up;
|
||||
char **ep;
|
||||
{
|
||||
int n, mult;
|
||||
long ipart, upart;
|
||||
@@ -102,7 +105,14 @@ uconvert(s, ip, up)
|
||||
for (n = 0; n < 6 && p[n]; n++)
|
||||
{
|
||||
if (DIGIT(p[n]) == 0)
|
||||
RETURN(0);
|
||||
{
|
||||
if (ep)
|
||||
{
|
||||
upart *= multiplier[n];
|
||||
p += n; /* To set EP */
|
||||
}
|
||||
RETURN(0);
|
||||
}
|
||||
upart = (upart * 10) + (p[n] - '0');
|
||||
}
|
||||
|
||||
@@ -112,5 +122,12 @@ uconvert(s, ip, up)
|
||||
if (n == 6 && p[6] >= '5' && p[6] <= '9')
|
||||
upart++; /* round up 1 */
|
||||
|
||||
if (ep)
|
||||
{
|
||||
p += n;
|
||||
while (DIGIT(*p))
|
||||
p++;
|
||||
}
|
||||
|
||||
RETURN(1);
|
||||
}
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ fsleep(sec, usec)
|
||||
#endif
|
||||
e = errno;
|
||||
if (r < 0 && errno == EINTR)
|
||||
QUIT; /* just signals, no traps */
|
||||
return -1; /* caller will handle */
|
||||
errno = e;
|
||||
}
|
||||
while (r < 0 && errno == EINTR);
|
||||
|
||||
Reference in New Issue
Block a user