JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2001

COMP-FORTRAN-90 2001

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

newline vs. linefeed

From:

Peter Shenkin <[log in to unmask]>

Reply-To:

Fortran 90 List <[log in to unmask]>

Date:

Fri, 30 Nov 2001 12:35:16 -0500

Content-Type:

TEXT/PLAIN

Parts/Attachments:

Parts/Attachments

TEXT/PLAIN (124 lines)

Hi,

Sorry, but newline and linefeed are indeed the same thing.
That's why the character coded for by dec 10 (hex 0a) is so often
abbreviated as "nl".

On the C compilation and C string issue, it is indeed the case
that *in a character string in the C program*, '\n' is an
abbreviation of this character -- ASCII dec 10 (hex 0a).  However,
this has nothing to do with how the string is stored in an
external file.  When writing to an external file, the '\n'
would be replaced by whatever the OS uses as a line separator.
When reading an external file, whatever the OS uses as a line
separator must be replaced with a '\n' (i.e., ASCII 10, hex 0a)
in the C string into which it is read.

There is an inherent lack of portability when reading into
a C program, on one OS, a so-called ascii file written out
on another OS.  The entire reason that ftp has an ascii mode
is to be able to convert the file from one OS's convention
to another.  But such differences in convention do not
apply to the representation of the string in the C program,
where '\n' must always mean ASCI dec 10, hex0a.

Thus, if an ASCI 10 winds up in a C string (e.g., by having
been passed from Fortran), then it will always start a new
line when output from C to the file system.

-P.

On Thu, 29 Nov 2001, Gary Scott wrote:

> Hi,
>
> Sorry to interrupt.  I would like to clarify that "newline" and "line
> feed" are not the same thing (I haven't been following this item so I
> hope this isn't too far out of scope).  Character 0A hex is "line
> feed".  This does not necessarily imply that following the advance to a
> new line that the "current position" is at the first character of a
> record.  That would happen according to ascii only following both a CR
> and an LF pair (I'm not sure there is an equivalent to newline in
> ASCII).  In EBCDIC, 15 hex is newline and 25 hex is line feed.
> Therefore, the standard should not refer to ACHAR(10) as "newline" but
> instead as "line feed".  I've never understood why systems don't use 1E
> hex (record separator) to separate text records as intended (other than
> to save space in text files).
>
> Van Snyder wrote:
> >
> > Thanks to Malcolm for looking in the C standard (and knowing better
> > than most of us where to look):L
> >
> > > (1) A conforming C compiler can use (practically) any control character
> > >     as "new-line" (their spelling).  Even when running in ASCII on Unix,
> > >     with all files stored as byte streams with ACHAR(10) as record
> > >     delimiters, if a compiler decided that it liked to use ACHAR(3) as
> > >     new-line, that would conform.
> >
> > I suspected this was true.
> >
> > > (2) Whatever choice the C compiler decided to use itself as "new-line"
> > >     makes no necessary difference to the files stored.  (This follows
> > >     from point 1).
> >
> > Also as I suspected.
> >
> > > Anyway, virtually all C programs that do such "naughty things" are
> > > already assuming that '\n'==10.
> > >
> > > Which brings me to my last point:
> > > (3) A C compiler that does something other than ACHAR(10) for '\n' does
> > >     not provide anything other than portability problems for its users.
> >
> > I do not see how one gets from (1) + (2) to (3) (except by arithmetic).
> > The problem isn't that \n might be different from ACHAR(10), but that
> > users assumed \n==10.  What's ICHAR(ACHAR(10)) on EBCDIC?  I suspect
> > it's not 10.  So users also assumed the character set was ASCII.
> >
> > > ... my recommendation is to "require that [a parameter in
> > > ISO_FORTRAN_ENV] be ACHAR(10)", as allowing this to vary would be to
> > > invite unnecessary portability problems.
> >
> > Exactly the same kind of portability problems as assuming KIND(0d0)==8.
> >
> > Requiring it to be ACHAR(10) militates against C interoperability,
> > unless we have TWO parameters, one to cause new-line when used in
> > formatted stream output, and one that represents \n for the purpose
> > of interoperating with C functions.  But why multiply mechanisms when
> > one will do?  This will just confuse users, especially those who are
> > primarily C programmers.
> >
> > I do not want to require any particular concrete value such as
> > ACHAR(10).  I prefer something similar to Kurt's proposal:
> >
> > a) define a CHARACTER(1) symbolic constant,
> > b) define the stream I/O requirements in terms of that constant, and
> > c) in the description of the constant, require that it be \n, whatever
> >    value that has in the companion processor.
> >
> > --
> > What fraction of Americans believe   |  Van Snyder
> > Wrestling is real and NASA is fake?  |  [log in to unmask]
> > Any alleged opinions are my own and have not been approved or disapproved
> > by JPL, CalTech, NASA, Dan Goldin, George Bush, the Pope, or anybody else.
>
>
> --
>
> Gary Scott
> mailto:[log in to unmask]
>
> mailto:[log in to unmask]
> http://www.fortranlib.com
>
> Support the GNU Fortran G95 Project:  http://g95.sourceforge.net
>

--
  Peter S. Shenkin                      Schrodinger, Inc.
  VP, Software Development              120 W. 45th St.
  646 366 9555 x111 Tel                 New York, NY 10036
  646 366 9550 FAX                      [log in to unmask]
                                        http://www.schrodinger.com

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager