guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/10: utils: 'version-compare' delays 'dynamic-link' code.


From: guix-commits
Subject: 01/10: utils: 'version-compare' delays 'dynamic-link' code.
Date: Sun, 5 Jan 2020 05:51:31 -0500 (EST)

civodul pushed a commit to branch wip-system-bootstrap
in repository guix.

commit 3e480b17c73b4e0a86f1323cdaf2dcbbcf723df1
Author: Ludovic Court├Ęs <address@hidden>
Date:   Fri Dec 6 23:07:13 2019 +0100

    utils: 'version-compare' delays 'dynamic-link' code.
    
    * guix/utils.scm (version-compare): Delay 'strverscmp' and force it when
    called.
---
 guix/utils.scm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/guix/utils.scm b/guix/utils.scm
index 728039f..b3aacfa 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -508,14 +508,17 @@ a character other than '@'."
 
 (define version-compare
   (let ((strverscmp
-         (let ((sym (or (dynamic-func "strverscmp" (dynamic-link))
-                        (error "could not find `strverscmp' (from GNU 
libc)"))))
-           (pointer->procedure int sym (list '* '*)))))
+         ;; Delay symbol resolution so that this module can be used even on a
+         ;; statically-linked Guile.
+         (delay
+           (let ((sym (or (dynamic-func "strverscmp" (dynamic-link))
+                          (error "could not find `strverscmp' (from GNU 
libc)"))))
+             (pointer->procedure int sym (list '* '*))))))
     (lambda (a b)
       "Return '> when A denotes a newer version than B,
 '< when A denotes a older version than B,
 or '= when they denote equal versions."
-      (let ((result (strverscmp (string->pointer a) (string->pointer b))))
+      (let ((result ((force strverscmp) (string->pointer a) (string->pointer 
b))))
         (cond ((positive? result) '>)
               ((negative? result) '<)
               (else '=))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]