Update to FreeBSD head 2016-08-23

Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
This commit is contained in:
Sebastian Huber
2016-10-07 15:10:20 +02:00
parent 8c0eebac7d
commit c40e45b75e
1040 changed files with 156866 additions and 67039 deletions

View File

@@ -37,31 +37,24 @@ __FBSDID("$FreeBSD$");
#include <libutil.h>
#include <stdint.h>
/*
* Convert an expression of the following forms to a uint64_t.
* 1) A positive decimal number.
* 2) A positive decimal number followed by a 'b' or 'B' (mult by 1).
* 3) A positive decimal number followed by a 'k' or 'K' (mult by 1 << 10).
* 4) A positive decimal number followed by a 'm' or 'M' (mult by 1 << 20).
* 5) A positive decimal number followed by a 'g' or 'G' (mult by 1 << 30).
* 6) A positive decimal number followed by a 't' or 'T' (mult by 1 << 40).
* 7) A positive decimal number followed by a 'p' or 'P' (mult by 1 << 50).
* 8) A positive decimal number followed by a 'e' or 'E' (mult by 1 << 60).
*/
int
expand_number(const char *buf, uint64_t *num)
{
char *endptr;
uintmax_t umaxval;
uint64_t number;
unsigned shift;
char *endptr;
int serrno;
number = strtoumax(buf, &endptr, 0);
if (endptr == buf) {
/* No valid digits. */
errno = EINVAL;
serrno = errno;
errno = 0;
umaxval = strtoumax(buf, &endptr, 0);
if (umaxval > UINT64_MAX)
errno = ERANGE;
if (errno != 0)
return (-1);
}
errno = serrno;
number = umaxval;
switch (tolower((unsigned char)*endptr)) {
case 'e':
@@ -97,7 +90,6 @@ expand_number(const char *buf, uint64_t *num)
errno = ERANGE;
return (-1);
}
*num = number << shift;
return (0);
}