ldlex should use streams
Andreas Jaeger
aj@suse.de
Fri Jan 25 05:54:00 GMT 2002
Ian Lance Taylor <ian@airs.com> writes:
> Andreas Jaeger <aj@suse.de> writes:
>
>> @@ -595,7 +595,7 @@
>> {
>> if (yyin)
>> {
>> - *result = read (fileno (yyin), (char *) buf, max_size);
>> + *result = fread ((char *) buf, 1, max_size, yyin);
>> if (*result < 0)
>> einfo ("%F%P: read in flex scanner failed\n");
>> }
>
> If you change read to fread, you have to change the error check.
> fread will never return a negative value. You have to check for a
> short count, and use ferror.
You're right - thanks.
I've committed the appended patch after testing it on i686-linux,
Andreas
2002-01-25 Andreas Jaeger <aj@suse.de>
* ldlex.l (yy_input): Correct error check.
Index: ld/ldlex.l
===================================================================
RCS file: /cvs/src/src/ld/ldlex.l,v
retrieving revision 1.9
diff -u -p -r1.9 ldlex.l
--- ldlex.l 2002/01/21 19:53:44 1.9
+++ ldlex.l 2002/01/25 13:03:46
@@ -596,7 +596,7 @@ yy_input (buf, result, max_size)
if (yyin)
{
*result = fread ((char *) buf, 1, max_size, yyin);
- if (*result < 0)
+ if (*result < max_size && ferror (yyin))
einfo ("%F%P: read in flex scanner failed\n");
}
}
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
More information about the Binutils
mailing list