rnews
Russ Allbery
rra at stanford.edu
Tue Nov 7 07:40:18 UTC 2000
Matt McLeod <matt at boggle.org> writes:
> The obvious solution to me would be to stick something in
> ReadRemainder() to throw out any \r it finds. My C is rusty, but I'm
> happy to give it a go (though the result will probably not be too
> pretty). The "easy" way, I guess, would be to change ReadRemainder() so
> it only ever reads a single character at a time, then look at that
> character and junk it if it's a \r. But presumably that would not be
> nice for performance, so something more complicated is probably in
> order.
Of roughly equivalent ease, and probably offering better performance
assuming a decent stdio implementation, would be to switch from fread to
fgets, check the second-to-last character after fgets to see if it's \r,
and if so write a \n over it and back up the buffer pointer by one so that
the next fgets overwrites the old \n.
This will be slightly slower than the current fread implementation, but I
doubt that in-memory processing of articles in rnews is going to be a
significant performance bottleneck in any modern server.
Alternately, and *possibly* better, one could fix NNTPsendarticle, which
is what rnews eventually ends up calling, in lib/sendarticle.c so that it
doesn't add the CR if lines already end in CRLF. That looks like it would
be pretty straightforward. I'm not sure if that would end up corrupting
articles that actually really did have a CR before their line terminator,
though, under some suck and repost circumstances, and if so whether we
actually care....
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
More information about the inn-workers
mailing list