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.
import StringBuffer
import GlaExts
import Ctype
import StringBuffer
import GlaExts
import Ctype
+import Char ( chr, ord )
import PrelRead ( readRational__ ) -- Glasgow non-std
\end{code}
import PrelRead ( readRational__ ) -- Glasgow non-std
\end{code}
lex_string cont glaexts s buf
= case currentChar# buf of
'"'#{-"-} ->
lex_string cont glaexts s buf
= case currentChar# buf of
'"'#{-"-} ->
- let buf' = incLexeme buf; s' = mkFastStringInt (reverse s) in
- case currentChar# buf' of
+ let buf' = incLexeme buf
+ s' = mkFastStringNarrow (map chr (reverse s))
+ in case currentChar# buf' of
'#'# | flag glaexts -> if all (<= 0xFF) s
then cont (ITprimstring s') (incLexeme buf')
'#'# | flag glaexts -> if all (<= 0xFF) s
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'
-- ignore \& in a string, deal with string gaps
_ -> cont (ITstring s') buf'
-- ignore \& in a string, deal with string gaps
--names?
mkFastString, -- :: String -> FastString
--names?
mkFastString, -- :: String -> FastString
+ mkFastStringNarrow, -- :: String -> FastString
mkFastSubString, -- :: Addr -> Int -> Int -> FastString
-- These ones hold on to the Addr after they return, and aren't hashed;
mkFastSubString, -- :: Addr -> Int -> Int -> FastString
-- These ones hold on to the Addr after they return, and aren't hashed;