mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
bounds check for parse-stream-debug-info on empty input (fixes issue #826)
This commit is contained in:
parent
899a6bace3
commit
d4eb32f8b1
2 changed files with 14 additions and 10 deletions
|
@ -21,6 +21,7 @@
|
|||
|
||||
(test-not (parse parse-nothing ""))
|
||||
(test-not (parse parse-nothing "a"))
|
||||
(test-error (parse-fully parse-nothing ""))
|
||||
|
||||
(test-not (parse (parse-char #\a) ""))
|
||||
(test-assert (parse-fully (parse-char #\a) "a"))
|
||||
|
|
|
@ -167,16 +167,19 @@
|
|||
;; location
|
||||
(if (%parse-stream-tail s)
|
||||
(parse-stream-debug-info (%parse-stream-tail s) i)
|
||||
(let* ((line-info
|
||||
(parse-stream-count-lines s (parse-stream-max-char s)))
|
||||
(line (+ (parse-stream-line s) (car line-info)))
|
||||
(col (if (zero? (car line-info))
|
||||
(+ (parse-stream-column s) (cadr line-info))
|
||||
(cadr line-info)))
|
||||
(from (car (cddr line-info)))
|
||||
(to (parse-stream-end-of-line s (+ from 1)))
|
||||
(str (parse-stream-substring s from s to)))
|
||||
(list line col str))))
|
||||
(let ((max-char (parse-stream-max-char s)))
|
||||
(if (< max-char 0)
|
||||
(list 0 0 "")
|
||||
(let* ((line-info
|
||||
(parse-stream-count-lines s max-char))
|
||||
(line (+ (parse-stream-line s) (car line-info)))
|
||||
(col (if (zero? (car line-info))
|
||||
(+ (parse-stream-column s) (cadr line-info))
|
||||
(cadr line-info)))
|
||||
(from (car (cddr line-info)))
|
||||
(to (parse-stream-end-of-line s (+ from 1)))
|
||||
(str (parse-stream-substring s from s to)))
|
||||
(list line col str))))))
|
||||
|
||||
(define (parse-stream-next-source source i)
|
||||
(if (>= (+ i 1) (vector-length (parse-stream-buffer source)))
|
||||
|
|
Loading…
Add table
Reference in a new issue