From: sewardj Date: Thu, 26 Apr 2001 15:42:06 +0000 (+0000) Subject: [project @ 2001-04-26 15:42:06 by sewardj] X-Git-Tag: Approximately_9120_patches~2094 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=11b6ed82b7e80125bd66c8d99b82270b81daa553;p=ghc-hetmet.git [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. --- diff --git a/ghc/compiler/parser/Lex.lhs b/ghc/compiler/parser/Lex.lhs index 130eef8..faec03f 100644 --- a/ghc/compiler/parser/Lex.lhs +++ b/ghc/compiler/parser/Lex.lhs @@ -52,7 +52,7 @@ import FastString import StringBuffer import GlaExts import Ctype -import Char ( ord ) +import Char ( chr, ord ) import PrelRead ( readRational__ ) -- Glasgow non-std \end{code} @@ -668,11 +668,12 @@ lex_prag cont buf 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') - 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 diff --git a/ghc/compiler/utils/FastString.lhs b/ghc/compiler/utils/FastString.lhs index eebb53a..bb0a02f 100644 --- a/ghc/compiler/utils/FastString.lhs +++ b/ghc/compiler/utils/FastString.lhs @@ -13,6 +13,7 @@ module 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;