fix position counting in `read-byte'
Merge to 5.2.1
(cherry picked from commit c723aeeb6a
)
This commit is contained in:
parent
fd8230152d
commit
c59a7bd8b2
|
@ -717,6 +717,27 @@
|
||||||
(test t2 sync t2)
|
(test t2 sync t2)
|
||||||
(test oc sync/timeout 0 oc))
|
(test oc sync/timeout 0 oc))
|
||||||
|
|
||||||
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; eof should not advance port position
|
||||||
|
|
||||||
|
(let ()
|
||||||
|
(define (check read-byte)
|
||||||
|
(define-values (i o) (make-pipe))
|
||||||
|
(test 0 file-position i)
|
||||||
|
(write-byte 10 o)
|
||||||
|
(close-output-port o)
|
||||||
|
(test 0 file-position i)
|
||||||
|
(test 10 read-byte i)
|
||||||
|
(test 1 file-position i)
|
||||||
|
(test eof read-byte i)
|
||||||
|
(test 1 file-position i))
|
||||||
|
(check read-byte)
|
||||||
|
(check (lambda (i)
|
||||||
|
(define c (read-char i))
|
||||||
|
(if (char? c)
|
||||||
|
(char->integer c)
|
||||||
|
c))))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(report-errs)
|
(report-errs)
|
||||||
|
|
|
@ -3201,10 +3201,11 @@ static MZ_INLINE intptr_t get_one_byte(GC_CAN_IGNORE const char *who,
|
||||||
if (v == SCHEME_SPECIAL) {
|
if (v == SCHEME_SPECIAL) {
|
||||||
scheme_bad_time_for_special(who, port);
|
scheme_bad_time_for_special(who, port);
|
||||||
}
|
}
|
||||||
|
if (v != EOF) {
|
||||||
ip = (Scheme_Input_Port *)port; /* since ignored by GC */
|
ip = (Scheme_Input_Port *)port; /* since `ip is ignored by GC */
|
||||||
if (ip->p.position >= 0)
|
if (ip->p.position >= 0)
|
||||||
ip->p.position++;
|
ip->p.position++;
|
||||||
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user