public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Tidy bfd_scan_vma
@ 2024-01-05  2:32 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2024-01-05  2:32 UTC (permalink / raw)
  To: binutils

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.

diff --git a/bfd/bfd.c b/bfd/bfd.c
index c8e38b05c72..0776145af52 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 ();
 }
 
 /*

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-05  2:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-05  2:32 Tidy bfd_scan_vma Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).