From 736492ced360555aa600c761b3e39f100fc6293f Mon Sep 17 00:00:00 2001 From: sof Date: Tue, 11 Aug 1998 21:42:06 +0000 Subject: [PATCH] [project @ 1998-08-11 21:42:03 by sof] Pick up unvectorize from Util --- ghc/lib/posix/PosixDB.lhs | 1 + ghc/lib/posix/PosixProcPrim.lhs | 1 + ghc/lib/posix/PosixUtil.lhs | 22 +++++----------------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/ghc/lib/posix/PosixDB.lhs b/ghc/lib/posix/PosixDB.lhs index a05e30d..2952c05 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 5db43b6..ab3a40a 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 0beb1bf..127524e 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 -- 1.7.10.4