Changeset 14341 for src/Pugs/Prim.hs

Show
Ignore:
Timestamp:
10/17/06 08:25:46 (2 years ago)
Author:
audreyt
svk:copy_cache_prev:
21206
Message:

* Pugs.Prim: Instead of using ByteString?.Char8's file IO primitives

(which defaults to binary mode instead of text mode on win32),
use Haskell's built-in ones, which handles CRLF transparently.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim.hs

    r14337 r14341  
    5454import GHC.Exts (unsafeCoerce#) 
    5555import GHC.Unicode 
    56 import qualified UTF8 as Str 
    5756import qualified Data.HashTable as H 
    5857 
     
    359358op1 "IO::next" = \v -> do 
    360359    fh  <- fromVal v 
    361     guardIO $ fmap (VStr . (++ "\n") . Str.unpack) (Str.hGetLine fh) 
     360    guardIO $ fmap (VStr . (++ "\n") . decodeUTF8) (hGetLine fh) 
    362361op1 "Pugs::Safe::safe_print" = \v -> do 
    363362    str  <- fromVal v 
    364     guardIO . Str.hPut stdout $ Str.pack str 
     363    guardIO . putStr $ encodeUTF8 str 
    365364    return $ VBool True 
    366365op1 "die" = \v -> do 
     
    438437        (do h <- fromVal v 
    439438            ifListContext (strictify $! op1 "=" v) $ do 
    440                 content <- guardIO $ Str.hGetContents h 
    441                 return . VStr $ Str.unpack content) 
     439                content <- guardIO $ hGetContents h 
     440                return . VStr $ decodeUTF8 content) 
    442441        (do 
    443442            fileName    <- fromVal v 
     
    451450    slurpList file = strictify $! op1 "=" (VList [VStr file]) 
    452451    slurpScalar file = do 
    453         content <- guardIO $ Str.readFile file 
    454         return . VStr $ Str.unpack content 
     452        content <- guardIO $ readFile file 
     453        return . VStr $ decodeUTF8 content 
    455454op1 "opendir" = \v -> do 
    456455    str <- fromVal v