YANAGAWA Kazuhisa graced us by uttering:
For ANSI-C compliance. From fopen(3) of FreeBSD 4.8-RELEASE:
The mode string can also include the letter ``b'' either
as a third char- acter or as a character between the
characters in any of the two-charac- ter strings described
above. This is strictly for compatibility with ISO/IEC
9899:1990 (``ISO C89'') and has no effect; the ``b'' is
ignored.
I believe most of Unix like platforms stand on a similar
position.
fopen(3) on my Debian box adds:
[…]; the b'' is ignored on all POSIX conforming systems, including Linux. (Other systems may treat text files and binary files differently, and adding the
b’’ may be a good
idea if you do I/O to a binary file and expect that your
program may be ported to non-Unix environments.)
If the POSIX standard dictates that ‘b’ is ignored, it must also
dictate that binary and text files are treated identically, no?
[…checking…]
Correct. From the POSIX spec
http://www.opengroup.org/onlinepubs/007904975/toc.htm:
The character 'b' shall have no effect, but is allowed for
ISO C standard conformance.
(That’s the subjunctive mood, so any implementation that is
affected by the ‘b’ flag is not POSIX compliant.)
And from dmr’s “The UNIX Time-Sharing System” (C)1974
http://cm.bell-labs.com/cm/cs/who/dmr/cacm.html:
III. THE FILE SYSTEM
3.1 Ordinary files
A file contains whatever information the user places on it,
for example, symbolic or binary (object) programs. No
particular structuring is expected by the system. A file of
text consists simply of a string of characters, with lines
demarcated by the newline character. Binary programs are
sequences of words as they will appear in core memory when
the program starts executing. A few user programs manipulate
files with more structure; for example, the assembler
generates, and the loader expects, an object file in a
particular format. However, the structure of files is
controlled by the programs that use them, not by the system.
This seems to be a CPM/DOS/Win32 issue.
Cheers,
Tim Hammerquist
···
–
Did I mention that I can’t tell you how to get rich?
If I could, I’d be rich, and not here.
– Martien Verbruggen in comp.lang.perl.misc