RE: Backslash n [OT] was Line Separator and Paragraph Separator

From: Kent Karlsson (kentk@cs.chalmers.se)
Date: Fri Oct 24 2003 - 09:33:06 CST


> For completeness the definitions of \n and \r in C are:
>
> "\n (new line) Moves the active position to the initial
> position of the next line.

Hmm. If the output is to a terminal, and the OS is Unixy,
then to guarantee that behaviour, \n must generate both
a CR and an LF, not just an LF. Terminals can dynamically be
set in "raw" mode. Among other things, LF then stays LF,
and LF just moves one line down. In (default) "cooked" mode,
each LF is replaced by an LF and a CR (I don't recall the order)
by the tty driver.

But as far as I know, \n in C under Unixy systems just produce
an LF. And the compiler has no way of knowing at compile
time if the device will be in raw mode or "cooked" mode. So
producing just an LF for \n in C/Unix does not conform to
the C specification, since the output may be to a Unixy
terminal (or a Unixy lpr printer) in "raw" mode. Hmm...

        /kent k





This archive was generated by hypermail 2.1.5 : Thu Jan 18 2007 - 15:54:24 CST