From: Irma
Subject: carriage return in file stream
Date: 
Message-ID: <39a1e801$1@naylor.cs.rmit.edu.au>
Hi...

is there a function to determine whether the character that you read
from input-stream is a carriage return or not?
i know that there is a function for the eof bit... 

the reason why i need this is because i need to know the number
of current line in the input-stream that i'm currently reading.

thanks for the help

--
***********************************
   {}   Irma Sumera
  /^\   ·······@cs.rmit.edu.au
    /   3rd year Computer Science
   /    
   \..
***********************************

From: Rainer Joswig
Subject: Re: carriage return in file stream
Date: 
Message-ID: <joswig-851CDB.05254222082000@news.is-europe.net>
In article <··········@naylor.cs.rmit.edu.au>, ·······@cs.rmit.edu.au 
(Irma) wrote:

> Hi...
> 
> is there a function to determine whether the character that you read
> from input-stream is a carriage return or not?

Common Lisp has the concept of a character #\Newline.
See also chapter 13.1.8 of the Common Lisp Hyperspec.


? (with-input-from-string (s "a
b")
    (mapcar (lambda (char)
              (char= char #\Newline))
            (list (read-char s)
                  (read-char s)
                  (read-char s))))
(NIL T NIL)

-- 
Rainer Joswig, Hamburg, Germany
Email: ·············@corporate-world.lisp.de
From: Kent M Pitman
Subject: Re: carriage return in file stream
Date: 
Message-ID: <sfwhf8d508a.fsf@world.std.com>
·······@cs.rmit.edu.au (Irma) writes:

> is there a function to determine whether the character that you read
> from input-stream is a carriage return or not?
> i know that there is a function for the eof bit... 
> 
> the reason why i need this is because i need to know the number
> of current line in the input-stream that i'm currently reading.

As Rainer mentioned, if you're using READ-CHAR, you can check for 
#\Newline.

Most implementations also have a #\Return and #\Linefeed, even though
this is technically not fully standard; one of these is usually chosen
to be EQL to #\Newline, depending on the OS's end of line convention.
In some circumstances where you're doing character-level, you may get
both #\Return and #\Linefeed so you should beware.  

However, you can avoid all this in some cases by doing READ-LINE, which
will get you a line of text as a string, gobbling up the end of lines
whether they are Return, Linefeed, or Return+Linefeed, so that you just
see the stuff in between.  Whether you can get away with READ-LINE may be
determined by your application's high-level needs as well as some efficiency
issues that are particular to your implementation and that I'll try not to
go into here unless you get far enough that you have a working application
and you want to then separately look at the efficiency right.  Get the 
effect right first, THEN worry about efficiency if/when it turns out to 
matter.