aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-exp.y
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2001-02-16 01:27:46 +0000
committerAndrew Cagney <cagney@redhat.com>2001-02-16 01:27:46 +0000
commit0f6e1ba6ee7bd706a07f2af8f4cad6bb3a0b1b11 (patch)
tree64ab976710d8585087304f6583bf85bae33e7c67 /gdb/f-exp.y
parent9afc4bbfbb772aa58dc9879038fb27b68632a696 (diff)
downloadgdb-0f6e1ba6ee7bd706a07f2af8f4cad6bb3a0b1b11.zip
gdb-0f6e1ba6ee7bd706a07f2af8f4cad6bb3a0b1b11.tar.gz
gdb-0f6e1ba6ee7bd706a07f2af8f4cad6bb3a0b1b11.tar.bz2
Simplify code parsing integers and, in process fix a -Wuninitialized warning.
Diffstat (limited to 'gdb/f-exp.y')
-rw-r--r--gdb/f-exp.y32
1 files changed, 16 insertions, 16 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 049d0f5..5afed8d 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -53,6 +53,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h" /* Required by objfiles.h. */
#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
+#include <ctype.h>
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
@@ -639,7 +640,6 @@ parse_number (p, len, parsed_float, putithere)
{
register LONGEST n = 0;
register LONGEST prevn = 0;
- register int i;
register int c;
register int base = input_radix;
int unsigned_p = 0;
@@ -697,26 +697,26 @@ parse_number (p, len, parsed_float, putithere)
while (len-- > 0)
{
c = *p++;
- if (c >= 'A' && c <= 'Z')
- c += 'a' - 'A';
- if (c != 'l' && c != 'u')
- n *= base;
- if (c >= '0' && c <= '9')
- n += i = c - '0';
+ if (isupper (c))
+ c = tolower (c);
+ if (len == 0 && c == 'l')
+ long_p = 1;
+ else if (len == 0 && c == 'u')
+ unsigned_p = 1;
else
{
- if (base > 10 && c >= 'a' && c <= 'f')
- n += i = c - 'a' + 10;
- else if (len == 0 && c == 'l')
- long_p = 1;
- else if (len == 0 && c == 'u')
- unsigned_p = 1;
+ int i;
+ if (c >= '0' && c <= '9')
+ i = c - '0';
+ else if (c >= 'a' && c <= 'f')
+ i = c - 'a' + 10;
else
return ERROR; /* Char not a digit */
+ if (i >= base)
+ return ERROR; /* Invalid digit in this base */
+ n *= base;
+ n += i;
}
- if (i >= base)
- return ERROR; /* Invalid digit in this base */
-
/* Portably test for overflow (only works for nonzero values, so make
a second check for zero). */
if ((prevn >= n) && n != 0)