[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/08: emacs-build-system: Do not patch files containing NULs.
From: |
Ludovic Courtès |
Subject: |
04/08: emacs-build-system: Do not patch files containing NULs. |
Date: |
Mon, 5 Feb 2018 10:56:25 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 7c599eac0c26ea0cc61d711c5e777b893519e90c
Author: Maxim Cournoyer <address@hidden>
Date: Sun Jan 14 22:38:20 2018 -0500
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 <address@hidden>
---
guix/build/emacs-build-system.scm | 41 +++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/guix/build/emacs-build-system.scm
b/guix/build/emacs-build-system.scm
index a68ca60..b779847 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
- branch master updated (76dbb75 -> b1968d8), Ludovic Courtès, 2018/02/05
- 07/08: gnu: Add emacs-loc-changes., Ludovic Courtès, 2018/02/05
- 03/08: emacs-build-system: Reinstate the check phase., Ludovic Courtès, 2018/02/05
- 01/08: doc: Document the 'upstream-name' property., Ludovic Courtès, 2018/02/05
- 02/08: emacs-build-system: Add set-emacs-load-path phase., Ludovic Courtès, 2018/02/05
- 05/08: gnu: Add emacs-test-simple., Ludovic Courtès, 2018/02/05
- 04/08: emacs-build-system: Do not patch files containing NULs.,
Ludovic Courtès <=
- 06/08: gnu: Add emacs-load-relative., Ludovic Courtès, 2018/02/05
- 08/08: gnu: Add emacs-realgud., Ludovic Courtès, 2018/02/05