[v2,43/65] RISC-V: use is_whitespace()

Message ID b813bd6e-0175-4b6f-96b4-8a1c6597853f@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:34 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). Switch places already checking for tabs to use the
macro, too.
---
v2: Also replace ISSPACE() and a strspn() use.
  

Patch

--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -2484,7 +2484,7 @@  parse_relocation (char **str, bfd_reloc_
       {
 	size_t len = 1 + strlen (percent_op->str);
 
-	while (ISSPACE ((*str)[len]))
+	while (is_whitespace ((*str)[len]))
 	  ++len;
 	if ((*str)[len] != '(')
 	  continue;
@@ -2548,7 +2548,7 @@  my_getSmallExpression (expressionS *ep,
 
       /* Skip over whitespace and brackets, keeping count of the number
 	 of brackets.  */
-      while (*str == ' ' || *str == '\t' || *str == '(')
+      while (is_whitespace (*str) || *str == '(')
 	if (*str++ == '(')
 	  str_depth++;
     }
@@ -2577,7 +2577,7 @@  my_getSmallExpression (expressionS *ep,
   probing_insn_operands = orig_probing;
 
   /* Match every open bracket.  */
-  while (crux_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t'))
+  while (crux_depth > 0 && (*str == ')' || is_whitespace (*str)))
     if (*str++ == ')')
       crux_depth--;
 
@@ -2844,7 +2844,7 @@  riscv_ip (char *str, struct riscv_cl_ins
   /* Parse the name of the instruction.  Terminate the string if whitespace
      is found so that str_hash_find only sees the name part of the string.  */
   for (asarg = str; *asarg!= '\0'; ++asarg)
-    if (ISSPACE (*asarg))
+    if (is_whitespace (*asarg))
       {
 	save_c = *asarg;
 	*asarg++ = '\0';
@@ -2891,7 +2891,8 @@  riscv_ip (char *str, struct riscv_cl_ins
       for (oparg = insn->args;; ++oparg)
 	{
 	  opargStart = oparg;
-	  asarg += strspn (asarg, " \t");
+	  while (is_whitespace (*asarg))
+	    ++asarg;
 	  switch (*oparg)
 	    {
 	    case '\0': /* End of args.  */
@@ -3520,7 +3521,7 @@  riscv_ip (char *str, struct riscv_cl_ins
 	      if (reg_lookup (&asarg, RCLASS_GPR, &regno))
 		{
 		  char c = *oparg;
-		  if (*asarg == ' ')
+		  if (is_whitespace (*asarg))
 		    ++asarg;
 
 		  /* Now that we have assembled one operand, we use the args
@@ -3554,7 +3555,7 @@  riscv_ip (char *str, struct riscv_cl_ins
 			      ? RCLASS_GPR : RCLASS_FPR), &regno))
 		{
 		  char c = *oparg;
-		  if (*asarg == ' ')
+		  if (is_whitespace (*asarg))
 		    ++asarg;
 		  switch (c)
 		    {
@@ -4963,7 +4964,7 @@  s_riscv_option (int x ATTRIBUTE_UNUSED)
   else if (strncmp (name, "arch,", 5) == 0)
     {
       name += 5;
-      if (ISSPACE (*name) && *name != '\0')
+      if (is_whitespace (*name) && *name != '\0')
 	name++;
       riscv_update_subset (&riscv_rps_as, name);
       riscv_set_arch_str (&riscv_rps_as.subset_list->arch_str);