From: Jan Beulich Date: Fri, 26 May 2023 07:41:41 +0000 (+0200) Subject: x86: de-duplicate operand_special_chars[] wrt extra_symbol_chars[] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d2b1a14de3214084892a6ec902301d8fda8885cf;p=binutils-gdb.git x86: de-duplicate operand_special_chars[] wrt extra_symbol_chars[] Having to add characters to both arrays can easily lead to oversights. Consuming extra_symbol_chars[] when populating operand_chars[] also allows to drop two special cases in md_begin(). Constify operand_special_chars[] at this occasion. --- diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 1b1f5d63b6a..613a15082d7 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -546,8 +546,9 @@ static char operand_chars[256]; #define is_register_char(x) (register_chars[(unsigned char) x]) #define is_space_char(x) ((x) == ' ') -/* All non-digit non-letter characters that may occur in an operand. */ -static char operand_special_chars[] = "%$-+(,)*._~/<>|&^!=:[@]"; +/* All non-digit non-letter characters that may occur in an operand and + which aren't already in extra_symbol_chars[]. */ +static const char operand_special_chars[] = "$+,)._~/<>|&^!=:@]"; /* md_assemble() always leaves the strings it's passed unaltered. To effect this we maintain a stack of saved characters that we've smashed @@ -3070,7 +3071,7 @@ md_begin (void) /* Fill in lexical tables: mnemonic_chars, operand_chars. */ { int c; - char *p; + const char *p; for (c = 0; c < 256; c++) { @@ -3087,10 +3088,7 @@ md_begin (void) operand_chars[c] = c; } else if (c == '{' || c == '}') - { - mnemonic_chars[c] = c; - operand_chars[c] = c; - } + mnemonic_chars[c] = c; #ifdef SVR4_COMMENT_CHARS else if (c == '\\' && strchr (i386_comment_chars, '/')) operand_chars[c] = c; @@ -3100,13 +3098,12 @@ md_begin (void) operand_chars[c] = c; } -#ifdef LEX_QM - operand_chars['?'] = '?'; -#endif mnemonic_chars['_'] = '_'; mnemonic_chars['-'] = '-'; mnemonic_chars['.'] = '.'; + for (p = extra_symbol_chars; *p != '\0'; p++) + operand_chars[(unsigned char) *p] = *p; for (p = operand_special_chars; *p != '\0'; p++) operand_chars[(unsigned char) *p] = *p; }