* [PATCH] Work around behavior of old 'scandir' in Guile 2.0.5
@ 2014-04-06 23:55 Mark H Weaver
2014-04-07 7:42 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Mark H Weaver @ 2014-04-06 23:55 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 69 bytes --]
This patch is needed when Guix is built with Guile 2.0.5.
Mark
[-- Attachment #2: [PATCH] Work around behavior of old 'scandir' in Guile 2.0.5 --]
[-- Type: text/x-patch, Size: 2409 bytes --]
From a49c33418aa6814daf6fcab5978c27afbfe8ac9a Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Sun, 6 Apr 2014 19:46:16 -0400
Subject: [PATCH] Work around behavior of old 'scandir' in Guile 2.0.5.
Problem reported by John Darrington <john@darrington.wattle.id.au>.
* guix/nar.scm (write-file): Filter out "." and ".." from the result of
'scandir'. Previously we did this by passing a suitable predicate.
---
guix/nar.scm | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/guix/nar.scm b/guix/nar.scm
index b642143..5b602df 100644
--- a/guix/nar.scm
+++ b/guix/nar.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -177,13 +178,18 @@ sub-directories of FILE as needed."
((directory)
(write-string "type" p)
(write-string "directory" p)
- (let* ((select? (negate (cut member <> '("." ".."))))
-
- ;; 'scandir' defaults to 'string-locale<?' to sort files, but
- ;; this happens to be case-insensitive (at least in 'en_US'
- ;; locale on libc 2.18.) Conversely, we want files to be
- ;; sorted in a case-sensitive fashion.
- (entries (scandir f select? string<?)))
+ (let ((entries
+ ;; NOTE: Guile 2.0.5's 'scandir' returns all subdirectories
+ ;; unconditionally, including "." and "..", regardless of the
+ ;; 'select?' predicate passed to it, so we have to filter
+ ;; those out externally.
+ (filter (negate (cut member <> '("." "..")))
+ ;; 'scandir' defaults to 'string-locale<?' to sort
+ ;; files, but this happens to be case-insensitive (at
+ ;; least in 'en_US' locale on libc 2.18.) Conversely,
+ ;; we want files to be sorted in a case-sensitive
+ ;; fashion.
+ (scandir f (const #t) string<?))))
(for-each (lambda (e)
(let ((f (string-append f "/" e)))
(write-string "entry" p)
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Work around behavior of old 'scandir' in Guile 2.0.5
2014-04-06 23:55 [PATCH] Work around behavior of old 'scandir' in Guile 2.0.5 Mark H Weaver
@ 2014-04-07 7:42 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2014-04-07 7:42 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel
Mark H Weaver <mhw@netris.org> skribis:
> From a49c33418aa6814daf6fcab5978c27afbfe8ac9a Mon Sep 17 00:00:00 2001
> From: Mark H Weaver <mhw@netris.org>
> Date: Sun, 6 Apr 2014 19:46:16 -0400
> Subject: [PATCH] Work around behavior of old 'scandir' in Guile 2.0.5.
>
> Problem reported by John Darrington <john@darrington.wattle.id.au>.
>
> * guix/nar.scm (write-file): Filter out "." and ".." from the result of
> 'scandir'. Previously we did this by passing a suitable predicate.
Good catch, please push!
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-04-07 7:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-06 23:55 [PATCH] Work around behavior of old 'scandir' in Guile 2.0.5 Mark H Weaver
2014-04-07 7:42 ` Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.