summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-06-18 16:23:01 (GMT)
committerGitHub <noreply@github.com>2021-06-18 16:23:01 (GMT)
commita91c626c29dd18dbb23f0533a940b153dd4cad33 (patch)
treebf0cb9798a0ceaa7a42d72fb72e461a847348a38 /src
parent2e7750f837547ad9d6fa6b5565d24b1f313cc5a9 (diff)
downloadhdf5-a91c626c29dd18dbb23f0533a940b153dd4cad33.zip
hdf5-a91c626c29dd18dbb23f0533a940b153dd4cad33.tar.gz
hdf5-a91c626c29dd18dbb23f0533a940b153dd4cad33.tar.bz2
Removes checks and work-arounds for strtoll and strtoull (#769)
* Removes checks and work-arounds for strtoll and strtoull * Removes CMake checks for strtoll and strtoull
Diffstat (limited to 'src')
-rw-r--r--src/H5private.h6
-rw-r--r--src/H5system.c125
2 files changed, 1 insertions, 130 deletions
diff --git a/src/H5private.h b/src/H5private.h
index a1285ee..290d873 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -1526,11 +1526,7 @@ H5_DLL void HDsrand(unsigned int seed);
#define HDstrtol(S, R, N) strtol(S, R, N)
#endif /* HDstrtol */
#ifndef HDstrtoll
-#ifdef H5_HAVE_STRTOLL
#define HDstrtoll(S, R, N) strtoll(S, R, N)
-#else
-H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base);
-#endif /* H5_HAVE_STRTOLL */
#endif /* HDstrtoll */
#ifndef HDstrtoul
#define HDstrtoul(S, R, N) strtoul(S, R, N)
@@ -1631,7 +1627,7 @@ H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base);
#ifdef H5_HAVE_VASPRINTF
#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A)
#else
-H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap);
+H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap);
#endif /* H5_HAVE_VASPRINTF */
#endif /* HDvasprintf */
#ifndef HDva_arg
diff --git a/src/H5system.c b/src/H5system.c
index 9d87726..7a87a65 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -97,131 +97,6 @@ HDvasprintf(char **bufp, const char *fmt, va_list _ap)
#endif /* H5_HAVE_VASPRINTF */
/*-------------------------------------------------------------------------
- * Function: HDstrtoll
- *
- * Purpose: Converts the string S to an int64_t value according to the
- * given BASE, which must be between 2 and 36 inclusive, or be
- * the special value zero.
- *
- * The string must begin with an arbitrary amount of white space
- * (as determined by isspace(3c)) followed by a single optional
- * `+' or `-' sign. If BASE is zero or 16 the string may then
- * include a `0x' or `0X' prefix, and the number will be read in
- * base 16; otherwise a zero BASE is taken as 10 (decimal)
- * unless the next character is a `0', in which case it is taken
- * as 8 (octal).
- *
- * The remainder of the string is converted to an int64_t in the
- * obvious manner, stopping at the first character which is not
- * a valid digit in the given base. (In bases above 10, the
- * letter `A' in either upper or lower case represetns 10, `B'
- * represents 11, and so forth, with `Z' representing 35.)
- *
- * If REST is not null, the address of the first invalid
- * character in S is stored in *REST. If there were no digits
- * at all, the original value of S is stored in *REST. Thus, if
- * *S is not `\0' but **REST is `\0' on return the entire string
- * was valid.
- *
- * Return: Success: The result.
- *
- * Failure: If the input string does not contain any
- * digits then zero is returned and REST points
- * to the original value of S. If an overflow
- * or underflow occurs then the maximum or
- * minimum possible value is returned and the
- * global `errno' is set to ERANGE. If BASE is
- * incorrect then zero is returned.
- *
- * Programmer: Robb Matzke
- * Thursday, April 9, 1998
- *
- *-------------------------------------------------------------------------
- */
-#ifndef HDstrtoll
-int64_t
-HDstrtoll(const char *s, const char **rest, int base)
-{
- int64_t sign = 1, acc = 0;
- hbool_t overflow = FALSE;
-
- errno = 0;
- if (!s || (base && (base < 2 || base > 36))) {
- if (rest)
- *rest = s;
- return 0;
- }
-
- /* Skip white space */
- while (HDisspace(*s))
- s++;
-
- /* Optional minus or plus sign */
- if ('+' == *s) {
- s++;
- }
- else if ('-' == *s) {
- sign = -1;
- s++;
- }
-
- /* Zero base prefix */
- if (0 == base && '0' == *s && ('x' == s[1] || 'X' == s[1])) {
- base = 16;
- s += 2;
- }
- else if (0 == base && '0' == *s) {
- base = 8;
- s++;
- }
- else if (0 == base) {
- base = 10;
- }
-
- /* Digits */
- while ((base <= 10 && *s >= '0' && *s < '0' + base) ||
- (base > 10 && ((*s >= '0' && *s <= '9') || (*s >= 'a' && *s < 'a' + base - 10) ||
- (*s >= 'A' && *s < 'A' + base - 10)))) {
- if (!overflow) {
- int64_t digit = 0;
-
- if (*s >= '0' && *s <= '9')
- digit = *s - '0';
- else if (*s >= 'a' && *s <= 'z')
- digit = (*s - 'a') + 10;
- else
- digit = (*s - 'A') + 10;
-
- if (acc * base + digit < acc) {
- overflow = TRUE;
- }
- else {
- acc = acc * base + digit;
- }
- }
- s++;
- }
-
- /* Overflow */
- if (overflow) {
- if (sign > 0) {
- acc = ((uint64_t)1 << (8 * sizeof(int64_t) - 1)) - 1;
- }
- else {
- acc = (int64_t)((uint64_t)1 << (8 * sizeof(int64_t) - 1));
- }
- errno = ERANGE;
- }
-
- /* Return values */
- acc *= sign;
- if (rest)
- *rest = s;
- return acc;
-} /* end HDstrtoll() */
-#endif
-
-/*-------------------------------------------------------------------------
* Function: HDrand/HDsrand
*
* Purpose: Wrapper function for rand. If rand_r exists on this system,