scsh-users
[Top] [All Lists]

Can't Rewind Regular File After `read-char'

To: scsh-bugs@martigny.ai.mit.edu
Subject: Can't Rewind Regular File After `read-char'
From: Victor C Zandy <zandy@cedar.buffalo.edu>
Date: Wed, 8 Mar 1995 22:52:14 -0500
    Using scsh-0.3 on sparc-sun-sunos4.1.3.

    When reading from a port returned from `open-input-file' (on a
regular file), I cannot use `file-seek' to rewind the file once I've
done a `read-char' on the port, although I seem to be able to rewind
to my heart's content if I use `read-string' (prior to the first call
to `read-char').  The sample interaction below illustrates this.

    test is a file containing the string "abcdefghijklmnop"

> (define test-port (open-input-file "test"))
> (read-string 2 test-port)
"ab"
> (read-string 2 test-port)
"cd"
> (file-seek test-port 0 seek/set)
0
> (read-string 2 test-port)
"ab"
> (read-string 2 test-port)
"cd"
> (read-char test-port)
#\a
> (file-seek test-port 0 seek/set)
0
> (read-char test-port)
#\b
> (read-string 2 test-port)
"cd"
> (file-seek test-port 0 seek/set)
0
> (read-string 2 test-port)
"ef"


Thanks,
Vic

<Prev in Thread] Current Thread [Next in Thread>