[v2,49/65] SH: use is_whitespace()

Message ID 0eb29372-3033-4687-92dc-9a68c75e7f0f@suse.com
State New
Headers
Series gas: whitespace handling |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed

Commit Message

Jan Beulich Jan. 27, 2025, 4:37 p.m. UTC
  Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). Also convert open-coded checks as well as an
ISSPACE() use. At the same time use is_end_of_stmt() instead of
(kind-of-)open-coded checks in adjacent code.
---
v2: New.
  

Comments

Alexandre Oliva Feb. 7, 2025, 6:54 a.m. UTC | #1
On Jan 27, 2025, Jan Beulich <jbeulich@suse.com> wrote:

> Wherever blanks are permissible in input, tabs ought to be permissible,
> too. This is particularly relevant when -f is passed to gas (alongside
> appropriate input). Also convert open-coded checks as well as an
> ISSPACE() use. At the same time use is_end_of_stmt() instead of
> (kind-of-)open-coded checks in adjacent code.

LGTM, thanks
  

Patch

--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -1232,7 +1232,7 @@  get_operands (sh_opcode_info *info, char
       /* The pre-processor will eliminate whitespace in front of '@'
 	 after the first argument; we may be called multiple times
 	 from assemble_ppi, so don't insist on finding whitespace here.  */
-      if (*ptr == ' ')
+      if (is_whitespace (*ptr))
 	ptr++;
 
       get_operand (&ptr, operand + 0);
@@ -2151,7 +2151,7 @@  find_cooked_opcode (char **str_p)
   unsigned int nlen = 0;
 
   /* Drop leading whitespace.  */
-  while (*str == ' ')
+  while (is_whitespace (*str))
     str++;
 
   /* Find the op code end.
@@ -2159,9 +2159,8 @@  find_cooked_opcode (char **str_p)
      any '@' after the first argument; we may be called from
      assemble_ppi, so the opcode might be terminated by an '@'.  */
   for (op_start = op_end = (unsigned char *) str;
-       *op_end
-       && nlen < sizeof (name) - 1
-       && !is_end_of_line[*op_end] && *op_end != ' ' && *op_end != '@';
+       nlen < sizeof (name) - 1
+       && !is_end_of_stmt (*op_end) && !is_whitespace (*op_end) && *op_end != '@';
        op_end++)
     {
       unsigned char c = op_start[nlen];
@@ -2515,10 +2514,11 @@  md_assemble (char *str)
       bool found = false;
 
       /* Identify opcode in string.  */
-      while (ISSPACE (*name))
+      while (is_whitespace (*name))
 	name++;
 
-      while (name[name_length] != '\0' && !ISSPACE (name[name_length]))
+      while (!is_end_of_stmt (name[name_length])
+	     && !is_whitespace (name[name_length]))
 	name_length++;
 
       /* Search for opcode in full list.  */
@@ -2577,7 +2577,7 @@  md_assemble (char *str)
 	    {
 	      /* Ignore trailing whitespace.  If there is any, it has already
 		 been compressed to a single space.  */
-	      if (*op_end == ' ')
+	      if (is_whitespace (*op_end))
 		op_end++;
 	    }
 	  else