Skip to content

Commit

Permalink
Fix build with -f-os-string
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell authored and Mistuke committed Aug 10, 2024
1 parent d342e13 commit f3fb024
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions System/Win32/WindowsString/Console.hsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE PackageImports #-}

-----------------------------------------------------------------------------
-- |
Expand Down Expand Up @@ -85,6 +84,17 @@ import GHC.IO.Exception (IOException(..), IOErrorType(OtherError))
import Prelude hiding (break, length, tail)
import qualified Prelude as P

#if !MIN_VERSION_filepath(1,5,0)
import Data.Coerce
import qualified "filepath" System.OsPath.Data.ByteString.Short.Word16 as BC

tail :: WindowsString -> WindowsString
tail = coerce BC.tail

break :: (WindowsChar -> Bool) -> WindowsString -> (WindowsString, WindowsString)
break = coerce BC.break
#endif


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

builder :: LPWSTR -> IO [WindowsString]
Expand Down
2 changes: 1 addition & 1 deletion System/Win32/WindowsString/String.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import System.Win32.String hiding
)
import System.Win32.WindowsString.Types
import System.OsString.Internal.Types
#if MIN_VERSION_filepath(1, 5, 0)
#if MIN_VERSION_filepath(1,5,0)
import qualified "os-string" System.OsString.Data.ByteString.Short as SBS
#else
import qualified "filepath" System.OsPath.Data.ByteString.Short as SBS
Expand Down
2 changes: 1 addition & 1 deletion System/Win32/WindowsString/Types.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import qualified System.OsPath.Windows as WS
import System.OsPath.Windows (WindowsPath)
import System.OsString.Windows (decodeWith, encodeWith)
import System.OsString.Internal.Types
#if MIN_VERSION_filepath(1, 5, 0)
#if MIN_VERSION_filepath(1,5,0)
import "os-string" System.OsString.Encoding.Internal (decodeWithBaseWindows)
import qualified "os-string" System.OsString.Data.ByteString.Short.Word16 as SBS
import "os-string" System.OsString.Data.ByteString.Short.Word16 (
Expand Down

0 comments on commit f3fb024

Please sign in to comment.