[project @ 1998-08-11 21:42:03 by sof]
authorsof <unknown>
Tue, 11 Aug 1998 21:42:06 +0000 (21:42 +0000)
committersof <unknown>
Tue, 11 Aug 1998 21:42:06 +0000 (21:42 +0000)
Pick up unvectorize from Util

ghc/lib/posix/PosixDB.lhs
ghc/lib/posix/PosixProcPrim.lhs
ghc/lib/posix/PosixUtil.lhs

index a05e30d..2952c05 100644 (file)
@@ -22,6 +22,7 @@ import PrelIOBase
 import Addr
 import IO
 import PosixUtil
+import Util ( unvectorize )
 
 data GroupEntry =
  GroupEntry {
index 5db43b6..ab3a40a 100644 (file)
@@ -102,6 +102,7 @@ import PackedString (psToByteArrayST)
 import Foreign  -- stable pointers
 import PosixErr
 import PosixUtil
+import Util ( unvectorize )
 
 import System(ExitCode(..))
 import PosixProcEnv (getProcessID)
index 0beb1bf..127524e 100644 (file)
@@ -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