Clive Page said:
> On Wed, 28 Nov 2001, Van Snyder wrote:
>
> > In the present draft of the Fortran 2000 standard, ACHAR(10) is specified
> > to cause a new-line when output using stream access. But stream access
> > isn't available for internal files.
[...]
> My understanding (I hope
> someone will correct me if I'm wrong) is that "newline" means
>
> on Unix/Linux: LF i.e. achar(10)
> on Macintosh: CR i.e. achar(13)
> on Windows: CR LF i.e. achar(13) // achar(10)
As far as Fortran 2002, C89 and C99 are concerned, this is the
wrong viewpoint.
You are confusing the *internal representation* (what is in the character
string/variable) and the *external representation* (what is written to
the user's disc file or teletype or whatever).
On many older systems, there is no "newline" actually stored in disc or
tape files at all (the end-of-record is implicitly indicated by a record
length, not by in-band signalling).
This does not stop C from being successfully implemented on those
systems, nor does it stop them from being POSIX-compliant.
> unless the compiler does some clever substitutions. Does the Draft
> Standard really specify that?
The draft standard really does specify that.
The "clever substitutions" really are not difficult.
Note: We are talking "formatted stream i/o" here. There are lots of
seriously non-trivial conversions happening (e.g. for numeric data), the
conversion for newline here is pretty trivial in comparison with the
others.
> I've never used C except on Unix/Linux boxes, so have no idea what happens
> on other platforms: if you use "/n" does the C compiler indeed translate
> it into the appropriate character or pair of characters according to the
> platform, or is C as unportable as Fortran in this instance?
'\n' is a single character constant in C; that is to say that a C
compiler always translates it into a single character, never a "pair of
characters". Any necessary translations required by the operating
system (into zero, one, two or more characters) are performed by the i/o
library. (And additional translations may of course be performed by
device drivers, but that is an additional level below this one).
Cheers,
--
...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
([log in to unmask])
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
|