diff --git a/module/mes/guile.mes b/module/mes/guile.mes index 4122c6d8..bd2f3bb4 100644 --- a/module/mes/guile.mes +++ b/module/mes/guile.mes @@ -71,8 +71,9 @@ (let ((tell 0) (end (string-length string))) (set! peek-char - (lambda () (if (= tell end) (integer->char -1) - (string-ref string (- tell 1))))) + (lambda () + (if (= tell end) (integer->char -1) + (string-ref string tell)))) (set! read-char (lambda () (if (= tell end) (integer->char -1) (begin diff --git a/tests/guile.test b/tests/guile.test index 4a3366be..0af3b35e 100755 --- a/tests/guile.test +++ b/tests/guile.test @@ -112,4 +112,9 @@ exit $? (push-input sp) (and (pop-input) (not (pop-input))))) +(pass-if-equal "with-input-from-string peek" + #\X + (with-input-from-string "X" + (lambda () (peek-char)))) + (result 'report)