Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
b77d3bcd
Commit
b77d3bcd
authored
26 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1998-12-09 17:52:09 by sof]
Added unpackCStringST - unmarshal C strings promptly
parent
9c3ddd5a
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/lib/std/PrelPack.lhs
+17
-5
17 additions, 5 deletions
ghc/lib/std/PrelPack.lhs
with
17 additions
and
5 deletions
ghc/lib/std/PrelPack.lhs
+
17
−
5
View file @
b77d3bcd
...
...
@@ -23,6 +23,7 @@ module PrelPack
packNBytesST, -- :: Int -> [Char] -> ST s (ByteArray Int)
unpackCString, -- :: Addr -> [Char]
unpackCStringST, -- :: Addr -> ST s [Char]
unpackNBytes, -- :: Addr -> Int -> [Char]
unpackNBytesST, -- :: Addr -> Int -> ST s [Char]
unpackNBytesAccST, -- :: Addr -> Int -> [Char] -> ST s [Char]
...
...
@@ -66,11 +67,22 @@ sequence of bytes into a list of @Char@s:
\begin{code}
unpackCString :: Addr{- ptr. to NUL terminated string-} -> [Char]
unpackCString a@(A# addr) =
if a == ``NULL'' then
[]
else
unpackCString# addr
unpackCString a@(A# addr)
| a == nullAddr = []
| otherwise = unpackCString# addr
unpackCStringST :: Addr{- ptr. to NUL terminated string-} -> ST s [Char]
unpackCStringST a@(A# addr)
| a == nullAddr = return []
| otherwise = unpack 0#
where
unpack nh
| ch `eqChar#` '\0'# = return []
| otherwise = do
ls <- unpack (nh +# 1#)
return ((C# ch ) : ls)
where
ch = indexCharOffAddr# addr nh
unpackCString# :: Addr# -> [Char]
unpackCString# addr
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment