Greg Chicares wrote:
>I always use '--binary' with 'patch'. Perhaps the
>default should be changed to '--binary' with ms
Yes, I think so. I'll maybe submit a patch.
>> For streams opened in text mode, fseek has limited use, because
>> carriage returnlinefeed translations can cause fseek to produce
>> unexpected results. The only fseek operations guaranteed to work
>> on streams opened in text mode are:
>> a.. Seeking with an offset of 0 relative to any of the origin values.
>> b.. Seeking from the beginning of the file with an offset value
>> from a call to ftell.
>C99 seems to say the same thing at 220.127.116.11/3 .
>In C, text streams are second-class citizens.
>J.2 says behavior is undefined when
> The fseek function is called for a text stream
> with a nonzero offset and either the offset was
> not returned by a previous successful call to
> the ftell function on a stream associated with
> the same file or whence is not SEEK_SET (18.104.22.168).
>But it looks like you've avoided that undefined
>behavior in your testcase:
> the_chaos = ftell(fp);
> fseek(fp, the_chaos, SEEK_SET);
>Doesn't item "b" quoted from the ms documentation
>above say that's guaranteed to work? Is this a
>defect in the msvc rtl?
Item "b" is a bit different, it says seeking from the
beginning of the file. The test case doesn't seek from
the beginning of the file.
On the other hand, if the test seeks from current location
to the beginning (case "a") and then from the beginning
to the location returned by ftell (case "b"), that should
work. This is maybe the solution :)