]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/alien/libraries/finder/linux/linux.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / alien / libraries / finder / linux / linux.factor
index 2785e31603437f5cd510adf7bd769a516c39ee51..406cb9a41e582199006760829e8839099a5c6b4c 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2013 Björn Lindqvist, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license
-USING: alien.libraries alien.libraries.finder arrays assocs
+USING: alien.libraries.finder arrays assocs
 combinators.short-circuit io io.encodings.utf8 io.files
 io.files.info io.launcher kernel sequences sets splitting system
 unicode.categories ;
@@ -17,7 +17,11 @@ CONSTANT: mach-map {
 : parse-ldconfig-lines ( string -- triple )
     [
         "=>" split1 [ [ blank? ] trim ] bi@
-        [ " " split1 [ "()" in? ] trim "," split ] dip 3array
+        [
+            " " split1 [ "()" in? ] trim "," split
+            [ [ blank? ] trim ] map
+            [ "OS ABI:" head? ] reject
+        ] dip 3array
     ] map ;
 
 : load-ldconfig-cache ( -- seq )
@@ -27,15 +31,22 @@ CONSTANT: mach-map {
 : ldconfig-arch ( -- str )
     mach-map cpu of { "libc6" } or ;
 
+: name-matches? ( lib triple -- ? )
+    first swap ?head [ ?first CHAR: . = ] [ drop f ] if ;
+
+: arch-matches? ( lib triple -- ? )
+    [ drop ldconfig-arch ] [ second swap subset? ] bi* ;
+
 : ldconfig-matches? ( lib triple -- ? )
-    { [ first head? ] [ nip second ldconfig-arch subset? ] } 2&& ;
+    { [ name-matches? ] [ arch-matches? ] } 2&& ;
 
 : ldconfig-find-soname ( lib -- seq )
-    load-ldconfig-cache [ ldconfig-matches? ] with filter [ third ] map ;
+    load-ldconfig-cache [ ldconfig-matches? ] with filter
+    [ third ] map ;
 
 PRIVATE>
 
-M: linux find-library
-    "lib" ".so" surround ldconfig-find-soname [
+M: linux find-library*
+    "lib" prepend ldconfig-find-soname [
         { [ exists? ] [ file-info regular-file? ] } 1&&
     ] map-find nip ;