From 11b6ed82b7e80125bd66c8d99b82270b81daa553 Mon Sep 17 00:00:00 2001 From: sewardj Date: Thu, 26 Apr 2001 15:42:06 +0000 Subject: [PATCH] [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. --- ghc/compiler/parser/Lex.lhs | 9 +++++---- ghc/compiler/utils/FastString.lhs | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) 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; -- 1.7.10.4