[v2,02/65] gas/obj-*.c: use is_whitespace()

Message ID 8bf267ab-1c2f-4f52-a2ce-13ef53a085ae@suse.com
State New
Headers
Series gas: whitespace handling |

Commit Message

Jan Beulich Jan. 27, 2025, 3:27 p.m. UTC
  ... for consistency of recognition of what is deemed whitespace.

In obj_elf_section_name() also generalize end-of-statement recognition
at the same time. Conversely drop the unused SKIP_SEMI_COLON() for COFF.
---
The code being touched in obj_elf_section_name() looks suspicious: I
expect it ought to use get_symbol_name() rather than blindly consuming
everything that's non-whitespace, non-comma, non-statement-separator.
---
v2: New.
  

Patch

--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -567,9 +567,7 @@  obj_coff_ident (int ignore ATTRIBUTE_UNU
    a C_EFCN. And a second reason is that the code is more clear this
    way. (at least I think it is :-).  */
 
-#define SKIP_SEMI_COLON()	while (*input_line_pointer++ != ';')
-#define SKIP_WHITESPACES()	while (*input_line_pointer == ' ' || \
-				       *input_line_pointer == '\t')  \
+#define SKIP_WHITESPACES()	while (is_whitespace (*input_line_pointer)) \
                                   input_line_pointer++;
 
 static void
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -1089,7 +1089,7 @@  obj_elf_section_name (void)
     {
       char *end = input_line_pointer;
 
-      while (0 == strchr ("\n\t,; ", *end))
+      while (!is_whitespace (*end) && !is_end_of_stmt (*end) && *end != ',')
 	end++;
       if (end == input_line_pointer)
 	{
@@ -1957,8 +1957,8 @@  obj_elf_get_vtable_inherit (void)
     ++input_line_pointer;
 
   if (input_line_pointer[0] == '0'
-      && (input_line_pointer[1] == '\0'
-	  || ISSPACE (input_line_pointer[1])))
+      && (is_end_of_stmt (input_line_pointer[1])
+	  || is_whitespace (input_line_pointer[1])))
     {
       psym = section_symbol (absolute_section);
       ++input_line_pointer;
@@ -2032,7 +2032,7 @@  obj_elf_vtable_entry (int ignore ATTRIBU
   (void) obj_elf_get_vtable_entry ();
 }
 
-#define skip_whitespace(str)  do { if (*(str) == ' ') ++(str); } while (0)
+#define skip_whitespace(str)  do { if (is_whitespace (*(str))) ++(str); } while (0)
 
 static inline int
 skip_past_char (char ** str, char c)
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -111,7 +111,7 @@  collect_16char_name (char *dest, const c
   {
       int len = input_line_pointer - namstart; /* could be zero.  */
       /* lose any trailing space.  */
-      while (len > 0 && namstart[len-1] == ' ')
+      while (len > 0 && is_whitespace (namstart[len-1]))
         len--;
       if (len > 16)
         {
@@ -330,7 +330,7 @@  obj_mach_o_section (int ignore ATTRIBUTE
 
       len = input_line_pointer - p;
       /* strip trailing spaces.  */
-      while (len > 0 && p[len-1] == ' ')
+      while (len > 0 && is_whitespace (p[len - 1]))
 	len--;
       tmpc = p[len];
 
@@ -369,7 +369,7 @@  obj_mach_o_section (int ignore ATTRIBUTE
 
 	      len = input_line_pointer - p;
 	      /* strip trailing spaces.  */
-	      while (len > 0 && p[len-1] == ' ')
+	      while (len > 0 && is_whitespace (p[len - 1]))
 		len--;
 	      tmpc = p[len];
 
--- a/gas/config/obj-som.c
+++ b/gas/config/obj-som.c
@@ -79,7 +79,7 @@  obj_som_compiler (int unused ATTRIBUTE_U
      quote.  */
   filename = buf + 1;
   p = filename;
-  while (*p != ' ' && *p != '\000')
+  while (!is_whitespace (*p) && *p != '\000')
     p++;
   if (*p == '\000')
     {
@@ -89,7 +89,7 @@  obj_som_compiler (int unused ATTRIBUTE_U
   *p = '\000';
 
   language_name = ++p;
-  while (*p != ' ' && *p != '\000')
+  while (!is_whitespace (*p) && *p != '\000')
     p++;
   if (*p == '\000')
     {