FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version

eol-convention

Arguments: stream

This function queries the stream's external-format to obtain information on the end-of-line convention being used. It returns two values: a symbol indicating the end-of-line convention and an external-format.

The first returned value is one of the following values:

The nature of the second returned value depends on whether stream's external format is or is not a composed external format. If stream's external format is not a composed external format (i.e. the first returned value is :unix), stream's external format is returned as the second returned value. If stream's external format is a composed external format, the second returned value is the composee (which translates Lisp characters to octets) external format. This allows easy construction of a new composed external format based on stream's, if desired. Composed external formats are described in Composed External-Formats.

You can change the end-of-line convention using setf and this function. Specify one of the keywords specified above as the first return value or specify the keyword :anynl. When you specify :anynl, no change is made if the first return value is :anynl-unix, :anynl-dos, or :anynl-mac, and :unix is changed to :anynl-unix, :dos is changed to :anynl-dos, and :mac is changed to :anynl-mac (and the second returned value is changed appropriately).

The :anynl value allows you to have streams read files using any standard end of line convention while still writing files using the machine-appropriate convention. This makes importing files for input much easier.

Modifying the external format of a stream

The eol-convention of a stream may be modified if you explicitly set the external format of a stream and so you may have to reset the eol-convention to the desired value.

Examples

[On Windows]
 (setq s (open "c:/autoexec.bat")) -> stream
 
 ;; The stream is currently set to read/write Ascii 13 followed by Ascii 10
 ;; as/for #\newline.
 (eol-convention s) -> :dos #<external-format ...>
 
 ;; Set the stream so that it reads/writes Ascii 13 as/for #\newline
 (setf (eol-convention s) :mac) -> :mac #<external-format ...>

 ;; Set the stream so that it reads/writes Ascii 10 as/for #\newline
 (setf (eol-convention s) :unix) -> :unix #<external-format ...>

 [On Unix]
 (setq s (open "/etc/passwd"))

 ;; The stream is currently set to read/write Ascii 10 as/for #\newline
 (eol-convention s) -> :unix #<external-format ...>

 ;; Set the stream so that it reads/writes Ascii 13 followed by
 ;; Ascii 10 as/for #\newline.
 (setf (eol-convention s) :dos) -> :dos #<external-format ...>
 
 ;; Set the stream so that it reads/writes Ascii 13 as/for #\newline
 (setf (eol-convention s) :mac) -> :mac #<external-format ...>


 ;; Set the stream so that it reads any standard end of line
 ;; and writes Ascii 13 for #\newline
 (setf (eol-convention s) :anynl-mac) -> :anynl-mac #<external-format ...>

 ;; Set the stream to the UNIX default
 (setf (eol-convention s) :unix)
 ;; Set the stream so that it reads any standard end of line
 ;; and writes Ascii 10 for #\newline
 (setf (eol-convention s) :anynl) -> :anynl-unix #<external-format ...>

See also #\newline discussion.


Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version