[commit: ghc] master: Extra CRs are now filtered out from the source file for :list. (45175e1)

git at git.haskell.org git at git.haskell.org
Thu Oct 30 04:15:45 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/45175e13edad452843207491d01cdbce0bedbbd4/ghc

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

commit 45175e13edad452843207491d01cdbce0bedbbd4
Author: Gintautas Miliauskas <gintautas.miliauskas at gmail.com>
Date:   Wed Oct 29 23:14:17 2014 -0500

    Extra CRs are now filtered out from the source file for :list.
    
    Fixes #9367.
    
    Reviewers: austin
    
    Reviewed By: austin
    
    Subscribers: #ghc_windows_task_force, thomie, carter, simonmar
    
    Differential Revision: https://phabricator.haskell.org/D382
    
    GHC Trac Issues: #9367


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

45175e13edad452843207491d01cdbce0bedbbd4
 ghc/InteractiveUI.hs                          | 3 ++-
 testsuite/tests/ghci/scripts/Makefile         | 5 +++++
 testsuite/tests/ghci/scripts/T9367-raw.stdout | 6 ++++++
 testsuite/tests/ghci/scripts/T9367.hs         | 2 ++
 testsuite/tests/ghci/scripts/T9367.script     | 4 ++++
 testsuite/tests/ghci/scripts/all.T            | 4 ++++
 6 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 3192d20..ed4ea7b 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -2934,7 +2934,8 @@ listModuleLine modl line = do
 listAround :: MonadIO m => RealSrcSpan -> Bool -> InputT m ()
 listAround pan do_highlight = do
       contents <- liftIO $ BS.readFile (unpackFS file)
-      let ls  = BS.split '\n' contents
+      -- Drop carriage returns to avoid duplicates, see #9367.
+      let ls  = BS.split '\n' $ BS.filter (/= '\r') contents
           ls' = take (line2 - line1 + 1 + pad_before + pad_after) $
                         drop (line1 - 1 - pad_before) $ ls
           fst_line = max 1 (line1 - pad_before)
diff --git a/testsuite/tests/ghci/scripts/Makefile b/testsuite/tests/ghci/scripts/Makefile
index 73f6203..873de43 100644
--- a/testsuite/tests/ghci/scripts/Makefile
+++ b/testsuite/tests/ghci/scripts/Makefile
@@ -39,3 +39,8 @@ ghci056_setup:
 T6106_prep:
 	'$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make T6106_preproc
 
+.PHONY: T9367
+T9367:
+	'$(TEST_HC)' $(TEST_HC_OPTS) --interactive -v0 -ignore-dot-ghci                   < T9367.script > T9367-raw.run.stdout
+	cmp T9367-raw.run.stdout T9367-raw.stdout
+
diff --git a/testsuite/tests/ghci/scripts/T9367-raw.stdout b/testsuite/tests/ghci/scripts/T9367-raw.stdout
new file mode 100644
index 0000000..69da032
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9367-raw.stdout
@@ -0,0 +1,6 @@
+Breakpoint 0 activated at T9367.hs:1:5-9
+"Stopped at T9367.hs:1:5-9
+_result :: [Char] = _
+1  x = "abc"
+       ^^^^^
+2  main = print x
diff --git a/testsuite/tests/ghci/scripts/T9367.hs b/testsuite/tests/ghci/scripts/T9367.hs
new file mode 100644
index 0000000..0f24fa4
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9367.hs
@@ -0,0 +1,2 @@
+x = "abc"
+main = print x
diff --git a/testsuite/tests/ghci/scripts/T9367.script b/testsuite/tests/ghci/scripts/T9367.script
new file mode 100644
index 0000000..afc89a8
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9367.script
@@ -0,0 +1,4 @@
+:l T9367
+:b 1
+:main
+:list
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index ede9807..624f431 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -43,6 +43,10 @@ test('ghci024',
      when(fast(), skip),
      run_command,
      ['$MAKE -s --no-print-directory ghci024'])
+test('T9367',
+     when(fast() or config.os != 'mingw32', skip),
+     run_command,
+     ['$MAKE -s --no-print-directory T9367'])
 test('ghci025', normal, ghci_script, ['ghci025.script'])
 test('ghci026', normal, ghci_script, ['ghci026.script'])
 



More information about the ghc-commits mailing list