diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-05-20 06:03:49 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-05-29 10:41:02 -0400 |
commit | cc0d05a78c3c731c771aaadd29c2c5c8d772d619 (patch) | |
tree | e04406ef4f872631b856fa8a0f71e3d24d9442e8 | |
parent | 9062b62555ced7403cb97f5fd55cffdd57fbf717 (diff) | |
download | haskell-cc0d05a78c3c731c771aaadd29c2c5c8d772d619.tar.gz |
Add hPutStringBuffer utility
-rw-r--r-- | compiler/utils/StringBuffer.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/utils/StringBuffer.hs b/compiler/utils/StringBuffer.hs index 98b8c19340..91377cad17 100644 --- a/compiler/utils/StringBuffer.hs +++ b/compiler/utils/StringBuffer.hs @@ -19,6 +19,7 @@ module StringBuffer -- * Creation\/destruction hGetStringBuffer, hGetStringBufferBlock, + hPutStringBuffer, appendStringBuffers, stringToStringBuffer, @@ -121,6 +122,11 @@ hGetStringBufferBlock handle wanted then ioError (userError $ "short read of file: "++show(r,size,size_i,handle)) else newUTF8StringBuffer buf ptr size +hPutStringBuffer :: Handle -> StringBuffer -> IO () +hPutStringBuffer hdl (StringBuffer buf len cur) + = do withForeignPtr (plusForeignPtr buf cur) $ \ptr -> + hPutBuf hdl ptr len + -- | Skip the byte-order mark if there is one (see #1744 and #6016), -- and return the new position of the handle in bytes. -- |