Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/ba60fc61ba5bbac8d0bbeb719fe26daa4058e1c5

>---------------------------------------------------------------

commit ba60fc61ba5bbac8d0bbeb719fe26daa4058e1c5
Author: Simon Peyton Jones <[email protected]>
Date:   Thu Sep 29 09:45:42 2011 +0100

    Make Outputable.quotes do what the comments say
    
    Outputable.quotes claimed to drop the quotes if the enclosed thing has
    a trailing single quote; but its implementation checked for
    a *leading* quote.
    
    Fixes Trac #5509

>---------------------------------------------------------------

 compiler/utils/Outputable.lhs |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs
index 833309e..136a1a2 100644
--- a/compiler/utils/Outputable.lhs
+++ b/compiler/utils/Outputable.lhs
@@ -77,6 +77,7 @@ import FastString
 import FastTypes
 import Platform
 import qualified Pretty
+import Util            ( snocView )
 import Pretty          ( Doc, Mode(..) )
 import Panic
 
@@ -451,14 +452,14 @@ cparen :: Bool -> SDoc -> SDoc
 
 cparen b d     = SDoc $ Pretty.cparen b . runSDoc d
 
--- quotes encloses something in single quotes...
+-- 'quotes' encloses something in single quotes...
 -- but it omits them if the thing ends in a single quote
 -- so that we don't get `foo''.  Instead we just have foo'.
 quotes d = SDoc $ \sty -> 
            let pp_d = runSDoc d sty in
-           case show pp_d of
-             ('\'' : _) -> pp_d
-             _other     -> Pretty.quotes pp_d
+           case snocView (show pp_d) of
+             Just (_, '\'') -> pp_d
+             _other         -> Pretty.quotes pp_d
 
 semi, comma, colon, equals, space, dcolon, arrow, underscore, dot :: SDoc
 darrow, lparen, rparen, lbrack, rbrack, lbrace, rbrace, blankLine :: SDoc



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to