cpphs 1.20.3 → 1.20.4
raw patch · 5 files changed
+26/−35 lines, 5 filesdep +filepathdep ~directoryPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: filepath
Dependency ranges changed: directory
API changes (from Hackage documentation)
- Language.Preprocessor.Cpphs: cleanPath :: FilePath -> FilePath
Files
- Language/Preprocessor/Cpphs/Position.hs +1/−9
- Language/Preprocessor/Cpphs/ReadFirst.hs +18/−19
- Language/Preprocessor/Cpphs/RunCpphs.hs +3/−3
- cpphs.cabal +3/−3
- cpphs.hs +1/−1
Language/Preprocessor/Cpphs/Position.hs view
@@ -17,7 +17,6 @@ , addcol, newline, tab, newlines, newpos , cppline, haskline, cpp2hask , filename, lineno, directory- , cleanPath ) where import Data.List (isPrefixOf)@@ -39,7 +38,7 @@ -- | Constructor. Argument is filename. newfile :: String -> Posn-newfile name = Pn (cleanPath name) 1 1 Nothing+newfile name = Pn name 1 1 Nothing -- | Increment column number by given quantity. addcol :: Int -> Posn -> Posn@@ -97,10 +96,3 @@ 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,11 +18,12 @@ ) where import System.IO-import System.Directory (doesFileExist)+import System.Directory (doesFileExist,findFile)+import System.FilePath (isRelative) import Data.List (intersperse) import Control.Exception as E import Control.Monad (when)-import Language.Preprocessor.Cpphs.Position (Posn,directory,cleanPath)+import Language.Preprocessor.Cpphs.Position (Posn,directory) -- | Attempt to read the given file from any location within the search path. -- The first location found is returned, together with the file content.@@ -36,27 +37,25 @@ , String ) -- ^ discovered filepath, and file contents -readFirst name demand path warn =- case name of- nm@(c:':':_) -> try nm [""] -- Windows absolute path- '/':nm -> try nm [""]- _ -> try name (cons dd (".":path))++readFirst name demand paths warn = do+ case (isRelative name, directory demand) of+ (False, _) -> try name []+ (_, "") -> try name (".":paths)+ (_, dd) -> try name (dd:".":paths) where- dd = directory demand- cons x xs = if null x then xs else x:xs- try name [] = do- when warn $+ try name ds = do+ file <- findFile ds name+ case file of+ Just f -> do+ content <- readFileUTF8 f+ return (f,content)+ Nothing -> do hPutStrLn stderr ("Warning: Can't find file \""++name ++"\" in directories\n\t"- ++concat (intersperse "\n\t" (cons dd (".":path)))+ ++concat (intersperse "\n\t" ds) ++"\n Asked for by: "++show demand)- 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)+ return ("missing file: "++name,"") 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 (cleanPath, Posn)+import Language.Preprocessor.Cpphs.Position (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 \""++cleanPath filename++"\"\n"+ ++ "#line 1 \""++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 \""++cleanPath filename++"\"\n"+ ++ "#line 1 \""++filename++"\"\n" (pass2,syms) <- if macros bools then do pass1 <- cppIfdef filename (defines options) (includes options)
cpphs.cabal view
@@ -1,5 +1,5 @@ Name: cpphs-Version: 1.20.3+Version: 1.20.4 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, polyparse>=1.9+ Build-Depends: base>3&&<6, old-locale, old-time, directory, filepath, 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, polyparse>=1.9+ Build-Depends: base>3&&<6, old-locale, old-time, directory, filepath, 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.3"+version = "1.20.4" main :: IO () main = do