This is the mail archive of the 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]

Problem with -f option and #APP

There is a bug in gas whereby the following fails when assembled with -f:

/* This code has a comment */

What happens is that the input_file_open routine in gas/input-file.c looks at
the first char in the file.  If it finds a '#', it reads in the next char,
looking for 'N' (start of NO_APP).  If this fails, it puts back the '#', but
unfortunately, it has eaten the first char after # which in this case is 'A'.
This causes the line to be read as #PP which is ignored and so
the comment on line 2 causes an error due to the -f option.

I have prepared a patch which accounts for the possibility that the first line
might be #APP.  It also fixes a potential bug whereby the previous code was assuming that
the line must be #NO_APP\n.  The new patch allows whitespace after #APP or #NO_APP.

Ok to check in?

-- Jeff J.
Index: gas/input-file.c
RCS file: /cvs/src/src/gas/input-file.c,v
retrieving revision 1.7
diff -u -r1.7 input-file.c
--- gas/input-file.c	2001/08/01 01:44:25	1.7
+++ gas/input-file.c	2001/09/24 21:00:35
@@ -159,10 +159,20 @@
       if (c == 'N')
 	  fgets (buf, 80, f_in);
-	  if (!strcmp (buf, "O_APP\n"))
+	  if (!strncmp (buf, "O_APP", 5) && isspace(buf[5]))
 	    preprocess = 0;
 	  if (!strchr (buf, '\n'))
 	    ungetc ('#', f_in);	/* It was longer.  */
+	  else
+	    ungetc ('\n', f_in);
+	}
+      else if (c == 'A')
+        {
+	  fgets (buf, 80, f_in);
+	  if (!strncmp (buf, "PP", 2) && isspace(buf[2]))
+	    preprocess = 1;
+	  if (!strchr (buf, '\n'))
+	    ungetc ('#', f_in);
 	    ungetc ('\n', f_in);

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