summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsof <unknown>1998-08-11 21:42:06 +0000
committersof <unknown>1998-08-11 21:42:06 +0000
commit736492ced360555aa600c761b3e39f100fc6293f (patch)
tree1864b4759f322c99c9c9512ebc29d58291fcdba9
parente51e1225b4bd3c2436a095f52da89c323913b5f2 (diff)
downloadhaskell-736492ced360555aa600c761b3e39f100fc6293f.tar.gz
[project @ 1998-08-11 21:42:03 by sof]
Pick up unvectorize from Util
-rw-r--r--ghc/lib/posix/PosixDB.lhs1
-rw-r--r--ghc/lib/posix/PosixProcPrim.lhs1
-rw-r--r--ghc/lib/posix/PosixUtil.lhs22
3 files changed, 7 insertions, 17 deletions
diff --git a/ghc/lib/posix/PosixDB.lhs b/ghc/lib/posix/PosixDB.lhs
index a05e30deaf..2952c05046 100644
--- a/ghc/lib/posix/PosixDB.lhs
+++ b/ghc/lib/posix/PosixDB.lhs
@@ -22,6 +22,7 @@ import PrelIOBase
import Addr
import IO
import PosixUtil
+import Util ( unvectorize )
data GroupEntry =
GroupEntry {
diff --git a/ghc/lib/posix/PosixProcPrim.lhs b/ghc/lib/posix/PosixProcPrim.lhs
index 5db43b6aa3..ab3a40a336 100644
--- a/ghc/lib/posix/PosixProcPrim.lhs
+++ b/ghc/lib/posix/PosixProcPrim.lhs
@@ -102,6 +102,7 @@ import PackedString (psToByteArrayST)
import Foreign -- stable pointers
import PosixErr
import PosixUtil
+import Util ( unvectorize )
import System(ExitCode(..))
import PosixProcEnv (getProcessID)
diff --git a/ghc/lib/posix/PosixUtil.lhs b/ghc/lib/posix/PosixUtil.lhs
index 0beb1bf4d3..127524ee54 100644
--- a/ghc/lib/posix/PosixUtil.lhs
+++ b/ghc/lib/posix/PosixUtil.lhs
@@ -16,9 +16,11 @@ import PrelBase
import MutableArray
import ByteArray
import Array
-import PackedString ( packCBytesST, psToByteArrayST, unpackPS )
+import PackedString ( unpackCStringIO, packCBytesST, psToByteArrayST )
import Ix
import PrelArr (StateAndMutableByteArray#(..), StateAndByteArray#(..))
+import Util ( unvectorize )
+
\end{code}
First, all of the major Posix data types, to avoid any recursive dependencies
@@ -96,12 +98,7 @@ freeze (MutableByteArray ixs arr#) = IO $ \ s# ->
-- Haskellized nonsense inside the heap
strcpy :: Addr -> IO String
-strcpy str
- | str == ``NULL'' = return ""
- | otherwise =
- _ccall_ strlen str >>= \ len ->
- stToIO (packCBytesST len str) >>= \ ps ->
- return (unpackPS ps)
+strcpy str = unpackCStringIO str
-- Turn a string list into a NULL-terminated vector of null-terminated
-- strings No indices...I hate indices. Death to Ix.
@@ -125,16 +122,7 @@ vectorize xs = do
fill arr (n+1) xs
-- Turn a NULL-terminated vector of null-terminated strings into a string list
-
-unvectorize :: Addr -> Int -> IO [String]
-unvectorize ptr n
- | str == ``NULL'' = return []
- | otherwise =
- strcpy str >>= \ x ->
- unvectorize ptr (n+1) >>= \ xs ->
- return (x : xs)
- where
- str = indexAddrOffAddr ptr n
+-- unvectorize ... (now in misc/Util.lhs)
-- common templates for system calls