From 1826e070a09060edafc5e7dc2c50d967472622d8 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 31 Dec 2023 19:39:18 +1030 Subject: 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. --- bfd/bfd.c | 73 ++++----------------------------------------------------------- 1 file changed, 4 insertions(+), 69 deletions(-) (limited to 'bfd') 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 <>, a numerical expression - @var{string} into a <> integer, and return that integer. - (Though without as many bells and whistles as <>.) - 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 <> value is - returned. + Convert, like <> or < depending on the size + of a <>, a numerical expression @var{string} into a + <> 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 (); } /* -- cgit v1.1