summaryrefslogtreecommitdiff
path: root/ghc/compiler/utils/StringBuffer.lhs
diff options
context:
space:
mode:
authorsimonmar <unknown>2000-01-05 17:23:34 +0000
committersimonmar <unknown>2000-01-05 17:23:34 +0000
commit1145d75aeb749b255533ea5f76d8c57146881cb6 (patch)
tree41e1c30f4fbd3e15011450846a2d6cb6af61c40d /ghc/compiler/utils/StringBuffer.lhs
parent1aad16b632df54fa4c430b6abf8c76fe257122b7 (diff)
downloadhaskell-1145d75aeb749b255533ea5f76d8c57146881cb6.tar.gz
[project @ 2000-01-05 17:23:34 by simonmar]
Emit a reasonable error message instead of crashing when there's an unterminated literal-liberal in the source file.
Diffstat (limited to 'ghc/compiler/utils/StringBuffer.lhs')
-rw-r--r--ghc/compiler/utils/StringBuffer.lhs14
1 files changed, 7 insertions, 7 deletions
diff --git a/ghc/compiler/utils/StringBuffer.lhs b/ghc/compiler/utils/StringBuffer.lhs
index 115d36c509..b6b728fa45 100644
--- a/ghc/compiler/utils/StringBuffer.lhs
+++ b/ghc/compiler/utils/StringBuffer.lhs
@@ -415,16 +415,16 @@ scanNumLit acc (StringBuffer fo l# s# c#) =
| otherwise -> (acc,StringBuffer fo l# s# c#)
-expandUntilMatch :: StringBuffer -> String -> StringBuffer
+expandUntilMatch :: StringBuffer -> String -> Maybe StringBuffer
expandUntilMatch (StringBuffer fo l# s# c#) str =
loop c# str
where
- loop c# [] = StringBuffer fo l# s# c#
- loop c# ((C# x#):xs)
- | indexCharOffAddr# fo c# `eqChar#` x#
- = loop (c# +# 1#) xs
- | otherwise
- = loop (c# +# 1#) str
+ loop c# [] = Just (StringBuffer fo l# s# c#)
+ loop c# ((C# x#):xs) =
+ case indexCharOffAddr# fo c# of
+ ch# | ch# `eqChar#` '\NUL'# && c# >=# l# -> Nothing
+ | ch# `eqChar#` x# -> loop (c# +# 1#) xs
+ | otherwise -> loop (c# +# 1#) str
\end{code}