boot: Bugfix for diff on mes.

* scripts/diff.scm (diff-files): Rename from diff; Avoids name clash
  with module to allow using -e '(<module>)' hack.
This commit is contained in:
Jan Nieuwenhuizen 2018-05-23 09:24:52 +02:00
parent a4110e55bb
commit 6ab7d2cee7
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -73,8 +73,7 @@ exec ${MES-mes} -L $(dirname 0) -e '(diff)' -s "$0" "$@"
(define (line-equal? a b) (define (line-equal? a b)
(equal? (string-trim-right a) (string-trim-right b))) (equal? (string-trim-right a) (string-trim-right b)))
;; naive diff (define (diff-files a b)
(define (diff a b)
(let ((a-lines (string-split (with-input-from-file a read-string) #\newline)) (let ((a-lines (string-split (with-input-from-file a read-string) #\newline))
(b-lines (string-split (with-input-from-file b read-string) #\newline))) (b-lines (string-split (with-input-from-file b read-string) #\newline)))
(let loop ((context '(1 1 #f #f #f)) (a-lines a-lines) (b-lines b-lines)) (let loop ((context '(1 1 #f #f #f)) (a-lines a-lines) (b-lines b-lines))
@ -116,7 +115,7 @@ exec ${MES-mes} -L $(dirname 0) -e '(diff)' -s "$0" "$@"
(define (main args) (define (main args)
(let* ((files (cdr args)) (let* ((files (cdr args))
(files (if (string-prefix? "-" (car files)) (cdr files) files)) (files (if (string-prefix? "-" (car files)) (cdr files) files))
(hunks (apply diff (list-head files 2)))) (hunks (apply diff-files (list-head files 2))))
(when (pair? hunks) (when (pair? hunks)
(display (string-join (append-map hunk->lines hunks) "\n")) (display (string-join (append-map hunk->lines hunks) "\n"))
(newline) (newline)