diff options
author | Ben Gamari <ben@smart-cactus.org> | 2016-07-17 00:12:52 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-07-17 00:12:53 +0200 |
commit | 0f0cdb6827803015a9a3924fdafaef8dbcde048f (patch) | |
tree | c35159a2c5ba6b4c9d9bfe4aa759c1878fa06813 /libraries/base/Text | |
parent | 24f5f368d8ed0b5f113c2753b2b2bdc99957dcb2 (diff) | |
download | haskell-0f0cdb6827803015a9a3924fdafaef8dbcde048f.tar.gz |
Bugfix for bug 11632: `readLitChar` should consume null characters
Test Plan: The tests have been included. This change deals with a
relatively minor edge case and should not break unrelated functionality.
Reviewers: thomie, #core_libraries_committee, ekmett, bgamari
Reviewed By: #core_libraries_committee, ekmett, bgamari
Subscribers: bgamari, ekmett
Differential Revision: https://phabricator.haskell.org/D2391
GHC Trac Issues: #11632
Diffstat (limited to 'libraries/base/Text')
-rw-r--r-- | libraries/base/Text/Read/Lex.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libraries/base/Text/Read/Lex.hs b/libraries/base/Text/Read/Lex.hs index 7054be9d79..d0d39c6648 100644 --- a/libraries/base/Text/Read/Lex.hs +++ b/libraries/base/Text/Read/Lex.hs @@ -253,7 +253,16 @@ lexLitChar = return (Char c) lexChar :: ReadP Char -lexChar = do { (c,_) <- lexCharE; return c } +lexChar = do { (c,_) <- lexCharE; consumeEmpties; return c } + where + -- Consumes the string "\&" repeatedly and greedily (will only produce one match) + consumeEmpties :: ReadP () + consumeEmpties = do + rest <- look + case rest of + ('\\':'&':_) -> string "\\&" >> consumeEmpties + _ -> return () + lexCharE :: ReadP (Char, Bool) -- "escaped or not"? lexCharE = |