Jari Salminen writes:
> 
> I'm not aware of any such file system like you mentioned (that would *add*
> LF to the lines), but would those be the ones which use the section "#ifdef
> BROKEN_READWRITE_CONVERSION" in that same send_modified() function?

No.  BROKEN_READWRITE_CONVERSION means that read() and write() do not
handle text file conversion the way fread() and fwrite() are required
to.  This is a complete separate issue from whether st_size

> Another thing: you said that "the file size returned by *fstat*". If the
> *fstat* is the problem, what about if this log file operation would use
> CVS_STAT instead (which uses *stat*)? After all, the code already uses
> CVS_OPEN right before fstat?

No, the problem is with stat() functions in general: naieve Unix (and
DOS and Windows) programmers tend to believe that st_size *is* the size
of the file; experienced Unix programmers (and people with lots of
experience on radically different systems) know better.

> At least the CVS_STAT should work correctly! Otherwise in subr.c the
> get_file() function (which is called by RCS_checkin() function, the very
> heart of whole CVS!) would be in trouble! It does
> 
>   if (CVS_STAT (name, &s) < 0)
> 
> and would use the value from s.st_size to reallocate the buffer to where it
> read the file. The file system, that would LF in the lines, would fail here
> anyway ...

On the contrary, get_file() only uses st_size as an *estimate* of the
size of the buffer.  It reads and reallocates the buffer as required
until it reaches end-of-file, which is exactly the right thing to do. 
I've changed the log file code to use it and to read the log file in
text mode.

> During my "research" I also find yet another case: do_editor() function in
> logmsg.c uses also CVS_STAT and does
> 
>   /* On NT, we might read less than st_size bytes, but we won't
>      read more.  So this works.  */
>      *messagep = (char *) xmalloc (post_stbuf.st_size + 1);
> 
> Although this is perhaps too "NT" specific comment, wouldn't this part of
> the code be already broken in those file system that add LF into the lines?

Yep, it's broken, all right.  It's filtering the file while it's reading
it, so you can't just use get_file() instead, but it wouldn't be too
hard to reallocate the buffer as required.  Perhaps I'll get to it some
day.

-Larry Jones

I take it there's no qualifying exam to be a Dad. -- Calvin

Reply via email to