Refactor: use System.FilePath.splitSearchPath
authorThomas Miedema <thomasmiedema@gmail.com>
Wed, 19 Nov 2014 04:17:47 +0000 (22:17 -0600)
committerAustin Seipp <austin@well-typed.com>
Wed, 19 Nov 2014 23:03:05 +0000 (17:03 -0600)
commit6fc78fdfa1482a31ed7b586f20c9d7cb592ea944
treefaca1cc9e2eab107c6ca86606ed0e3e42d4bf005
parent101c62e26286353dd3fac1ef54323529b64c9902
Refactor: use System.FilePath.splitSearchPath

Summary:
To address #2521 ("Trailing colon on GHC_PACKAGE_PATH doesn't work with
ghc-pkg"), we were using a custom version of splitSearchPath (e4f46f5de). This
solution however caused issue #9698 ("GHC_PACKAGE_PATH should be more lenient
for empty paths").

This patch reverts back to System.FilePath.splitSearchPath (fixes #9698) and
adresses (#2521) by testing for a trailing search path separators explicitly
(instead of implicitly using empty search path elements).

Empty paths are now allowed (ignored on Windows, interpreted as current
directory on Posix systems), and trailing path separator still tack on the
user and system package databases.

Also update submodule filepath, which has a version of splitSearchPath which
handles quotes in the same way as our custom version did.

Test Plan:
$ GHC_PACKAGE_PATH=/::/home: ./ghc-pkg list
...
db stack: ["/",".","/home","<userdb>","<systemdb>"]
...

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D414

GHC Trac Issues: #2521, #9698
compiler/main/Packages.lhs
compiler/utils/Util.lhs
libraries/filepath
utils/ghc-pkg/Main.hs