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

Patch to clip nesting tokens in gas


Hi Guys,

  A customer has reported a problem whereby a piece of assembler
  like this was generating an error message from gas:

    .macro foo
      .mypesudo
      .endmypseudo
    .endm

  The error message was the '.endm' was an unrecognised pseudo op.
  The reason is that the function buffer_and_nest() in macro.c is
  passed a start and end token, but it only checks for a string match
  up to the end of the tokens.  It does not check to see if there is
  any text beyond the end of the tokens.  Thus in the case above it
  sees the text '.endmypseudo', thinks that it is '.endm' with some
  garbage after it, and so terminates the macro early.

  The patch below fixes this by forcing buffer_and_nest() to check the
  character after a matching token, and to require it to be a non
  alpabetic character.

  I have built a patched assembler and checked that there are no new
  gas testsuite failures as a result of this patch.

  Any objections to my checking this patch in ?

Cheers
	Nick


1999-11-11  Nick Clifton  <nickc@cygnus.com>

	* macro.c (buffer_and_nest): Look for seperator after TO and
	FROM tokens.

Index: gas/macro.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/macro.c,v
retrieving revision 1.23
diff -p -r1.23 macro.c
*** macro.c	1998/06/02 19:39:47	1.23
--- macro.c	1999/11/11 15:41:20
*************** buffer_and_nest (from, to, ptr, get_line
*** 245,253 ****
  	{
  	  if (ptr->ptr[i] == '.')
  	      i++;
! 	  if (strncasecmp (ptr->ptr + i, from, from_len) == 0)
  	    depth++;
! 	  if (strncasecmp (ptr->ptr + i, to, to_len) == 0)
  	    {
  	      depth--;
  	      if (depth == 0)
--- 245,255 ----
  	{
  	  if (ptr->ptr[i] == '.')
  	      i++;
! 	  if (strncasecmp (ptr->ptr + i, from, from_len) == 0
! 	      && ! isalpha (ptr->ptr[i + from_len]))
  	    depth++;
! 	  if (strncasecmp (ptr->ptr + i, to, to_len) == 0
! 	      && ! isalpha (ptr->ptr[i + to_len]))
  	    {
  	      depth--;
  	      if (depth == 0)

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