[v2,21/65] HP-PA: use is_whitespace()

Message ID f8119602-20f9-4bf9-9d0f-0ae30eec7e31@suse.com
State New
Headers
Series gas: whitespace handling |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Jan Beulich Jan. 27, 2025, 4:20 p.m. UTC
  Convert open-coded checks. At the same time use is_end_of_stmt() instead
of an open-coded check in adjacent code.
---
v2: New.
  

Comments

John David Anglin Jan. 27, 2025, 10:50 p.m. UTC | #1
Can't test without is_whitespace() being defined but it looks okay.

Dave

On 2025-01-27 11:20 a.m., Jan Beulich wrote:
> Convert open-coded checks. At the same time use is_end_of_stmt() instead
> of an open-coded check in adjacent code.
> ---
> v2: New.
> 
> --- a/gas/config/tc-hppa.c
> +++ b/gas/config/tc-hppa.c
> @@ -2013,7 +2013,7 @@ pa_parse_number (char **s, int is_float)
>    bool have_prefix;
>  
>    /* Skip whitespace before the number.  */
> -  while (*p == ' ' || *p == '\t')
> +  while (is_whitespace (*p))
>      p = p + 1;
>  
>    pa_number = -1;
> @@ -2229,12 +2229,12 @@ pa_parse_fp_cmp_cond (char **s)
>  	  *s += strlen (fp_cond_map[i].string);
>  	  /* If not a complete match, back up the input string and
>  	     report an error.  */
> -	  if (**s != ' ' && **s != '\t')
> +	  if (!is_whitespace (**s))
>  	    {
>  	      *s -= strlen (fp_cond_map[i].string);
>  	      break;
>  	    }
> -	  while (**s == ' ' || **s == '\t')
> +	  while (is_whitespace (**s))
>  	    *s = *s + 1;
>  	  return cond;
>  	}
> @@ -2243,7 +2243,7 @@ pa_parse_fp_cmp_cond (char **s)
>    as_bad (_("Invalid FP Compare Condition: %s"), *s);
>  
>    /* Advance over the bogus completer.  */
> -  while (**s != ',' && **s != ' ' && **s != '\t')
> +  while (**s != ',' && !is_whitespace (**s))
>      *s += 1;
>  
>    return 0;
> @@ -2416,7 +2416,7 @@ pa_chk_field_selector (char **str)
>    char *s = *str;
>  
>    /* Read past any whitespace.  */
> -  while (*s == ' ' || *s == '\t')
> +  while (is_whitespace (*s))
>      s++;
>    *str = s;
>  
> @@ -2547,7 +2547,7 @@ pa_get_number (struct pa_it *insn, char
>       contain no whitespace.  */
>  
>    s = *strp;
> -  while (*s != ',' && *s != ' ' && *s != '\t')
> +  while (*s != ',' && !is_whitespace (*s))
>      s++;
>  
>    c = *s;
> @@ -2627,7 +2627,7 @@ pa_parse_nonneg_cmpsub_cmpltr (char **s)
>    if (**s == ',')
>      {
>        *s += 1;
> -      while (**s != ',' && **s != ' ' && **s != '\t')
> +      while (**s != ',' && !is_whitespace (**s))
>  	*s += 1;
>        c = **s;
>        **s = 0x00;
> @@ -2697,7 +2697,7 @@ pa_parse_neg_cmpsub_cmpltr (char **s)
>    if (**s == ',')
>      {
>        *s += 1;
> -      while (**s != ',' && **s != ' ' && **s != '\t')
> +      while (**s != ',' && !is_whitespace (**s))
>  	*s += 1;
>        c = **s;
>        **s = 0x00;
> @@ -2772,7 +2772,7 @@ pa_parse_cmpb_64_cmpltr (char **s)
>    if (**s == ',')
>      {
>        *s += 1;
> -      while (**s != ',' && **s != ' ' && **s != '\t')
> +      while (**s != ',' && !is_whitespace (**s))
>  	*s += 1;
>        c = **s;
>        **s = 0x00;
> @@ -2865,7 +2865,7 @@ pa_parse_cmpib_64_cmpltr (char **s)
>    if (**s == ',')
>      {
>        *s += 1;
> -      while (**s != ',' && **s != ' ' && **s != '\t')
> +      while (**s != ',' && !is_whitespace (**s))
>  	*s += 1;
>        c = **s;
>        **s = 0x00;
> @@ -2928,7 +2928,7 @@ pa_parse_nonneg_add_cmpltr (char **s)
>    if (**s == ',')
>      {
>        *s += 1;
> -      while (**s != ',' && **s != ' ' && **s != '\t')
> +      while (**s != ',' && !is_whitespace (**s))
>  	*s += 1;
>        c = **s;
>        **s = 0x00;
> @@ -2997,7 +2997,7 @@ pa_parse_neg_add_cmpltr (char **s)
>    if (**s == ',')
>      {
>        *s += 1;
> -      while (**s != ',' && **s != ' ' && **s != '\t')
> +      while (**s != ',' && !is_whitespace (**s))
>  	*s += 1;
>        c = **s;
>        **s = 0x00;
> @@ -3070,7 +3070,7 @@ pa_parse_addb_64_cmpltr (char **s)
>    if (**s == ',')
>      {
>        *s += 1;
> -      while (**s != ',' && **s != ' ' && **s != '\t')
> +      while (**s != ',' && !is_whitespace (**s))
>  	*s += 1;
>        c = **s;
>        **s = 0x00;
> @@ -3178,7 +3178,7 @@ pa_ip (char *str)
>  
>    /* Convert everything up to the first whitespace character into lower
>       case.  */
> -  for (s = str; *s != ' ' && *s != '\t' && *s != '\n' && *s != '\0'; s++)
> +  for (s = str; !is_whitespace (*s) && !is_end_of_stmt (*s); s++)
>      *s = TOLOWER (*s);
>  
>    /* Skip to something interesting.  */
> @@ -3198,11 +3198,13 @@ pa_ip (char *str)
>  
>        /*FALLTHROUGH */
>  
> -    case ' ':
> +    zap_char:
>        *s++ = '\0';
>        break;
>  
>      default:
> +      if (is_whitespace (*s))
> +	goto zap_char;
>        as_bad (_("Unknown opcode: `%s'"), str);
>        return;
>      }
> @@ -3239,7 +3241,7 @@ pa_ip (char *str)
>        for (args = insn->args;; ++args)
>  	{
>  	  /* Absorb white space in instruction.  */
> -	  while (*s == ' ' || *s == '\t')
> +	  while (is_whitespace (*s))
>  	    s++;
>  
>  	  switch (*args)
> @@ -3264,11 +3266,15 @@ pa_ip (char *str)
>  	    case '(':
>  	    case ')':
>  	    case ',':
> -	    case ' ':
>  	      if (*s++ == *args)
>  		continue;
>  	      break;
>  
> +	    case ' ':
> +	      if (is_whitespace (*s++))
> +		continue;
> +	      break;
> +
>  	    /* Handle a 5 bit register or control register field at 10.  */
>  	    case 'b':
>  	    case '^':
> @@ -3282,7 +3288,7 @@ pa_ip (char *str)
>  	       is there.  */
>  	    case '!':
>  	      /* Skip whitespace before register.  */
> -	      while (*s == ' ' || *s == '\t')
> +	      while (is_whitespace (*s))
>  		s = s + 1;
>  
>  	      if (!strncasecmp (s, "%sar", 4))
> @@ -3956,7 +3962,7 @@ pa_ip (char *str)
>  			  break;
>  
>  			name = s;
> -			while (*s != ',' && *s != ' ' && *s != '\t')
> +			while (*s != ',' && !is_whitespace (*s))
>  			  s += 1;
>  			c = *s;
>  			*s = 0x00;
> @@ -4131,7 +4137,7 @@ pa_ip (char *str)
>  			  break;
>  
>  			name = s;
> -			while (*s != ',' && *s != ' ' && *s != '\t')
> +			while (*s != ',' && !is_whitespace (*s))
>  			  s += 1;
>  			c = *s;
>  			*s = 0x00;
> @@ -4279,7 +4285,7 @@ pa_ip (char *str)
>  			  break;
>  
>  			name = s;
> -			while (*s != ',' && *s != ' ' && *s != '\t')
> +			while (*s != ',' && !is_whitespace (*s))
>  			  s += 1;
>  			c = *s;
>  			*s = 0x00;
> @@ -4353,7 +4359,7 @@ pa_ip (char *str)
>  			  break;
>  
>  			name = s;
> -			while (*s != ',' && *s != ' ' && *s != '\t')
> +			while (*s != ',' && !is_whitespace (*s))
>  			  s += 1;
>  			c = *s;
>  			*s = 0x00;
> @@ -4497,7 +4503,7 @@ pa_ip (char *str)
>  			    s += 3;
>  			  }
>  			/* ",*" is a valid condition.  */
> -			else if (*args != 'U' || (*s != ' ' && *s != '\t'))
> +			else if (*args != 'U' || !is_whitespace (*s))
>  			  as_bad (_("Invalid Unit Instruction Condition."));
>  		      }
>  		    /* 32-bit is default for no condition.  */
>
  
Jan Beulich Jan. 28, 2025, 7:19 a.m. UTC | #2
On 27.01.2025 23:50, John David Anglin wrote:
> Can't test without is_whitespace() being defined but it looks okay.

Well, that's patch 01 in the series.

Jan
  
John David Anglin Jan. 28, 2025, 6:19 p.m. UTC | #3
On 2025-01-28 2:19 a.m., Jan Beulich wrote:
> On 27.01.2025 23:50, John David Anglin wrote:
>> Can't test without is_whitespace() being defined but it looks okay.
> 
> Well, that's patch 01 in the series.

Okay on hppa.

Dave
  

Patch

--- a/gas/config/tc-hppa.c
+++ b/gas/config/tc-hppa.c
@@ -2013,7 +2013,7 @@  pa_parse_number (char **s, int is_float)
   bool have_prefix;
 
   /* Skip whitespace before the number.  */
-  while (*p == ' ' || *p == '\t')
+  while (is_whitespace (*p))
     p = p + 1;
 
   pa_number = -1;
@@ -2229,12 +2229,12 @@  pa_parse_fp_cmp_cond (char **s)
 	  *s += strlen (fp_cond_map[i].string);
 	  /* If not a complete match, back up the input string and
 	     report an error.  */
-	  if (**s != ' ' && **s != '\t')
+	  if (!is_whitespace (**s))
 	    {
 	      *s -= strlen (fp_cond_map[i].string);
 	      break;
 	    }
-	  while (**s == ' ' || **s == '\t')
+	  while (is_whitespace (**s))
 	    *s = *s + 1;
 	  return cond;
 	}
@@ -2243,7 +2243,7 @@  pa_parse_fp_cmp_cond (char **s)
   as_bad (_("Invalid FP Compare Condition: %s"), *s);
 
   /* Advance over the bogus completer.  */
-  while (**s != ',' && **s != ' ' && **s != '\t')
+  while (**s != ',' && !is_whitespace (**s))
     *s += 1;
 
   return 0;
@@ -2416,7 +2416,7 @@  pa_chk_field_selector (char **str)
   char *s = *str;
 
   /* Read past any whitespace.  */
-  while (*s == ' ' || *s == '\t')
+  while (is_whitespace (*s))
     s++;
   *str = s;
 
@@ -2547,7 +2547,7 @@  pa_get_number (struct pa_it *insn, char
      contain no whitespace.  */
 
   s = *strp;
-  while (*s != ',' && *s != ' ' && *s != '\t')
+  while (*s != ',' && !is_whitespace (*s))
     s++;
 
   c = *s;
@@ -2627,7 +2627,7 @@  pa_parse_nonneg_cmpsub_cmpltr (char **s)
   if (**s == ',')
     {
       *s += 1;
-      while (**s != ',' && **s != ' ' && **s != '\t')
+      while (**s != ',' && !is_whitespace (**s))
 	*s += 1;
       c = **s;
       **s = 0x00;
@@ -2697,7 +2697,7 @@  pa_parse_neg_cmpsub_cmpltr (char **s)
   if (**s == ',')
     {
       *s += 1;
-      while (**s != ',' && **s != ' ' && **s != '\t')
+      while (**s != ',' && !is_whitespace (**s))
 	*s += 1;
       c = **s;
       **s = 0x00;
@@ -2772,7 +2772,7 @@  pa_parse_cmpb_64_cmpltr (char **s)
   if (**s == ',')
     {
       *s += 1;
-      while (**s != ',' && **s != ' ' && **s != '\t')
+      while (**s != ',' && !is_whitespace (**s))
 	*s += 1;
       c = **s;
       **s = 0x00;
@@ -2865,7 +2865,7 @@  pa_parse_cmpib_64_cmpltr (char **s)
   if (**s == ',')
     {
       *s += 1;
-      while (**s != ',' && **s != ' ' && **s != '\t')
+      while (**s != ',' && !is_whitespace (**s))
 	*s += 1;
       c = **s;
       **s = 0x00;
@@ -2928,7 +2928,7 @@  pa_parse_nonneg_add_cmpltr (char **s)
   if (**s == ',')
     {
       *s += 1;
-      while (**s != ',' && **s != ' ' && **s != '\t')
+      while (**s != ',' && !is_whitespace (**s))
 	*s += 1;
       c = **s;
       **s = 0x00;
@@ -2997,7 +2997,7 @@  pa_parse_neg_add_cmpltr (char **s)
   if (**s == ',')
     {
       *s += 1;
-      while (**s != ',' && **s != ' ' && **s != '\t')
+      while (**s != ',' && !is_whitespace (**s))
 	*s += 1;
       c = **s;
       **s = 0x00;
@@ -3070,7 +3070,7 @@  pa_parse_addb_64_cmpltr (char **s)
   if (**s == ',')
     {
       *s += 1;
-      while (**s != ',' && **s != ' ' && **s != '\t')
+      while (**s != ',' && !is_whitespace (**s))
 	*s += 1;
       c = **s;
       **s = 0x00;
@@ -3178,7 +3178,7 @@  pa_ip (char *str)
 
   /* Convert everything up to the first whitespace character into lower
      case.  */
-  for (s = str; *s != ' ' && *s != '\t' && *s != '\n' && *s != '\0'; s++)
+  for (s = str; !is_whitespace (*s) && !is_end_of_stmt (*s); s++)
     *s = TOLOWER (*s);
 
   /* Skip to something interesting.  */
@@ -3198,11 +3198,13 @@  pa_ip (char *str)
 
       /*FALLTHROUGH */
 
-    case ' ':
+    zap_char:
       *s++ = '\0';
       break;
 
     default:
+      if (is_whitespace (*s))
+	goto zap_char;
       as_bad (_("Unknown opcode: `%s'"), str);
       return;
     }
@@ -3239,7 +3241,7 @@  pa_ip (char *str)
       for (args = insn->args;; ++args)
 	{
 	  /* Absorb white space in instruction.  */
-	  while (*s == ' ' || *s == '\t')
+	  while (is_whitespace (*s))
 	    s++;
 
 	  switch (*args)
@@ -3264,11 +3266,15 @@  pa_ip (char *str)
 	    case '(':
 	    case ')':
 	    case ',':
-	    case ' ':
 	      if (*s++ == *args)
 		continue;
 	      break;
 
+	    case ' ':
+	      if (is_whitespace (*s++))
+		continue;
+	      break;
+
 	    /* Handle a 5 bit register or control register field at 10.  */
 	    case 'b':
 	    case '^':
@@ -3282,7 +3288,7 @@  pa_ip (char *str)
 	       is there.  */
 	    case '!':
 	      /* Skip whitespace before register.  */
-	      while (*s == ' ' || *s == '\t')
+	      while (is_whitespace (*s))
 		s = s + 1;
 
 	      if (!strncasecmp (s, "%sar", 4))
@@ -3956,7 +3962,7 @@  pa_ip (char *str)
 			  break;
 
 			name = s;
-			while (*s != ',' && *s != ' ' && *s != '\t')
+			while (*s != ',' && !is_whitespace (*s))
 			  s += 1;
 			c = *s;
 			*s = 0x00;
@@ -4131,7 +4137,7 @@  pa_ip (char *str)
 			  break;
 
 			name = s;
-			while (*s != ',' && *s != ' ' && *s != '\t')
+			while (*s != ',' && !is_whitespace (*s))
 			  s += 1;
 			c = *s;
 			*s = 0x00;
@@ -4279,7 +4285,7 @@  pa_ip (char *str)
 			  break;
 
 			name = s;
-			while (*s != ',' && *s != ' ' && *s != '\t')
+			while (*s != ',' && !is_whitespace (*s))
 			  s += 1;
 			c = *s;
 			*s = 0x00;
@@ -4353,7 +4359,7 @@  pa_ip (char *str)
 			  break;
 
 			name = s;
-			while (*s != ',' && *s != ' ' && *s != '\t')
+			while (*s != ',' && !is_whitespace (*s))
 			  s += 1;
 			c = *s;
 			*s = 0x00;
@@ -4497,7 +4503,7 @@  pa_ip (char *str)
 			    s += 3;
 			  }
 			/* ",*" is a valid condition.  */
-			else if (*args != 'U' || (*s != ' ' && *s != '\t'))
+			else if (*args != 'U' || !is_whitespace (*s))
 			  as_bad (_("Invalid Unit Instruction Condition."));
 		      }
 		    /* 32-bit is default for no condition.  */