[commit: ghc] master,ghc-lwc2: Fix parsing of pragmas containing unicode characters; fixes #7671 (c68aac1)

Ian Lynagh igloo at earth.li
Thu Feb 28 15:20:16 CET 2013


Repository : http://darcs.haskell.org/ghc.git/

On branches: master,ghc-lwc2

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

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

commit c68aac1f2e59d0844a285b757777b950da91a8be
Author: Ian Lynagh <ian at well-typed.com>
Date:   Tue Feb 26 01:27:43 2013 +0000

    Fix parsing of pragmas containing unicode characters; fixes #7671

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

 compiler/parser/Lexer.x | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index 7e801dd..fdf75cf 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -2389,8 +2389,11 @@ dispatch_pragmas prags span buf len = case Map.lookup (clean_pragma (lexemeToStr
                                        Nothing -> lexError "unknown pragma"
 
 known_pragma :: Map String Action -> AlexAccPred Int
-known_pragma prags _ _ len (AI _ buf) = (isJust $ Map.lookup (clean_pragma (lexemeToString (offsetBytes (- len) buf) len)) prags)
-                                          && (nextCharIsNot buf (\c -> isAlphaNum c || c == '_'))
+known_pragma prags _ (AI _ startbuf) _ (AI _ curbuf)
+ = isKnown && nextCharIsNot curbuf pragmaNameChar
+    where l = lexemeToString startbuf (byteDiff startbuf curbuf)
+          isKnown = isJust $ Map.lookup (clean_pragma l) prags
+          pragmaNameChar c = isAlphaNum c || c == '_'
 
 clean_pragma :: String -> String
 clean_pragma prag = canon_ws (map toLower (unprefix prag))





More information about the ghc-commits mailing list