From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 39C97395BC5F; Fri, 26 May 2023 07:42:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39C97395BC5F Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] x86: de-duplicate operand_special_chars[] wrt extra_symbol_chars[] X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: 540034ec40b4490705318101300cb425f6c7e667 X-Git-Newrev: d2b1a14de3214084892a6ec902301d8fda8885cf Message-Id: <20230526074213.39C97395BC5F@sourceware.org> Date: Fri, 26 May 2023 07:42:13 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 May 2023 07:42:13 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd2b1a14de321= 4084892a6ec902301d8fda8885cf commit d2b1a14de3214084892a6ec902301d8fda8885cf Author: Jan Beulich Date: Fri May 26 09:41:41 2023 +0200 x86: de-duplicate operand_special_chars[] wrt extra_symbol_chars[] =20 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(). =20 Constify operand_special_chars[] at this occasion. Diff: --- gas/config/tc-i386.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) 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) =3D=3D ' ') =20 -/* All non-digit non-letter characters that may occur in an operand. */ -static char operand_special_chars[] =3D "%$-+(,)*._~/<>|&^!=3D:[@]"; +/* 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[] =3D "$+,)._~/<>|&^!=3D:@]"; =20 /* 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; =20 for (c =3D 0; c < 256; c++) { @@ -3087,10 +3088,7 @@ md_begin (void) operand_chars[c] =3D c; } else if (c =3D=3D '{' || c =3D=3D '}') - { - mnemonic_chars[c] =3D c; - operand_chars[c] =3D c; - } + mnemonic_chars[c] =3D c; #ifdef SVR4_COMMENT_CHARS else if (c =3D=3D '\\' && strchr (i386_comment_chars, '/')) operand_chars[c] =3D c; @@ -3100,13 +3098,12 @@ md_begin (void) operand_chars[c] =3D c; } =20 -#ifdef LEX_QM - operand_chars['?'] =3D '?'; -#endif mnemonic_chars['_'] =3D '_'; mnemonic_chars['-'] =3D '-'; mnemonic_chars['.'] =3D '.'; =20 + for (p =3D extra_symbol_chars; *p !=3D '\0'; p++) + operand_chars[(unsigned char) *p] =3D *p; for (p =3D operand_special_chars; *p !=3D '\0'; p++) operand_chars[(unsigned char) *p] =3D *p; }