From b75c0c920f88f3b6a5877509b14f59b5d86f88b5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 2 Jun 2000 02:52:10 +0000 Subject: [PATCH] is_end_of_line fixes. --- gas/ChangeLog | 24 ++++++++++++++++++++++++ gas/config/tc-arm.c | 4 ++-- gas/config/tc-h8500.c | 3 +-- gas/config/tc-m88k.c | 2 +- gas/config/tc-mcore.c | 8 ++++---- gas/config/tc-tic30.c | 7 ++++--- gas/expr.c | 11 +++++++---- gas/read.c | 35 ++++++++++++++--------------------- 8 files changed, 57 insertions(+), 37 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index e04fcebf62..e5fd99802f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,27 @@ +2000-06-01 Alan Modra + + * expr.c (operand): Test is_end_of_line outside switch to catch + line separator chars that are also operators. + (operator): Return O_illegal for line separator chars. + + * read.c (is_end_of_line): Use 1 instead of 99. Don't set `;' + entry (or `!' entry for TC_HPPA). + + * config/tc-arm.c (my_get_float_expression): Cast to unsigned char + before indexing is_end_of_line. Remove redundant check for '\0'. + (fp_op2): Likewise. + * config/tc-h8500.c (md_assemble): Likewise. + * config/tc-mcore.c (md_assemble): Likewise. + * config/tc-tic30.c (tic30_find_parallel_insn): Likewise. + (md_atof): Likewise + + * config/tc-m88k.c (s_bss): Cast to unsigned char before indexing + is_end_of_line. + * config/tc-mcore.c (mcore_cons): Likewise. + (mcore_float_cons): Likewise. + (mcore_stringer): Likewise. + * config/tc-tic30.c (tic30_find_parallel_insn): Likewise. + 2000-06-01 Scott Bambrough * config/tc-arm.c (do_mrs): Allow SPSR_BIT to be set correctly. diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index c5b2cd768f..1a9ebc8020 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -2219,7 +2219,7 @@ my_get_float_expression (str) memset (words, 0, MAX_LITTLENUMS * sizeof (LITTLENUM_TYPE)); /* Look for a raw floating point number */ if ((save_in = atof_ieee (*str, 'x', words)) != NULL - && (is_end_of_line [(int)(*save_in)] || *save_in == '\0')) + && is_end_of_line [(unsigned char) *save_in]) { for (i = 0; i < NUM_FLOAT_VALS; i++) { @@ -2644,7 +2644,7 @@ fp_op2 (str) char *start = *str; *str += strlen (fp_const[i]); - if (is_end_of_line[(int)**str] || **str == '\0') + if (is_end_of_line[(unsigned char) **str]) { inst.instruction |= i + 8; return SUCCESS; diff --git a/gas/config/tc-h8500.c b/gas/config/tc-h8500.c index 9dec3e2e6a..b5e6be3819 100644 --- a/gas/config/tc-h8500.c +++ b/gas/config/tc-h8500.c @@ -1104,8 +1104,7 @@ DEFUN (md_assemble, (str), /* find the op code end */ for (op_start = op_end = str; - *op_end && - !is_end_of_line[*op_end] && *op_end != ' '; + !is_end_of_line[(unsigned char) *op_end] && *op_end != ' '; op_end++) { if ( /**op_end != '.' diff --git a/gas/config/tc-m88k.c b/gas/config/tc-m88k.c index f77460a0ca..a8f5b43198 100644 --- a/gas/config/tc-m88k.c +++ b/gas/config/tc-m88k.c @@ -1311,7 +1311,7 @@ s_bss () as_warn (_("Ignoring attempt to re-define symbol %s."), name); } - while (!is_end_of_line[*input_line_pointer]) + while (!is_end_of_line[(unsigned char) *input_line_pointer]) { input_line_pointer++; } diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c index 3b232148cf..0284c00535 100644 --- a/gas/config/tc-mcore.c +++ b/gas/config/tc-mcore.c @@ -239,7 +239,7 @@ mcore_cons (nbytes) int commas = 1; /* Count the number of commas on the line. */ - while (! is_end_of_line [* ptr]) + while (! is_end_of_line [(unsigned char) * ptr]) commas += * ptr ++ == ','; poolspan += nbytes * commas; @@ -268,7 +268,7 @@ mcore_float_cons (float_type) #endif /* Count the number of commas on the line. */ - while (! is_end_of_line [* ptr]) + while (! is_end_of_line [(unsigned char) * ptr]) commas += * ptr ++ == ','; /* We would like to compute "hex_float (float_type) * commas" @@ -301,7 +301,7 @@ mcore_stringer (append_zero) estimate, which is OK, and automatically allows for the appending a zero byte, since the real string(s) is/are required to be enclosed in double quotes. */ - while (! is_end_of_line [* ptr]) + while (! is_end_of_line [(unsigned char) * ptr]) ptr ++; poolspan += ptr - input_line_pointer; @@ -975,7 +975,7 @@ md_assemble (str) /* Find the op code end. */ for (op_start = op_end = str; - * op_end && nlen < 20 && !is_end_of_line [*op_end] && *op_end != ' '; + nlen < 20 && !is_end_of_line [(unsigned char) *op_end] && *op_end != ' '; op_end++) { name[nlen] = op_start[nlen]; diff --git a/gas/config/tc-tic30.c b/gas/config/tc-tic30.c index 255c06a381..e85811454b 100644 --- a/gas/config/tc-tic30.c +++ b/gas/config/tc-tic30.c @@ -1459,7 +1459,7 @@ tic30_find_parallel_insn (current_line, next_line) char *parallel_insn; debug ("In tic30_find_parallel_insn()\n"); - while (!is_end_of_line[(int) *next_line]) + while (!is_end_of_line[(unsigned char) *next_line]) { if (*next_line == PARALLEL_SEPARATOR && *(next_line + 1) == PARALLEL_SEPARATOR) { @@ -1495,7 +1495,7 @@ tic30_find_parallel_insn (current_line, next_line) int char_ptr = 0; char c; - while (!is_end_of_line[(int) (c = *line)] && *line) + while (!is_end_of_line[(unsigned char) (c = *line)]) { if (is_opcode_char (c) && search_status == NONE) { @@ -1682,7 +1682,8 @@ md_atof (what_statement_type, literalP, sizeP) debug ("literal = %s\n", literalP); debug ("line = "); token = input_line_pointer; - while (!is_end_of_line[(unsigned) *input_line_pointer] && (*input_line_pointer) && (*input_line_pointer != ',')) + while (!is_end_of_line[(unsigned char) *input_line_pointer] + && (*input_line_pointer != ',')) { debug ("%c", *input_line_pointer); input_line_pointer++; diff --git a/gas/expr.c b/gas/expr.c index 851a406e01..11a9e13465 100644 --- a/gas/expr.c +++ b/gas/expr.c @@ -799,6 +799,9 @@ operand (expressionP) SKIP_WHITESPACE (); /* leading whitespace is part of operand. */ c = *input_line_pointer++; /* input_line_pointer->past char in c. */ + if (is_end_of_line[(unsigned char) c]) + goto eol; + switch (c) { case '1': @@ -1166,9 +1169,8 @@ operand (expressionP) { goto isname; } + case ',': - case '\n': - case '\0': eol: /* can't imagine any other kind of operand */ expressionP->X_op = O_absent; @@ -1211,8 +1213,6 @@ operand (expressionP) #ifdef TC_M68K de_fault: #endif - if (is_end_of_line[(unsigned char) c]) - goto eol; if (is_name_beginner (c)) /* here if did not begin with a digit */ { /* @@ -1571,6 +1571,9 @@ operator () c = *input_line_pointer & 0xff; + if (is_end_of_line[c]) + return O_illegal; + switch (c) { default: diff --git a/gas/read.c b/gas/read.c index 2ea5e2b612..7ff8aad324 100644 --- a/gas/read.c +++ b/gas/read.c @@ -146,33 +146,26 @@ char lex_type[256] = * In: a character. * Out: 1 if this character ends a line. */ -#define Z_ (0) char is_end_of_line[256] = { #ifdef CR_EOL - 99, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, 99, Z_, Z_, 99, Z_, Z_, /* @abcdefghijklmno */ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */ #else - 99, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, 99, Z_, Z_, Z_, Z_, Z_, /* @abcdefghijklmno */ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */ #endif - Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, /* */ -#ifdef TC_HPPA - Z_,99, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, /* _!"#$%&'()*+,-./ */ - Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, /* 0123456789:;<=>? */ -#else - Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z_, /* */ - Z_, Z_, Z_, Z_, Z_, Z_, Z_, Z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