[Top][All Lists]

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

01/01: list-runtime-root: Fix off-by-one in 'strip-drop' call.

From: Ludovic Courtès
Subject: 01/01: list-runtime-root: Fix off-by-one in 'strip-drop' call.
Date: Sun, 31 Dec 2017 05:18:39 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 091191c3dcbfb9f01070d26bf15cb2c4dd07b1b5
Author: Ludovic Courtès <address@hidden>
Date:   Sun Dec 31 11:15:24 2017 +0100

    list-runtime-root: Fix off-by-one in 'strip-drop' call.
    Fixes <>.
    Reported by Danny Milosavljevic <address@hidden>.
    * nix/scripts/ (canonicalize-store-item): Define
    'store' with a trailing "/".  Have the 'string-prefix?' call match the
    'string-drop' call.
 nix/scripts/ | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/nix/scripts/ 
index 48a07ed..5f2660f 100644
--- a/nix/scripts/
+++ b/nix/scripts/
@@ -130,12 +130,13 @@ or the empty list."
                          (< (string->number a) (string->number b))))))
 (define canonicalize-store-item
-  (let ((prefix (+ 1 (string-length %store-directory))))
+  (let* ((store  (string-append %store-directory "/"))
+         (prefix (string-length store)))
     (lambda (file)
       "Return #f if FILE is not a store item; otherwise, return the store file
 name without any sub-directory components."
-      (and (string-prefix? %store-directory file)
-           (string-append %store-directory "/"
+      (and (string-prefix? store file)
+           (string-append store
                           (let ((base (string-drop file prefix)))
                             (match (string-index base #\/)
                               (#f    base)

reply via email to

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