[Cmake] Buffer overflows
Brad King
brad.king at kitware.com
Fri Jun 22 12:21:48 EDT 2001
> I'm not sure that reading character-by-character, especially using the
> stream iterators, is any less efficient. There isn't (shouldn't be) a
> disk access per iterator dereference, since these are buffered
> streams, and copying from one stream's buffer directly to the other
> stream's buffer seems more efficient that reading into a temporary
> buffer first. However, this does imply doing things like
> fin.setf(ios::skipws), or, according to the standard,
> fin.setf(ios_base::skipws). Maybe it's best to avoid such issues.
I doubt the compiler will generate code from that std::copy with iterators
that runs as fast as the pre-compiled (assembly?) implementation of the
standard library's getline.
> Anyway, I guess the simplest solution is just to check for fin.fail()
> after the readline, and reset the flag if it does happen.
I have just checked in code that uses an approach like this. I had
written it this morning, but cmake's repository has been broken for a few
hours so I couldn't compile and test it until just now. The new code can
copy any file even with a 2 byte buffer.
-Brad
More information about the CMake
mailing list