Skip to content

Commit f3fb024

Browse files
hasufellMistuke
authored andcommitted
Fix build with -f-os-string
1 parent d342e13 commit f3fb024

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

System/Win32/WindowsString/Console.hsc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{-# LANGUAGE QuasiQuotes #-}
2-
{-# LANGUAGE ViewPatterns #-}
1+
{-# LANGUAGE PackageImports #-}
32

43
-----------------------------------------------------------------------------
54
-- |
@@ -85,6 +84,17 @@ import GHC.IO.Exception (IOException(..), IOErrorType(OtherError))
8584
import Prelude hiding (break, length, tail)
8685
import qualified Prelude as P
8786

87+
#if !MIN_VERSION_filepath(1,5,0)
88+
import Data.Coerce
89+
import qualified "filepath" System.OsPath.Data.ByteString.Short.Word16 as BC
90+
91+
tail :: WindowsString -> WindowsString
92+
tail = coerce BC.tail
93+
94+
break :: (WindowsChar -> Bool) -> WindowsString -> (WindowsString, WindowsString)
95+
break = coerce BC.break
96+
#endif
97+
8898

8999
-- | This function can be used to parse command line arguments and return
90100
-- the split up arguments as elements in a list.
@@ -142,7 +152,8 @@ getEnvironment = bracket c_GetEnvironmentStringsW c_FreeEnvironmentStrings $ \lp
142152
divvy :: WindowsString -> (WindowsString, WindowsString)
143153
divvy str =
144154
case break (== unsafeFromChar '=') str of
145-
(xs,[pstr||]) -> (xs,[pstr||]) -- don't barf (like Posix.getEnvironment)
155+
(xs,ys)
156+
| ys == mempty -> (xs,ys) -- don't barf (like Posix.getEnvironment)
146157
(name, ys) -> let value = tail ys in (name,value)
147158

148159
builder :: LPWSTR -> IO [WindowsString]

System/Win32/WindowsString/String.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import System.Win32.String hiding
3030
)
3131
import System.Win32.WindowsString.Types
3232
import System.OsString.Internal.Types
33-
#if MIN_VERSION_filepath(1, 5, 0)
33+
#if MIN_VERSION_filepath(1,5,0)
3434
import qualified "os-string" System.OsString.Data.ByteString.Short as SBS
3535
#else
3636
import qualified "filepath" System.OsPath.Data.ByteString.Short as SBS

System/Win32/WindowsString/Types.hsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import qualified System.OsPath.Windows as WS
4949
import System.OsPath.Windows (WindowsPath)
5050
import System.OsString.Windows (decodeWith, encodeWith)
5151
import System.OsString.Internal.Types
52-
#if MIN_VERSION_filepath(1, 5, 0)
52+
#if MIN_VERSION_filepath(1,5,0)
5353
import "os-string" System.OsString.Encoding.Internal (decodeWithBaseWindows)
5454
import qualified "os-string" System.OsString.Data.ByteString.Short.Word16 as SBS
5555
import "os-string" System.OsString.Data.ByteString.Short.Word16 (

0 commit comments

Comments
 (0)