RFC: line endings and specs parser
Mumit Khan
khan@xraylith.wisc.EDU
Sun Aug 8 20:26:00 GMT 1999
Now that GCC is slowly but surely moving towards dealing with the various
types of EOLs (thanks Zack!), what do folks think about fixing specs parser
to do the same?
The problem is that the gcc.c:read_specs() doesn't use stdio to read the
file, so all the usual conversions don't happen.
My first attempt was to do graft it on top of existing code, but the code
became extremely hard to read.
My second attempt worked much better, but at the expense of a bit of
memory and some processing overhead. After reading the specs using
read(), I allocate a 2nd buffer, copy the 1st onto 2nd using the
following simple logic:
for each character in input buffer,
- if '\r', transform to '\n'.
- if next character is '\n', advance input pointer (ie, just skip).
- copy to output buffer
This should handle EOL styles of \n, \r\n and \r.
Comments? Is this worth it?
Regards,
Mumit
More information about the Gcc
mailing list