mes: #<eof> is not a character.
* module/mes/display.mes (display): * module/mes/type-0.mes (char?): -1 is not a character. (eof-object?): New function. * tests/base.test ("#<eof>"): Test it. * module/mes/scm.mes (eof-object?): Remove. (unread-char): Return character (WAS: integer).
This commit is contained in:
parent
0e06928320
commit
cab272a101
|
@ -1,7 +1,7 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2017,2018 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of Mes.
|
||||
;;;
|
||||
|
@ -62,10 +62,11 @@
|
|||
(define (d x cont? sep)
|
||||
(for-each (cut write-char <> port) (string->list sep))
|
||||
(cond
|
||||
((eof-object? x)
|
||||
(display "#<eof>" port))
|
||||
((char? x)
|
||||
(if (not write?) (write-char x port)
|
||||
(let ((name (and=> (assq x '((#\*eof* . *eof*)
|
||||
(#\nul . nul)
|
||||
(let ((name (and=> (assq x '((#\nul . nul)
|
||||
(#\alarm . alarm)
|
||||
(#\backspace . backspace)
|
||||
(#\tab . tab)
|
||||
|
|
|
@ -82,10 +82,6 @@
|
|||
|
||||
(define integer? number?)
|
||||
|
||||
(define (eof-object? x)
|
||||
(or (and (number? x) (= x -1))
|
||||
(and (char? x) (eof-object? (char->integer x)))))
|
||||
|
||||
(if (not (defined? 'peek-char))
|
||||
(define (peek-char)
|
||||
(integer->char (peek-byte))))
|
||||
|
@ -96,7 +92,7 @@
|
|||
|
||||
(if (not (defined? 'unread-char))
|
||||
(define (unread-char c)
|
||||
(unread-byte (char->integer c))))
|
||||
(integer->char (unread-byte (char->integer c)))))
|
||||
|
||||
(define (assq-set! alist key val)
|
||||
(let ((entry (assq key alist)))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2017,2018 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of Mes.
|
||||
;;;
|
||||
|
@ -62,7 +62,12 @@
|
|||
(cond ((assq (core:type x) cell:type-alist) => cdr)))
|
||||
|
||||
(define (char? x)
|
||||
(eq? (core:type x) <cell:char>))
|
||||
(and (eq? (core:type x) <cell:char>)
|
||||
(>= (char->integer x) 0)))
|
||||
|
||||
(define (eof-object? x)
|
||||
(and (eq? (core:type x) <cell:char>)
|
||||
(= (char->integer x) -1)))
|
||||
|
||||
(define (closure? x)
|
||||
(eq? (core:type x) <cell:closure>))
|
||||
|
|
|
@ -9,7 +9,7 @@ exit $?
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2018 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of Mes.
|
||||
;;;
|
||||
|
@ -110,4 +110,8 @@ exit $?
|
|||
(begin (set! seen? #t)
|
||||
(cont 2)))))
|
||||
|
||||
(if (not guile?)
|
||||
(pass-if-not "#<eof>"
|
||||
(char? (integer->char -1))))
|
||||
|
||||
(result 'report)
|
||||
|
|
Loading…
Reference in a new issue