Report errors in the member file.
This commit is contained in:
parent
9a71545e3e
commit
39554768b3
4 changed files with 76 additions and 15 deletions
30
listing.scm
30
listing.scm
|
@ -26,7 +26,11 @@
|
|||
(declare (unit listing))
|
||||
|
||||
(module
|
||||
listing (print-source-listing listing-tests!)
|
||||
listing
|
||||
(
|
||||
print-source-listing
|
||||
listing-tests!
|
||||
)
|
||||
|
||||
(import scheme
|
||||
testing
|
||||
|
@ -59,18 +63,34 @@
|
|||
|
||||
;; Returns true if given line is near the target line.
|
||||
(define (line-near-target? line target context)
|
||||
(or (< context 0)
|
||||
(<= (abs (- line target)) context)))
|
||||
(let ((target-line (if (list? target)
|
||||
(car target)
|
||||
target)))
|
||||
(or (< context 0)
|
||||
(<= (abs (- line target-line)) context))))
|
||||
|
||||
;; Returns true if given line is near one of the target lines given.
|
||||
(define (line-near-targets? line targets context)
|
||||
(let loop ((targets targets))
|
||||
(if (null? targets)
|
||||
#f
|
||||
(< context 0)
|
||||
(if (line-near-target? line (car targets) context)
|
||||
#t
|
||||
(loop (cdr targets))))))
|
||||
|
||||
;; Returns true if given number is in highlights.
|
||||
(define (in-highlights? number highlights)
|
||||
(let loop ((highlights highlights))
|
||||
(if (null? highlights)
|
||||
#f
|
||||
(let* ((highlight (car highlights))
|
||||
(line-number (if (list? highlight)
|
||||
(car highlight)
|
||||
highlight)))
|
||||
(if (= number line-number)
|
||||
#t
|
||||
(loop (cdr highlights)))))))
|
||||
|
||||
;; Prints and highlights a selection of source listing lines and
|
||||
;; their optional context.
|
||||
(define (print-source-listing lines highlights context hl-pre hl-post ctx-pre ctx-post ellipsis)
|
||||
|
@ -80,7 +100,7 @@
|
|||
(printed-something #f)
|
||||
(was-printing #f))
|
||||
(when (not (null? lines))
|
||||
(let* ((content? (if (member number highlights) #t #f))
|
||||
(let* ((content? (in-highlights? number highlights))
|
||||
(context? (and (not content?)
|
||||
(line-near-targets? number highlights context)))
|
||||
(print? (or content? context?)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue