Re: unread more than one char



On Mon, 08 Oct 2007 16:38:08 -0400, Alberto Riva <ariva@xxxxxxxxxxxxxx> wrote:

What about:

(defun stream-backup (stream n)
(file-position stream
(- (file-position stream) n)))

The standard doesn't require streams to be able to represent the
notion of file position, i.e. what FILE-POSITION returns could be NIL,
or trying to change the file position doesn't have to succeed.

Also it says (in the FILE-POSITION dictionary entry) that for "a
character file, performing a single READ-CHAR or WRITE-CHAR operation
may cause the file position to be increased by more than 1."

Edi.

--

Lisp is not dead, it just smells funny.

Real email: (replace (subseq "spamtrap@xxxxxxxxxx" 5) "edi")
.



Relevant Pages

  • Re: NEWBIE: Read/write IO (Random Access)/:overwrite- replace?
    ... > Is there any way to reset the position of the 'read' on the stream, ... the HyperSpec definition of file-position and file position designator ... (file-position stream 5) ... I read a character from the stream and printed it out. ...
    (comp.lang.lisp)
  • [JW] file position indicater after appending
    ... Suppose that there is only one stream associated with a file, that is, ... What's the value of the file position indicator after writing ... The standard does not consider multiple C programs running ...
    (comp.std.c)
  • Re: Reading whole text files
    ... The ftell function ... file position indicator for the stream pointed to by stream. ...
    (comp.lang.c)
  • StreamReader bug?
    ... position of the current stream using the base stream's Seek method. ... The following code exhibits the behavior I am describing when compiled and ... File position is 0. ... If tracing through the code in debug mode, the second peek returns -1. ...
    (microsoft.public.dotnet.framework)
  • seekp() sets failbit OR streampos::operator+() fails after 2GB. Why ?
    ... /* This program advances the file position after 2GB, ... seekpsets failbit to the stream. ... cout << endl; ...
    (microsoft.public.vc.stl)