aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2018-01-14 22:38:20 -0500
committerLudovic Courtès <ludo@gnu.org>2018-02-05 16:54:27 +0100
commit7c599eac0c26ea0cc61d711c5e777b893519e90c (patch)
tree33971bd846bbf41e6533deb55eb13a10cede3fb0
parent58b6812fd4c480bc3ef07934c5967d18a2992292 (diff)
downloadguix-7c599eac0c26ea0cc61d711c5e777b893519e90c.tar
guix-7c599eac0c26ea0cc61d711c5e777b893519e90c.tar.gz
emacs-build-system: Do not patch files containing NULs.
This is a temporary workaround for <https://bugs.gnu.org/30116>, where 'substitute*' throws on files containing NUL characters. * guix/build/emacs-build-system.scm (patch-el-files): Filter out elisp files that contain NUL characters. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--guix/build/emacs-build-system.scm41
1 files changed, 29 insertions, 12 deletions
diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-system.scm
index a68ca60c7e..b779847424 100644
--- a/guix/build/emacs-build-system.scm
+++ b/guix/build/emacs-build-system.scm
@@ -97,23 +97,40 @@ archive, a directory, or an Emacs Lisp file."
(define* (patch-el-files #:key outputs #:allow-other-keys)
"Substitute the absolute \"/bin/\" directory with the right location in the
store in '.el' files."
+
+ (define (file-contains-nul-char? file)
+ (call-with-input-file file
+ (lambda (in)
+ (let loop ((line (read-line in 'concat)))
+ (cond
+ ((eof-object? line) #f)
+ ((string-index line #\nul) #t)
+ (else (loop (read-line in 'concat))))))
+ #:binary #t))
+
(let* ((out (assoc-ref outputs "out"))
(elpa-name-ver (store-directory->elpa-name-version out))
(el-dir (string-append out %install-suffix "/" elpa-name-ver))
- (substitute-cmd (lambda ()
- (substitute* (find-files "." "\\.el$")
- (("\"/bin/([^.]\\S*)\"" _ cmd-name)
- (let ((cmd (which cmd-name)))
- (unless cmd
- (error
- "patch-el-files: unable to locate " cmd-name))
- (string-append "\"" cmd "\"")))))))
+
+ ;; (ice-9 regex) uses libc's regexp routines, which cannot deal with
+ ;; strings containing NULs. Filter out such files. TODO: Remove
+ ;; this workaround when <https://bugs.gnu.org/30116> is fixed.
+ (el-files (remove file-contains-nul-char?
+ (find-files (getcwd) "\\.el$"))))
+ (define (substitute-program-names)
+ (substitute* el-files
+ (("\"/bin/([^.]\\S*)\"" _ cmd-name)
+ (let ((cmd (which cmd-name)))
+ (unless cmd
+ (error "patch-el-files: unable to locate " cmd-name))
+ (string-append "\"" cmd "\"")))))
+
(with-directory-excursion el-dir
- ;; Some old '.el' files (e.g., tex-buf.el in AUCTeX) are still encoded
- ;; with the "ISO-8859-1" locale.
- (unless (false-if-exception (substitute-cmd))
+ ;; Some old '.el' files (e.g., tex-buf.el in AUCTeX) are still
+ ;; ISO-8859-1-encoded.
+ (unless (false-if-exception (substitute-program-names))
(with-fluids ((%default-port-encoding "ISO-8859-1"))
- (substitute-cmd))))
+ (substitute-program-names))))
#t))
(define* (install #:key outputs