This is the mail archive of the
mailing list for the binutils project.
Problem with -f option and #APP
- To: binutils at sources dot redhat dot com
- Subject: Problem with -f option and #APP
- From: "J. Johnston" <jjohnstn at cygnus dot com>
- Date: Mon, 24 Sep 2001 17:08:59 -0400
- Organization: Red Hat Inc.
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.
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))
preprocess = 0;
if (!strchr (buf, '\n'))
ungetc ('#', f_in); /* It was longer. */
+ ungetc ('\n', f_in);
+ else if (c == 'A')
+ fgets (buf, 80, f_in);
+ if (!strncmp (buf, "PP", 2) && isspace(buf))
+ preprocess = 1;
+ if (!strchr (buf, '\n'))
+ ungetc ('#', f_in);
ungetc ('\n', f_in);