This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: demand_empty_rest_of_line and ignore_rest_of_line


Hi,
This patch implements
*) demand_empty_rest_of_line issues an error and skips to EOL
*) ignore_rest_of_line silently skips to EOL.

I went through the config dir and inspected all uses of
ignore_rest_of_line.  Those that needed to be demand_empty_rest_of_line
are changed.  I tested with the following targets,

arc-unknown-elf
i686-pc-linux-gnu
ia64-unknown-linux-gnu
mips-unknown-elf

ok?

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-03-18  Nathan Sidwell  <nathan@codesourcery.com>

	* read.c (read_a_source_file): Use demand_empty_rest_of_line.
	(demand_empty_rest_of_line): Issue an error here.
	(ignore_rest_of_line): Silently skip to end.
	(demand_copy_string): Issue an error, not warning.
	(equals): Likewise.
	* config/obj-elf.c (obj_elf_section_name): Likewise.
	(obj_elf_section): Likewise.
	* config/tc-arc.c (arc_extoper): Remove bogus NULL checks.
	(arc_extinst): Likewise.
	* config/tc-ia64.c (dot_saveb): Use demand_empty_rest_of_line.
	(dot_spill): Likewise.
	(dot_unwabi): Likewise.
	(dot_prologue): Likewise.

Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.76
diff -c -3 -p -r1.76 read.c
*** read.c	12 Mar 2004 17:48:12 -0000	1.76
--- read.c	18 Mar 2004 09:56:05 -0000
*************** read_a_source_file (char *name)
*** 1053,1059 ****
  #endif
  	  input_line_pointer--;
  	  /* Report unknown char as ignored.  */
! 	  ignore_rest_of_line ();
  	}
  
  #ifdef md_after_pass_hook
--- 1053,1059 ----
  #endif
  	  input_line_pointer--;
  	  /* Report unknown char as ignored.  */
! 	  demand_empty_rest_of_line ();
  	}
  
  #ifdef md_after_pass_hook
*************** s_text (int ignore ATTRIBUTE_UNUSED)
*** 3020,3025 ****
--- 3020,3029 ----
  #endif
  }
  
+ 
+ /* Verify that we are at the end of a line.  If not, issue an error and
+    skip to EOL.  */
+ 
  void
  demand_empty_rest_of_line (void)
  {
*************** demand_empty_rest_of_line (void)
*** 3027,3054 ****
    if (is_end_of_line[(unsigned char) *input_line_pointer])
      input_line_pointer++;
    else
-     ignore_rest_of_line ();
- 
-   /* Return having already swallowed end-of-line.  */
- }
- 
- void
- ignore_rest_of_line (void)
- {
-   /* For suspect lines: gives warning.  */
-   if (!is_end_of_line[(unsigned char) *input_line_pointer])
      {
        if (ISPRINT (*input_line_pointer))
! 	as_warn (_("rest of line ignored; first ignored character is `%c'"),
  		 *input_line_pointer);
        else
! 	as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
  		 *input_line_pointer);
! 
!       while (input_line_pointer < buffer_limit
! 	     && !is_end_of_line[(unsigned char) *input_line_pointer])
! 	input_line_pointer++;
      }
  
    input_line_pointer++;
  
--- 3031,3059 ----
    if (is_end_of_line[(unsigned char) *input_line_pointer])
      input_line_pointer++;
    else
      {
        if (ISPRINT (*input_line_pointer))
! 	as_bad (_("junk at end of line, first unrecognized character is `%c'"),
  		 *input_line_pointer);
        else
! 	as_bad (_("junk at end of line, first unrecognized character valued 0x%x"),
  		 *input_line_pointer);
!       ignore_rest_of_line ();
      }
+   
+   /* Return pointing just after end-of-line.  */
+   know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
+ }
+ 
+ /* Silently advance to the end of line.  Use this after already having
+    issued an error about something bad.  */
+ 
+ void
+ ignore_rest_of_line (void)
+ {
+   while (input_line_pointer < buffer_limit
+ 	 && !is_end_of_line[(unsigned char) *input_line_pointer])
+     input_line_pointer++;
  
    input_line_pointer++;
  
*************** demand_copy_string (int *lenP)
*** 4738,4744 ****
      }
    else
      {
!       as_warn (_("missing string"));
        retval = NULL;
        ignore_rest_of_line ();
      }
--- 4743,4749 ----
      }
    else
      {
!       as_bad (_("missing string"));
        retval = NULL;
        ignore_rest_of_line ();
      }
*************** equals (char *sym_name, int reassign)
*** 4814,4820 ****
    if (flag_mri)
      {
        /* Check garbage after the expression.  */
!       ignore_rest_of_line ();
        mri_comment_end (stop, stopc);
      }
  }
--- 4819,4825 ----
    if (flag_mri)
      {
        /* Check garbage after the expression.  */
!       demand_empty_rest_of_line ();
        mri_comment_end (stop, stopc);
      }
  }
Index: config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.79
diff -c -3 -p -r1.79 obj-elf.c
*** config/obj-elf.c	13 Dec 2003 12:57:40 -0000	1.79
--- config/obj-elf.c	18 Mar 2004 09:56:09 -0000
*************** obj_elf_section_name (void)
*** 787,793 ****
  	end++;
        if (end == input_line_pointer)
  	{
! 	  as_warn (_("missing name"));
  	  ignore_rest_of_line ();
  	  return NULL;
  	}
--- 787,793 ----
  	end++;
        if (end == input_line_pointer)
  	{
! 	  as_bad (_("missing name"));
  	  ignore_rest_of_line ();
  	  return NULL;
  	}
*************** obj_elf_section (int push)
*** 938,944 ****
  	      SKIP_WHITESPACE ();
  	      if (*input_line_pointer != '#')
  		{
! 		  as_warn (_("character following name is not '#'"));
  		  ignore_rest_of_line ();
  		  return;
  		}
--- 938,944 ----
  	      SKIP_WHITESPACE ();
  	      if (*input_line_pointer != '#')
  		{
! 		  as_bad (_("character following name is not '#'"));
  		  ignore_rest_of_line ();
  		  return;
  		}
Index: config/tc-arc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arc.c,v
retrieving revision 1.25
diff -c -3 -p -r1.25 tc-arc.c
*** config/tc-arc.c	10 Dec 2003 06:41:08 -0000	1.25
--- config/tc-arc.c	18 Mar 2004 09:56:13 -0000
*************** arc_extoper (opertype)
*** 905,915 ****
    name = input_line_pointer;
    c = get_symbol_end ();
    name = xstrdup (name);
-   if (NULL == name)
-     {
-       ignore_rest_of_line ();
-       return;
-     }
  
    p = name;
    while (*p)
--- 905,910 ----
*************** arc_extinst (ignore)
*** 1153,1163 ****
    name = input_line_pointer;
    c = get_symbol_end ();
    name = xstrdup (name);
-   if (NULL == name)
-     {
-       ignore_rest_of_line ();
-       return;
-     }
    strcpy (syntax, name);
    name_len = strlen (name);
  
--- 1148,1153 ----
*************** arc_extinst (ignore)
*** 1305,1322 ****
    strcat (syntax, "%S%L");
  
    ext_op = (struct arc_opcode *) xmalloc (sizeof (struct arc_opcode));
-   if (NULL == ext_op)
-     {
-       ignore_rest_of_line ();
-       return;
-     }
- 
    ext_op->syntax = xstrdup (syntax);
-   if (NULL == ext_op->syntax)
-     {
-       ignore_rest_of_line ();
-       return;
-     }
  
    ext_op->mask  = I (-1) | ((0x3 == opcode) ? C (-1) : 0);
    ext_op->value = I (opcode) | ((0x3 == opcode) ? C (subopcode) : 0);
--- 1295,1301 ----
Index: config/tc-ia64.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.c,v
retrieving revision 1.106
diff -c -3 -p -r1.106 tc-ia64.c
*** config/tc-ia64.c	5 Mar 2004 17:07:12 -0000	1.106
--- config/tc-ia64.c	18 Mar 2004 09:56:32 -0000
*************** dot_saveb (dummy)
*** 3617,3623 ****
      add_unwind_entry (output_br_mem (brmask));
  
    if (!is_end_of_line[sep] && !is_it_end_of_statement ())
!     ignore_rest_of_line ();
  }
  
  static void
--- 3617,3623 ----
      add_unwind_entry (output_br_mem (brmask));
  
    if (!is_end_of_line[sep] && !is_it_end_of_statement ())
!     demand_empty_rest_of_line ();
  }
  
  static void
*************** dot_spill (dummy)
*** 3649,3655 ****
  
    sep = parse_operand (&e);
    if (!is_end_of_line[sep] && !is_it_end_of_statement ())
!     ignore_rest_of_line ();
  
    if (e.X_op != O_constant)
      as_bad ("Operand to .spill must be a constant");
--- 3649,3655 ----
  
    sep = parse_operand (&e);
    if (!is_end_of_line[sep] && !is_it_end_of_statement ())
!     demand_empty_rest_of_line ();
  
    if (e.X_op != O_constant)
      as_bad ("Operand to .spill must be a constant");
*************** dot_unwabi (dummy)
*** 3925,3931 ****
      }
    sep = parse_operand (&e2);
    if (!is_end_of_line[sep] && !is_it_end_of_statement ())
!     ignore_rest_of_line ();
  
    if (e1.X_op != O_constant)
      {
--- 3925,3931 ----
      }
    sep = parse_operand (&e2);
    if (!is_end_of_line[sep] && !is_it_end_of_statement ())
!     demand_empty_rest_of_line ();
  
    if (e1.X_op != O_constant)
      {
*************** dot_prologue (dummy)
*** 4020,4026 ****
  	as_bad ("No second operand to .prologue");
        sep = parse_operand (&e2);
        if (!is_end_of_line[sep] && !is_it_end_of_statement ())
! 	ignore_rest_of_line ();
  
        if (e1.X_op == O_constant)
  	{
--- 4020,4026 ----
  	as_bad ("No second operand to .prologue");
        sep = parse_operand (&e2);
        if (!is_end_of_line[sep] && !is_it_end_of_statement ())
! 	demand_empty_rest_of_line ();
  
        if (e1.X_op == O_constant)
  	{

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]