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]

PATCH: def_file_add_directive: Cope with NUL separated directives.


Hi Guys,

  I am applying the patch below to allow the def_file_add_directive()
  function to cope with multiple NUL separated directives.

Cheers
        Nick

2003-06-27  Nick Clifton  <nickc@redhat.com>

	* deffilep.y (def_file_add_directive): Cope with NUL seperated
	directives.  Fix reporting of unparseable directives.
	(def_error): Check for a NULL def_filename.

Index: ld/deffilep.y
===================================================================
RCS file: /cvs/src/src/ld/deffilep.y,v
retrieving revision 1.14
diff -c -3 -p -r1.14 deffilep.y
*** ld/deffilep.y	18 Mar 2003 21:33:43 -0000	1.14
--- ld/deffilep.y	27 Jun 2003 08:09:10 -0000
*************** def_file_add_directive (my_def, param, l
*** 601,618 ****
  {
    def_file *save_def = def;
    const char *pend = param + len;
!   const char *tend = param;
    int i;
  
    def = my_def;
  
    while (param < pend)
      {
!       while (param < pend && ISSPACE (*param))
  	param++;
  
!       for (tend = param + 1;
! 	   tend < pend && !(ISSPACE (tend[-1]) && *tend == '-');
  	   tend++)
  	;
  
--- 601,626 ----
  {
    def_file *save_def = def;
    const char *pend = param + len;
!   char * tend = (char *) param;
    int i;
  
    def = my_def;
  
    while (param < pend)
      {
!       while (param < pend && (ISSPACE (*param) || * param == '\n' || * param == 0))
  	param++;
  
!       if (param == pend)
! 	break;
! 
!       /* Scan forward until we encounter any of:
!           - the end of the buffer
! 	  - the start of a new option
! 	  - a newline seperating options
!           - a NUL seperating options.  */
!       for (tend = (char *) (param + 1);
! 	   tend < pend && !(ISSPACE (tend[-1]) && *tend == '-') && (*tend != '\n') && (*tend != 0);
  	   tend++)
  	;
  
*************** def_file_add_directive (my_def, param, l
*** 628,642 ****
  	      lex_parse_string = param + len + 1;
  	      lex_forced_token = diropts[i].token;
  	      saw_newline = 0;
! 	      def_parse ();
  	      break;
  	    }
  	}
  
        if (!diropts[i].param)
! 	/* xgettext:c-format */
! 	einfo (_("Warning: .drectve `%.*s' unrecognized\n"),
! 	       tend - param, param);
  
        lex_parse_string = 0;
        param = tend;
--- 636,657 ----
  	      lex_parse_string = param + len + 1;
  	      lex_forced_token = diropts[i].token;
  	      saw_newline = 0;
! 	      if (def_parse ())
! 		continue;
  	      break;
  	    }
  	}
  
        if (!diropts[i].param)
! 	{
! 	  char saved;
! 
! 	  saved = * tend;
! 	  * tend = 0;
! 	  /* xgettext:c-format */
! 	  einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
! 	  * tend = saved;
! 	}
  
        lex_parse_string = 0;
        param = tend;
*************** static int
*** 843,849 ****
  def_error (err)
       const char *err;
  {
!   einfo ("%P: %s:%d: %s\n", def_filename, linenumber, err);
  
    return 0;
  }
--- 858,864 ----
  def_error (err)
       const char *err;
  {
!   einfo ("%P: %s:%d: %s\n", def_filename ? def_filename : "<unknown-file>", linenumber, err);
  
    return 0;
  }
        


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