
Bug using UNIX file types
[snip]
There seems to be some controversy as to
whether the ANSI C standard library provides
for file streams to have binary or text modes.
Quote:
> I stand corrected. I've just perused the ANSI standards and to my
> surprise openning a file in text mode is not part of the standard.
I don't happen to have a copy of the ANSI C
standard here, but your statement is at odds
with a couple sources I do have. One is the
man entry for fopen() on my Linux system,
which states that fopen() accepts a "b" as
part of its second parameter "for compatibility
with ANSI C3.159-1989 (``ANSI C'')". The
other is the 2nd edition of "The C Programming
Language", by Brian W. Kernighan and Dennis
M. Ritchie which claims in its preface that it
"describes C as defined by the ANSI standard".
In its Appendix B, it states "This appendix is a
summary of the library defined by the ANSI
standard." Later, in section B1.1, fopen() is
said to take a final "b" in its second parameter
as indicating a binary file. Then, in section
B1.6, the fseek() functionality is said to depend
on whether it operates on a "binary file" or a
"text stream". (I posted this fact earlier, but
its relevance appears to have not struck with
sufficient force, yet.)
So, unless you are prepared to state that
these sources have incorrectly portrayed
those portions of the standard C library,
I think you have to allow that binary and
text mode are recognized in the standard.
I suspect your error is in not recognizing
that for streams, text mode is the default
unless overridden globally or per fopen()
with the "b" indicator. You should have
looked for binary mode, not text mode.
(And don't get hung up on Microsoft's
extension where a "t" indicator can be
used to locally override a global binary
mode override. The manner by which
a file gets into binary or text mode is
not particularly germane here.)
Quote:
> Since it's not in the standard, Microsoft can choose to implement
> this common language extension any way it sees fit, even if that
> way is different than the way many other compilers choose.
Nonsense. Both the ANSI C standard and the
ANSI/ISO C++ standard proscribe how variations
in newline representation are handled portably
among platforms. That is why both standards
describe binary and text mode operations.
Quote:
> Even if, under common circumstances, the results are unexpected
> and unusable, since there is not a defined standard for proper behavior,
> there is no bug.
I've been using both binary and text mode on
that platform for years, with the VC compiler
and others, always with results that were
expected, useful and usable.
Quote:
> Technically, there is no bug.
Technically and practically.
Quote:
> End of Thread.
Let's hope so.
--
--Larry Brasfield
Above opinions may be mine alone.