aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lex.l
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-09-21 13:50:51 +0000
committerDaniel Jacobowitz <drow@false.org>2006-09-21 13:50:51 +0000
commit253c8abb67a72cdfcdb2be4b92e2dba8689e6554 (patch)
tree7d79e3725009992103877706f6e2317a558a663c /gdb/ada-lex.l
parentc96fc75e9e90e0781789095b842495bbcdbb037a (diff)
downloadgdb-253c8abb67a72cdfcdb2be4b92e2dba8689e6554.zip
gdb-253c8abb67a72cdfcdb2be4b92e2dba8689e6554.tar.gz
gdb-253c8abb67a72cdfcdb2be4b92e2dba8689e6554.tar.bz2
* ada-lex.l (HIGH_BYTE_POSN, is_digit_in_base, digit_to_int)
(strtoulst): Moved to ... * utils.c (HIGH_BYTE_POSN, is_digit_in_base, digit_to_int) (strtoulst): ... here. Enhanced to behave more similarly to strtoul. * defs.h (strtoulst): New prototype.
Diffstat (limited to 'gdb/ada-lex.l')
-rw-r--r--gdb/ada-lex.l62
1 files changed, 0 insertions, 62 deletions
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index b25264c..7ece109 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -296,68 +296,6 @@ canonicalizeNumeral (char *s1, const char *s2)
s1[0] = '\000';
}
-#define HIGH_BYTE_POSN ((sizeof (ULONGEST) - 1) * HOST_CHAR_BIT)
-
-/* True (non-zero) iff DIGIT is a valid digit in radix BASE,
- where 2 <= BASE <= 16. */
-
-static int
-is_digit_in_base (unsigned char digit, int base)
-{
- if (!isxdigit (digit))
- return 0;
- if (base <= 10)
- return (isdigit (digit) && digit < base + '0');
- else
- return (isdigit (digit) || tolower (digit) < base - 10 + 'a');
-}
-
-static int
-digit_to_int (unsigned char c)
-{
- if (isdigit (c))
- return c - '0';
- else
- return tolower (c) - 'a' + 10;
-}
-
-/* As for strtoul, but for ULONGEST results. */
-
-ULONGEST
-strtoulst (const char *num, const char **trailer, int base)
-{
- unsigned int high_part;
- ULONGEST result;
- int i;
- unsigned char lim;
-
- if (base < 2 || base > 16)
- {
- errno = EINVAL;
- return 0;
- }
- lim = base - 1 + '0';
-
- result = high_part = 0;
- for (i = 0; is_digit_in_base (num[i], base); i += 1)
- {
- result = result*base + digit_to_int (num[i]);
- high_part = high_part*base + (unsigned int) (result >> HIGH_BYTE_POSN);
- result &= ((ULONGEST) 1 << HIGH_BYTE_POSN) - 1;
- if (high_part > 0xff)
- {
- errno = ERANGE;
- result = high_part = 0;
- break;
- }
- }
-
- if (trailer != NULL)
- *trailer = &num[i];
-
- return result + ((ULONGEST) high_part << HIGH_BYTE_POSN);
-}
-
/* Interprets the prefix of NUM that consists of digits of the given BASE
as an integer of that BASE, with the string EXP as an exponent.
Puts value in yylval, and returns INT, if the string is valid. Causes