mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
restoring efficient read-line
This commit is contained in:
parent
e9ce08da78
commit
ef0a8bd199
3 changed files with 24 additions and 18 deletions
|
@ -75,9 +75,11 @@
|
|||
;;> a string not including the newline. Reads at most \var{n}
|
||||
;;> characters, defaulting to 8192.
|
||||
|
||||
(cond-expand
|
||||
((not string-streams)
|
||||
(define (%read-line n in)
|
||||
(define (%read-line n in)
|
||||
(cond
|
||||
((port-fileno in)
|
||||
(%%read-line n in))
|
||||
(else
|
||||
(let ((out (open-output-string)))
|
||||
(let lp ((i 0))
|
||||
(let ((ch (peek-char in)))
|
||||
|
@ -128,9 +130,11 @@
|
|||
;;> than \var{n} characters if the end of file is reached,
|
||||
;;> or the eof-object if no characters are available.
|
||||
|
||||
(cond-expand
|
||||
((not string-streams)
|
||||
(define (%read-string n in)
|
||||
(define (%read-string n in)
|
||||
(cond
|
||||
;;((port-fileno in)
|
||||
;; (%%read-string n in))
|
||||
(else
|
||||
(let ((out (open-output-string)))
|
||||
(let lp ((i 0))
|
||||
(cond ((or (= i n) (eof-object? (peek-char in)))
|
||||
|
@ -159,9 +163,11 @@
|
|||
;;> An error is signalled if the length of \var{str} is smaller
|
||||
;;> than \var{n}.
|
||||
|
||||
(cond-expand
|
||||
((not string-streams)
|
||||
(define (%read-string! str n in)
|
||||
(define (%read-string! str n in)
|
||||
(cond
|
||||
;;((port-fileno in)
|
||||
;; (%%read-string! str n in))
|
||||
(else
|
||||
(let lp ((i 0))
|
||||
(cond ((or (= i n) (eof-object? (peek-char in))) i)
|
||||
(else (string-set! str i (read-char in)) (lp (+ i 1))))))))
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
|
||||
(cond-expand
|
||||
(string-streams
|
||||
(define-c non-null-string (%read-line "fgets")
|
||||
((result (array char arg1)) int (default (current-input-port) input-port)))
|
||||
(define-c non-null-string (%%read-line "fgets")
|
||||
((result (array char arg1)) int (default (current-input-port) input-port)))
|
||||
|
||||
(define-c size_t (%read-string "fread")
|
||||
((result (array char (result arg2))) (value 1 size_t) size_t (default (current-input-port) input-port)))
|
||||
;;(define-c size_t (%%read-string "fread")
|
||||
;; ((result (array char (result arg2))) (value 1 size_t) size_t (default (current-input-port) input-port)))
|
||||
|
||||
(define-c size_t (%read-string! "fread")
|
||||
(string (value 1 size_t) size_t (default (current-input-port) input-port)))
|
||||
))
|
||||
;;(define-c size_t (%%read-string! "fread")
|
||||
;; (string (value 1 size_t) size_t (default (current-input-port) input-port)))
|
||||
|
||||
(c-include-verbatim "port.c")
|
||||
|
||||
|
|
3
sexp.c
3
sexp.c
|
@ -482,6 +482,9 @@ static const char* sexp_initial_features[] = {
|
|||
#if SEXP_USE_UTF8_STRINGS
|
||||
"full-unicode",
|
||||
#endif
|
||||
#if SEXP_USE_STRING_INDEX_TABLE
|
||||
"string-index",
|
||||
#endif
|
||||
#if SEXP_USE_GREEN_THREADS
|
||||
"threads",
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue