diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2003-02-07 15:06:33 +0000 |
---|---|---|
committer | Richard Sandiford <rdsandiford@googlemail.com> | 2003-02-07 15:06:33 +0000 |
commit | 09b8f35ab28afe82b9841339b83746bf3b2a3575 (patch) | |
tree | 4ff4743015ce2526d98935fa288cbd0e8bdb453e /gas/config/tc-mips.c | |
parent | 589e6347e9c78e09e51a5cebcd022a5ef995048a (diff) | |
download | gdb-09b8f35ab28afe82b9841339b83746bf3b2a3575.zip gdb-09b8f35ab28afe82b9841339b83746bf3b2a3575.tar.gz gdb-09b8f35ab28afe82b9841339b83746bf3b2a3575.tar.bz2 |
* config/tc-mips.c (my_getSmallExpression): Rework bracket handling.
testsuite/
* gas/mips/expr1.[sd]: New test.
* gas/mips/mips.exp: Run it.
Diffstat (limited to 'gas/config/tc-mips.c')
-rw-r--r-- | gas/config/tc-mips.c | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 1d38d20..57c1196 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -10020,36 +10020,40 @@ my_getSmallExpression (ep, reloc, str) { bfd_reloc_code_real_type reversed_reloc[3]; size_t reloc_index, i; - int bracket_depth; - - reloc_index = 0; - bracket_depth = 0; + int crux_depth, str_depth; + char *crux; /* Search for the start of the main expression, recoding relocations - in REVERSED_RELOC. */ - for (;;) - { - if (*str == '(') - bracket_depth++, str++; - else if (*str == ' ' || *str == '\t') - str++; - else if (*str == '%' - && reloc_index < (HAVE_NEWABI ? 3 : 1) - && parse_relocation (&str, &reversed_reloc[reloc_index])) - reloc_index++; - else - break; - } - - my_getExpression (ep, str); + in REVERSED_RELOC. End the loop with CRUX pointing to the start + of the main expression and with CRUX_DEPTH containing the number + of open brackets at that point. */ + reloc_index = -1; + str_depth = 0; + do + { + reloc_index++; + crux = str; + crux_depth = str_depth; + + /* Skip over whitespace and brackets, keeping count of the number + of brackets. */ + while (*str == ' ' || *str == '\t' || *str == '(') + if (*str++ == '(') + str_depth++; + } + while (*str == '%' + && reloc_index < (HAVE_NEWABI ? 3 : 1) + && parse_relocation (&str, &reversed_reloc[reloc_index])); + + my_getExpression (ep, crux); str = expr_end; /* Match every open bracket. */ - while (bracket_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t')) + while (crux_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t')) if (*str++ == ')') - bracket_depth--; + crux_depth--; - if (bracket_depth > 0) + if (crux_depth > 0) as_bad ("unclosed '('"); expr_end = str; |