aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-12-31 19:39:18 +1030
committerAlan Modra <amodra@gmail.com>2024-01-05 13:00:11 +1030
commit1826e070a09060edafc5e7dc2c50d967472622d8 (patch)
tree74083ab74151e2ca30dd7bac84fcb44a08edbdbd /bfd/bfd.c
parentc217aed574216e6af34188ac8a9bf019539e415d (diff)
downloadgdb-1826e070a09060edafc5e7dc2c50d967472622d8.zip
gdb-1826e070a09060edafc5e7dc2c50d967472622d8.tar.gz
gdb-1826e070a09060edafc5e7dc2c50d967472622d8.tar.bz2
Tidy bfd_scan_vma
In commit 83c79df86bf4 I removed configure tests for strtoull among other library functions part of C99, but didn't remove what is now dead code. * bfd.c (bfd_scan_vma): Delete fall-back for strtoull.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r--bfd/bfd.c73
1 files changed, 4 insertions, 69 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index c8e38b0..0776145 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2257,86 +2257,21 @@ SYNOPSIS
bfd_vma bfd_scan_vma (const char *string, const char **end, int base);
DESCRIPTION
- Convert, like <<strtoul>>, a numerical expression
- @var{string} into a <<bfd_vma>> integer, and return that integer.
- (Though without as many bells and whistles as <<strtoul>>.)
- The expression is assumed to be unsigned (i.e., positive).
- If given a @var{base}, it is used as the base for conversion.
- A base of 0 causes the function to interpret the string
- in hex if a leading "0x" or "0X" is found, otherwise
- in octal if a leading zero is found, otherwise in decimal.
-
- If the value would overflow, the maximum <<bfd_vma>> value is
- returned.
+ Convert, like <<strtoul>> or <<stdtoull> depending on the size
+ of a <<bfd_vma>>, a numerical expression @var{string} into a
+ <<bfd_vma>> integer, and return that integer.
*/
bfd_vma
bfd_scan_vma (const char *string, const char **end, int base)
{
- bfd_vma value;
- bfd_vma cutoff;
- unsigned int cutlim;
- int overflow;
-
- /* Let the host do it if possible. */
if (sizeof (bfd_vma) <= sizeof (unsigned long))
return strtoul (string, (char **) end, base);
if (sizeof (bfd_vma) <= sizeof (unsigned long long))
return strtoull (string, (char **) end, base);
- if (base == 0)
- {
- if (string[0] == '0')
- {
- if ((string[1] == 'x') || (string[1] == 'X'))
- base = 16;
- else
- base = 8;
- }
- }
-
- if ((base < 2) || (base > 36))
- base = 10;
-
- if (base == 16
- && string[0] == '0'
- && (string[1] == 'x' || string[1] == 'X')
- && ISXDIGIT (string[2]))
- {
- string += 2;
- }
-
- cutoff = (~ (bfd_vma) 0) / (bfd_vma) base;
- cutlim = (~ (bfd_vma) 0) % (bfd_vma) base;
- value = 0;
- overflow = 0;
- while (1)
- {
- unsigned int digit;
-
- digit = *string;
- if (ISDIGIT (digit))
- digit = digit - '0';
- else if (ISALPHA (digit))
- digit = TOUPPER (digit) - 'A' + 10;
- else
- break;
- if (digit >= (unsigned int) base)
- break;
- if (value > cutoff || (value == cutoff && digit > cutlim))
- overflow = 1;
- value = value * base + digit;
- ++string;
- }
-
- if (overflow)
- value = ~ (bfd_vma) 0;
-
- if (end != NULL)
- *end = string;
-
- return value;
+ abort ();
}
/*