[commit: hsc2hs] master: Fixes #12504: Double-escape paths used to build call to hsc_line (f5ae016)

git at git.haskell.org git at git.haskell.org
Wed Aug 31 17:18:47 UTC 2016


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

On branch  : master
Link       : http://git.haskell.org/hsc2hs.git/commitdiff/f5ae016e5a69ebf42d612805e51afd9227df9389

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

commit f5ae016e5a69ebf42d612805e51afd9227df9389
Author: Richard Cook <rcook at rcook.org>
Date:   Mon Aug 22 12:14:17 2016 -0700

    Fixes #12504: Double-escape paths used to build call to hsc_line
    
    In outHsLine, paths passed to construct invocations of hsc_line must be escaped
    twice in order to generate a properly escaped string literal that will end up
    in the eventual LINE pragma emitted by this code. This is especially important
    on Windows paths, where backslashes would otherwise be treated as C escape
    sequences and result in the incorrect Windows paths.
    
    See https://ghc.haskell.org/trac/ghc/ticket/12504


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

f5ae016e5a69ebf42d612805e51afd9227df9389
 C.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/C.hs b/C.hs
index dd02f43..f742be7 100644
--- a/C.hs
+++ b/C.hs
@@ -185,7 +185,7 @@ outCLine (SourcePos name line) =
 outHsLine :: SourcePos -> String
 outHsLine (SourcePos name line) =
     "    hsc_line ("++show (line + 1)++", \""++
-    showCString name++"\");\n"
+    (showCString . showCString) name ++ "\");\n"
 
 showCString :: String -> String
 showCString = concatMap showCChar



More information about the ghc-commits mailing list