Commit 11b6ed82 authored by sewardj's avatar sewardj
Browse files

[project @ 2001-04-26 15:42:06 by sewardj]

Fix bug in which *primitive* string literals were being checked for
Unicode-ness, even though they are not allowed to be; literals
containing zero bytes were then unicodified, which crashes the
bytecode generator.
parent d9f56487
...@@ -52,7 +52,7 @@ import FastString ...@@ -52,7 +52,7 @@ import FastString
import StringBuffer import StringBuffer
import GlaExts import GlaExts
import Ctype import Ctype
import Char ( ord ) import Char ( chr, ord )
import PrelRead ( readRational__ ) -- Glasgow non-std import PrelRead ( readRational__ ) -- Glasgow non-std
\end{code} \end{code}
...@@ -668,11 +668,12 @@ lex_prag cont buf ...@@ -668,11 +668,12 @@ lex_prag cont buf
lex_string cont glaexts s buf lex_string cont glaexts s buf
= case currentChar# buf of = case currentChar# buf of
'"'#{-"-} -> '"'#{-"-} ->
let buf' = incLexeme buf; s' = mkFastStringInt (reverse s) in let buf' = incLexeme buf
case currentChar# buf' of s' = mkFastStringNarrow (map chr (reverse s))
in case currentChar# buf' of
'#'# | flag glaexts -> if all (<= 0xFF) s '#'# | flag glaexts -> if all (<= 0xFF) s
then cont (ITprimstring s') (incLexeme buf') then cont (ITprimstring s') (incLexeme buf')
else lexError "primitive string literal must contain only characters <= '\xFF'" buf' else lexError "primitive string literal must contain only characters <= \'\\xFF\'" buf'
_ -> cont (ITstring s') buf' _ -> cont (ITstring s') buf'
-- ignore \& in a string, deal with string gaps -- ignore \& in a string, deal with string gaps
......
...@@ -13,6 +13,7 @@ module FastString ...@@ -13,6 +13,7 @@ module FastString
--names? --names?
mkFastString, -- :: String -> FastString mkFastString, -- :: String -> FastString
mkFastStringNarrow, -- :: String -> FastString
mkFastSubString, -- :: Addr -> Int -> Int -> FastString mkFastSubString, -- :: Addr -> Int -> Int -> FastString
-- These ones hold on to the Addr after they return, and aren't hashed; -- These ones hold on to the Addr after they return, and aren't hashed;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment