RFC: line endings and specs parser

Per Bothner per@bothner.com
Sun Aug 8 21:26:00 GMT 1999


> 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:

You could always do the transformation in place - just use two
pointers into the same buffer.  You do an initial scan looking for
the first '\r':  If none is found, you're done;  otherwise, start
copying (in place) from there.

(I tend to prefer to do the processing "as you read" - i.e. whoever is
parsing the specs file should do handle any of the conventions.  However,
it can be difficult to do that cleanly, and often it is faster to do a pre-pass.)
-- 
	--Per Bothner
bothner@pacbell.net  per@bothner.com   http://home.pacbell.net/bothner/


More information about the Gcc mailing list