Hi, - Change the first argument to pledge (the promises) to Maybe String, following the recent change to pledge(2) (passing NULL doesn't change the value).
- Use maybeWith instead of pattern matching to distinguish between Nothing and Just x. - Add some minimal documentation. Sending this to ports@ mainly because of the documentation bits -- my english sometimes sucks ;-) Any nitpicks and / or corrections? Ciao, Kili Index: Makefile =================================================================== RCS file: /cvs/ports/lang/ghc/Makefile,v retrieving revision 1.134 diff -u -p -r1.134 Makefile --- Makefile 26 Feb 2016 07:50:52 -0000 1.134 +++ Makefile 13 Mar 2016 14:44:57 -0000 @@ -12,7 +12,7 @@ COMMENT = compiler for the functional l NO_CCACHE = Yes DISTNAME = ghc-${MODGHC_VER} -REVISION = 1 +REVISION = 2 CATEGORIES = lang devel HOMEPAGE = https://www.haskell.org/ghc/ Index: files/Process.hsc =================================================================== RCS file: /cvs/ports/lang/ghc/files/Process.hsc,v retrieving revision 1.1 diff -u -p -r1.1 Process.hsc --- files/Process.hsc 20 Jan 2016 16:02:06 -0000 1.1 +++ files/Process.hsc 13 Mar 2016 14:44:57 -0000 @@ -6,18 +6,23 @@ import Foreign import Foreign.C import System.Posix.Internals ( withFilePath ) -pledge :: String -> Maybe [FilePath] -> IO () +-- | This function provides an interface to the OpenBSD +-- <http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man2/pledge.2 pledge(2)> +-- system call. +-- +-- Passing 'Nothing' to the promises or paths arguments has the same +-- effect as passing NULL to the corresponding arguments of the system +-- call (i.e. not changing the current value). +pledge :: Maybe String -> Maybe [FilePath] -> IO () pledge promises paths = - withCString promises $ \cproms -> - withPaths2Array0 paths $ \paths_arr -> + maybeWith withCString promises $ \cproms -> + maybeWith withPaths2Array0 paths $ \paths_arr -> throwErrnoIfMinus1_ "pledge" (c_pledge cproms paths_arr) -withPaths2Array0 :: Maybe [FilePath] -> (Ptr (Ptr CChar) -> IO a) -> IO a +withPaths2Array0 :: [FilePath] -> (Ptr (Ptr CChar) -> IO a) -> IO a -withPaths2Array0 Nothing f = f nullPtr - -withPaths2Array0 (Just paths) f = +withPaths2Array0 paths f = withMany withFilePath paths $ \cstrs -> withArray0 nullPtr cstrs $ \paths_arr -> f paths_arr