Commit 6e4a7500 authored by Joachim Breitner's avatar Joachim Breitner
Browse files

Only use UnicodeSytanx pretty printing if the locale supports it

using the same check as for unicode quotes.
parent 819e1f2c
......@@ -777,7 +777,7 @@ data DynFlags = DynFlags {
pprCols :: Int,
traceLevel :: Int, -- Standard level is 1. Less verbose is 0.
useUnicodeQuotes :: Bool,
useUnicode :: Bool,
-- | what kind of {-# SCC #-} to add automatically
profAuto :: ProfAuto,
......@@ -1295,12 +1295,12 @@ initDynFlags dflags = do
refRtldInfo <- newIORef Nothing
refRtccInfo <- newIORef Nothing
wrapperNum <- newIORef emptyModuleEnv
canUseUnicodeQuotes <- do let enc = localeEncoding
str = "‘’"
(withCString enc str $ \cstr ->
do str' <- peekCString enc cstr
return (str == str'))
`catchIOError` \_ -> return False
canUseUnicode <- do let enc = localeEncoding
str = "‘’"
(withCString enc str $ \cstr ->
do str' <- peekCString enc cstr
return (str == str'))
`catchIOError` \_ -> return False
return dflags{
canGenerateDynamicToo = refCanGenerateDynamicToo,
nextTempSuffix = refNextTempSuffix,
......@@ -1310,7 +1310,7 @@ initDynFlags dflags = do
generatedDumps = refGeneratedDumps,
llvmVersion = refLlvmVersion,
nextWrapperNum = wrapperNum,
useUnicodeQuotes = canUseUnicodeQuotes,
useUnicode = canUseUnicode,
rtldInfo = refRtldInfo,
rtccInfo = refRtccInfo
}
......@@ -1449,7 +1449,7 @@ defaultDynFlags mySettings =
flushErr = defaultFlushErr,
pprUserLength = 5,
pprCols = 100,
useUnicodeQuotes = False,
useUnicode = False,
traceLevel = 1,
profAuto = NoProfAuto,
llvmVersion = panic "defaultDynFlags: No llvmVersion",
......
......@@ -9,5 +9,5 @@ targetPlatform :: DynFlags -> Platform
pprUserLength :: DynFlags -> Int
pprCols :: DynFlags -> Int
unsafeGlobalDynFlags :: DynFlags
useUnicodeQuotes :: DynFlags -> Bool
useUnicode :: DynFlags -> Bool
useUnicodeSyntax :: DynFlags -> Bool
......@@ -74,7 +74,7 @@ module Outputable (
import {-# SOURCE #-} DynFlags( DynFlags,
targetPlatform, pprUserLength, pprCols,
useUnicodeQuotes, useUnicodeSyntax,
useUnicode, useUnicodeSyntax,
unsafeGlobalDynFlags )
import {-# SOURCE #-} Module( Module, ModuleName, moduleName )
import {-# SOURCE #-} OccName( OccName )
......@@ -459,7 +459,7 @@ cparen b d = SDoc $ Pretty.cparen b . runSDoc d
-- so that we don't get `foo''. Instead we just have foo'.
quotes d =
sdocWithDynFlags $ \dflags ->
if useUnicodeQuotes dflags
if useUnicode dflags
then char '‘' <> d <> char '’'
else SDoc $ \sty ->
let pp_d = runSDoc d sty
......@@ -501,8 +501,9 @@ forAllLit = unicodeSyntax (char '∀') (ptext (sLit "forall"))
unicodeSyntax :: SDoc -> SDoc -> SDoc
unicodeSyntax unicode plain = sdocWithDynFlags $ \dflags ->
if useUnicodeSyntax dflags then unicode
else plain
if useUnicode dflags && useUnicodeSyntax dflags
then unicode
else plain
nest :: Int -> SDoc -> SDoc
-- ^ Indent 'SDoc' some specified amount
......
......@@ -556,6 +556,10 @@ T6037:
T2507:
-LC_ALL=C "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) -c T2507.hs
.PHONY: T8959a
T8959a:
-LC_ALL=C "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) -c T8959a.hs -XUnicodeSyntax
.PHONY: T703
T703:
$(RM) -rf T703
......
{-# LANGUAGE UnicodeSyntax #-}
module T8959a where
foo :: Int -> Int
foo = ()
T8959a.hs:5:7:
Couldn't match expected type `Int -> Int' with actual type `()'
In the expression: ()
In an equation for `foo': foo = ()
......@@ -391,6 +391,11 @@ test('T2507',
[when(opsys('mingw32'), expect_fail), when(opsys('darwin'), expect_fail)],
run_command,
['$MAKE -s --no-print-directory T2507'])
test('T8959a',
# The testsuite doesn't know how to set a non-Unicode locale on Windows or Mac OS X
[when(opsys('mingw32'), expect_fail), when(opsys('darwin'), expect_fail)],
run_command,
['$MAKE -s --no-print-directory T8959a'])
test('T703', normal, run_command, ['$MAKE -s --no-print-directory T703'])
test('T8101', normal, compile, ['-Wall -fno-code'])
......
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