cpphs 1.20.4 → 1.20.5
raw patch · 8 files changed
+65/−29 lines, 8 filesdep −filepathdep ~directoryPVP ok
version bump matches the API change (PVP)
Dependencies removed: filepath
Dependency ranges changed: directory
API changes (from Hackage documentation)
+ Language.Preprocessor.Cpphs: cleanPath :: FilePath -> FilePath
Files
- CHANGELOG +3/−0
- Language/Preprocessor/Cpphs/Position.hs +9/−1
- Language/Preprocessor/Cpphs/ReadFirst.hs +19/−18
- Language/Preprocessor/Cpphs/RunCpphs.hs +3/−3
- README +1/−1
- cpphs.cabal +3/−3
- cpphs.hs +1/−1
- docs/index.html +26/−2
CHANGELOG view
@@ -3,6 +3,9 @@ * bugfixes for #if defined(FOO) && FOO(a,b) * (1.20.1): fix version number * (1.20.2): ensure all input/output is UTF8, regardless of locale+ * (1.20.3): detect an absolute windows path with a drive letter in a #include+ * (1.20.4): more windows path handling+ * (1.20.5): revert change in 1.20.4 Version 1.19 ------------
Language/Preprocessor/Cpphs/Position.hs view
@@ -17,6 +17,7 @@ , addcol, newline, tab, newlines, newpos , cppline, haskline, cpp2hask , filename, lineno, directory+ , cleanPath ) where import Data.List (isPrefixOf)@@ -38,7 +39,7 @@ -- | Constructor. Argument is filename. newfile :: String -> Posn-newfile name = Pn name 1 1 Nothing+newfile name = Pn (cleanPath name) 1 1 Nothing -- | Increment column number by given quantity. addcol :: Int -> Posn -> Posn@@ -96,3 +97,10 @@ dirname = reverse . safetail . dropWhile (not.(`elem`"\\/")) . reverse where safetail [] = [] safetail (_:x) = x++-- | Sigh. Mixing Windows filepaths with unix is bad. Make sure there is a+-- canonical path separator.+cleanPath :: FilePath -> FilePath+cleanPath [] = []+cleanPath ('\\':cs) = '/': cleanPath cs+cleanPath (c:cs) = c: cleanPath cs
Language/Preprocessor/Cpphs/ReadFirst.hs view
@@ -18,12 +18,11 @@ ) where import System.IO-import System.Directory (doesFileExist,findFile)-import System.FilePath (isRelative)+import System.Directory (doesFileExist) import Data.List (intersperse) import Control.Exception as E import Control.Monad (when)-import Language.Preprocessor.Cpphs.Position (Posn,directory)+import Language.Preprocessor.Cpphs.Position (Posn,directory,cleanPath) -- | Attempt to read the given file from any location within the search path. -- The first location found is returned, together with the file content.@@ -37,25 +36,27 @@ , String ) -- ^ discovered filepath, and file contents --readFirst name demand paths warn = do- case (isRelative name, directory demand) of- (False, _) -> try name []- (_, "") -> try name (".":paths)- (_, dd) -> try name (dd:".":paths)+readFirst name demand path warn =+ case name of+ nm@(c:':':_) -> try nm [""] -- Windows absolute path+ '/':nm -> try nm [""]+ _ -> try name (cons dd (".":path)) where- try name ds = do- file <- findFile ds name- case file of- Just f -> do- content <- readFileUTF8 f- return (f,content)- Nothing -> do+ dd = directory demand+ cons x xs = if null x then xs else x:xs+ try name [] = do+ when warn $ hPutStrLn stderr ("Warning: Can't find file \""++name ++"\" in directories\n\t"- ++concat (intersperse "\n\t" ds)+ ++concat (intersperse "\n\t" (cons dd (".":path))) ++"\n Asked for by: "++show demand)- return ("missing file: "++name,"")+ return ("missing file: "++name,"")+ try name (p:ps) = do+ let file = cleanPath p++'/':cleanPath name+ ok <- doesFileExist file+ if not ok then try name ps+ else do content <- readFileUTF8 file+ return (file,content) readFileUTF8 :: FilePath -> IO String readFileUTF8 file = do
Language/Preprocessor/Cpphs/RunCpphs.hs view
@@ -15,7 +15,7 @@ import Language.Preprocessor.Cpphs.Options (CpphsOptions(..), BoolOptions(..) ,trailing) import Language.Preprocessor.Cpphs.Tokenise (deWordStyle, tokenise)-import Language.Preprocessor.Cpphs.Position (Posn)+import Language.Preprocessor.Cpphs.Position (cleanPath, Posn) import Language.Preprocessor.Unlit as Unlit (unlit) @@ -31,7 +31,7 @@ preInc = case preInclude options of [] -> "" is -> concatMap (\f->"#include \""++f++"\"\n") is - ++ "#line 1 \""++filename++"\"\n"+ ++ "#line 1 \""++cleanPath filename++"\"\n" pass1 <- cppIfdef filename (defines options) (includes options) bools (preInc++input)@@ -58,7 +58,7 @@ preInc = case preInclude options of [] -> "" is -> concatMap (\f->"#include \""++f++"\"\n") is - ++ "#line 1 \""++filename++"\"\n"+ ++ "#line 1 \""++cleanPath filename++"\"\n" (pass2,syms) <- if macros bools then do pass1 <- cppIfdef filename (defines options) (includes options)
README view
@@ -30,7 +30,7 @@ COPYRIGHT ----------Copyright (c) 2004-2016 Malcolm Wallace (Malcolm.Wallace@me.com)+Copyright (c) 2004-2017 Malcolm Wallace (Malcolm.Wallace@me.com) LICENCE
cpphs.cabal view
@@ -1,5 +1,5 @@ Name: cpphs-Version: 1.20.4+Version: 1.20.5 Copyright: 2004-2017, Malcolm Wallace License: LGPL License-File: LICENCE-LGPL@@ -24,7 +24,7 @@ Extra-Source-Files: README, LICENCE-GPL, LICENCE-commercial, CHANGELOG, docs/cpphs.1, docs/index.html Library- Build-Depends: base>3&&<6, old-locale, old-time, directory, filepath, polyparse>=1.9+ Build-Depends: base>3&&<6, old-locale, old-time, directory, polyparse>=1.9 Exposed-Modules: Language.Preprocessor.Cpphs Language.Preprocessor.Unlit@@ -40,7 +40,7 @@ Language.Preprocessor.Cpphs.Tokenise Executable cpphs- Build-Depends: base>3&&<6, old-locale, old-time, directory, filepath, polyparse>=1.9+ Build-Depends: base>3&&<6, old-locale, old-time, directory, polyparse>=1.9 Main-Is: cpphs.hs Other-Modules: Language.Preprocessor.Cpphs
cpphs.hs view
@@ -21,7 +21,7 @@ import Data.List ( isPrefixOf ) version :: String-version = "1.20.4"+version = "1.20.5" main :: IO () main = do
docs/index.html view
@@ -198,11 +198,11 @@ <b>Current stable version:</b> <p>-cpphs-1.20.3, release date 2017-02-06<br>+cpphs-1.20.5, release date 2017-04-11<br> By HTTP: <a href="http://hackage.haskell.org/package/cpphs">Hackage</a>. <ul>-<li> (1.20.3) detect an absolute windows path with a drive letter in a #include+<li> (1.20.5) reverts the changes in 1.20.4 </ul> <p>@@ -224,6 +224,30 @@ <p> <b>Older versions:</b>++<p>+cpphs-1.20.5, release date 2017-04-11<br>+By HTTP:+<a href="http://hackage.haskell.org/package/cpphs">Hackage</a>.+<ul>+<li> (1.20.5) reverts the changes in 1.20.4+</ul>++<p>+cpphs-1.20.4, release date 2017-02-27<br>+By HTTP:+<a href="http://hackage.haskell.org/package/cpphs">Hackage</a>.+<ul>+<li> (1.20.4) more windows path handling+</ul>++<p>+cpphs-1.20.3, release date 2017-02-06<br>+By HTTP:+<a href="http://hackage.haskell.org/package/cpphs">Hackage</a>.+<ul>+<li> (1.20.3) detect an absolute windows path with a drive letter in a #include+</ul> <p> cpphs-1.20.2, release date 2016-09-05<br>