Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
6e4a7500
Commit
6e4a7500
authored
Jun 06, 2014
by
Joachim Breitner
Browse files
Only use UnicodeSytanx pretty printing if the locale supports it
using the same check as for unicode quotes.
parent
819e1f2c
Changes
7
Hide whitespace changes
Inline
Side-by-side
compiler/main/DynFlags.hs
View file @
6e4a7500
...
...
@@ -777,7 +777,7 @@ data DynFlags = DynFlags {
pprCols
::
Int
,
traceLevel
::
Int
,
-- Standard level is 1. Less verbose is 0.
useUnicode
Quotes
::
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
canUseUnicode
Quotes
<-
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
,
useUnicode
Quotes
=
canUseUnicode
Quotes
,
useUnicode
=
canUseUnicode
,
rtldInfo
=
refRtldInfo
,
rtccInfo
=
refRtccInfo
}
...
...
@@ -1449,7 +1449,7 @@ defaultDynFlags mySettings =
flushErr
=
defaultFlushErr
,
pprUserLength
=
5
,
pprCols
=
100
,
useUnicode
Quotes
=
False
,
useUnicode
=
False
,
traceLevel
=
1
,
profAuto
=
NoProfAuto
,
llvmVersion
=
panic
"defaultDynFlags: No llvmVersion"
,
...
...
compiler/main/DynFlags.hs-boot
View file @
6e4a7500
...
...
@@ -9,5 +9,5 @@ targetPlatform :: DynFlags -> Platform
pprUserLength
::
DynFlags
->
Int
pprCols
::
DynFlags
->
Int
unsafeGlobalDynFlags
::
DynFlags
useUnicode
Quotes
::
DynFlags
->
Bool
useUnicode
::
DynFlags
->
Bool
useUnicodeSyntax
::
DynFlags
->
Bool
compiler/utils/Outputable.lhs
View file @
6e4a7500
...
...
@@ -74,7 +74,7 @@ module Outputable (
import {-# SOURCE #-} DynFlags( DynFlags,
targetPlatform, pprUserLength, pprCols,
useUnicode
Quotes
, 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 useUnicode
Quotes
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
...
...
testsuite/tests/driver/Makefile
View file @
6e4a7500
...
...
@@ -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
...
...
testsuite/tests/driver/T8959a.hs
0 → 100644
View file @
6e4a7500
{-# LANGUAGE UnicodeSyntax #-}
module
T8959a
where
foo
::
Int
->
Int
foo
=
()
testsuite/tests/driver/T8959a.stderr
0 → 100644
View file @
6e4a7500
T8959a.hs:5:7:
Couldn't match expected type `Int -> Int' with actual type `()'
In the expression: ()
In an equation for `foo': foo = ()
testsuite/tests/driver/all.T
View file @
6e4a7500
...
...
@@ -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
'])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment