This is the mail archive of the binutils@sourceware.org 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]

assembler skipping \ chars


The assembler skips \ chars if they appear in certain positions of the input file :(

This is occurring in do_scrub_chars, where we fill an input buffer (usually 32768 chars at a time). In some states we'll emit ' \' instead of '\'. Unfortunately, if we're at the end of the input buffer, the PUT (' ') causes us to exit do_scrub_chars, without saving the '\' character.

This patch changes do_scrub_chars to check whether we're near the end of the input buffer before trying to emit the ' \' sequence. If we are, we UNGET the '\' and exit immediately.

Our user had the unfortunate case where a macro was appearing near the end of an input chunk such that an arg use triggered this bug, leading to confusing error messages.

ok?

nathan

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

2007-05-26  Nathan Sidwell  <nathan@codesourcery.com>

	* app.c (do_scrub_chars): Cope with \ at end of buffer.

Index: app.c
===================================================================
RCS file: /cvs/src/src/gas/app.c,v
retrieving revision 1.40
diff -c -3 -p -r1.40 app.c
*** app.c	15 May 2007 10:06:03 -0000	1.40
--- app.c	26 May 2007 20:54:34 -0000
*************** do_scrub_chars (int (*get) (char *, int)
*** 1360,1366 ****
  		     the space.  We don't have enough information to
  		     make the right choice, so here we are making the
  		     choice which is more likely to be correct.  */
! 		  PUT (' ');
  		}
  
  	      state = 3;
--- 1360,1374 ----
  		     the space.  We don't have enough information to
  		     make the right choice, so here we are making the
  		     choice which is more likely to be correct.  */
! 		  if (to + 1 >= toend)
! 		    {
! 		      /* If we're near the end of the buffer, save the
! 		         character for the next time round.  Otherwise
! 		         we'll lose our state.  */
! 		      UNGET (ch);
! 		      goto tofull;
! 		    }
! 		  *to++ = ' ';
  		}
  
  	      state = 3;

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