public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] x86: de-duplicate operand_special_chars[] wrt extra_symbol_chars[]
@ 2023-05-26  7:42 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-05-26  7:42 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d2b1a14de3214084892a6ec902301d8fda8885cf

commit d2b1a14de3214084892a6ec902301d8fda8885cf
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri May 26 09:41:41 2023 +0200

    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:
---
 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) == ' ')
 
-/* 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;
   }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-26  7:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26  7:42 [binutils-gdb] x86: de-duplicate operand_special_chars[] wrt extra_symbol_chars[] Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).