packages feed

hgettext 0.1.40 → 0.1.40.1

raw patch · 5 files changed

+51/−28 lines, 5 filesdep ~Cabaldep ~basedep ~containers

Dependency ranges changed: Cabal, base, containers, deepseq, split

Files

CHANGELOG.md view
@@ -1,5 +1,12 @@-0.1.40-======+### 0.1.40.1++_Andreas Abel, 2022-09-19_++- Allow `Cabal ≥ 2.4` ([#15](https://github.com/haskell-hvr/hgettext/issues/15), thanks Claudio Bley!)++Tested with GHC 7.4 - 9.4.++## 0.1.40  _Andreas Abel, 2022-09-04_ 
hgettext.cabal view
@@ -1,6 +1,6 @@ cabal-version:       1.14 name:                hgettext-version:             0.1.40+version:             0.1.40.1 build-type:          Simple  license:             BSD3@@ -19,12 +19,11 @@                      A user-contributed tutorial can be found in the [Haskell Wiki](https://wiki.haskell.org/Internationalization_of_Haskell_programs_using_gettext).  tested-with:-  -- Constraint Cabal < 2.1 prevents building with GHC > 8.6-  -- GHC == 9.4.2-  -- GHC == 9.2.4-  -- GHC == 9.0.2-  -- GHC == 8.10.7-  -- GHC == 8.8.4+  GHC == 9.4.2+  GHC == 9.2.4+  GHC == 9.0.2+  GHC == 8.10.7+  GHC == 8.8.4   GHC == 8.6.5   GHC == 8.4.4   GHC == 8.2.2@@ -48,9 +47,8 @@   other-modules:     Internal    hs-source-dirs:    src-  build-depends:     base             >=4.5    && <4.13-                   , Cabal            >=1.14   && <1.25 || >= 2.0 && < 2.3-                       -- Cabal >= 2.4 fails on matchGlobFile+  build-depends:     base             >=4.5    && <4.18+                   , Cabal            >=1.14   && <1.25 || >= 2.0 && < 2.5 || >=3.0 && <3.9                    , containers       >=0.4.2  && <0.7                    , directory        >=1.1    && <1.4                    , filepath         >=1.3    && <1.5
src-exe/hgettext.hs view
@@ -74,12 +74,12 @@                   , x == f]  showStringLit :: String -> String-showStringLit s0 = '"' : concatMap showChar s0 ++ "\""+showStringLit s0 = '"' : concatMap showChr s0 ++ "\""     where-      showChar '"' = "\\\""-      showChar '\\' = "\\\\"-      showChar '\n' = "\\n"-      showChar c = return c+      showChr '"' = "\\\""+      showChr '\\' = "\\\\"+      showChr '\n' = "\\n"+      showChr c = return c  formatMessage :: String -> [(FilePath, Int)] -> String formatMessage s locs = unlines $
src/Distribution/Simple/I18N/GetText.hs view
@@ -78,7 +78,7 @@ import           Distribution.Simple.InstallDirs    as I import           Distribution.Simple.LocalBuildInfo import           Distribution.Simple.Setup-import           Distribution.Simple.Utils+import           Distribution.Simple.Utils          (warn) import           Distribution.Verbosity  import           Control.Arrow                      (second)@@ -90,7 +90,7 @@ import           System.FilePath import           System.Process -import           Internal+import           Internal                           (fromPackageName, matchFileGlob)  -- | Default main function, same as --@@ -125,11 +125,13 @@ updateLocalBuildInfo :: LocalBuildInfo -> LocalBuildInfo updateLocalBuildInfo l =     let sMap = getCustomFields l-        [domDef, catDef] = map ($ sMap) [getDomainDefine, getMsgCatalogDefine]+        domDef = getDomainDefine sMap+        catDef = getMsgCatalogDefine sMap         dom = getDomainNameDefault sMap (getPackageName l)         tar = targetDataDir l-        [catMS, domMS] = map (uncurry formatMacro) [(domDef, dom), (catDef, tar)]-    in (appendCPPOptions [domMS,catMS] . appendExtension [EnableExtension CPP]) l+        catMS = formatMacro domDef dom+        domMS = formatMacro catDef tar+    in appendCPPOptions [domMS,catMS] $ appendExtension [EnableExtension CPP] l  installPOFiles :: Verbosity -> LocalBuildInfo -> IO () installPOFiles verb l =@@ -150,7 +152,7 @@             -- only warn for now, as the package may still be usable even if the msg catalogs are missing             ExitFailure n -> warn verb ("'msgfmt' exited with non-zero status (rc = " ++ show n ++ ")")     in do-      filelist <- getPoFilesDefault sMap+      filelist <- getPoFilesDefault verb l sMap       -- copy all whose name is in the form of dir/{loc}.po to the       -- destDir/{loc}/LC_MESSAGES/dom.mo       -- with the 'msgfmt' tool@@ -179,8 +181,8 @@     where updBuildInfo x = x{cppOptions = updOpts (cppOptions x)}           updOpts s = nub (s ++ opts) -formatMacro :: Show a => [Char] -> a -> [Char]-formatMacro name value = "-D" ++ name ++ "=" ++ (show value)+formatMacro :: Show a => String -> a -> String+formatMacro name value = "-D" ++ name ++ "=" ++ show value  targetDataDir :: LocalBuildInfo -> FilePath targetDataDir l =@@ -208,10 +210,10 @@ getMsgCatalogDefine :: [(String, String)] -> String getMsgCatalogDefine al = findInParametersDefault al "x-gettext-msg-cat-def" "__MESSAGE_CATALOG_DIR__" -getPoFilesDefault :: [(String, String)] -> IO [String]-getPoFilesDefault al = toFileList $ findInParametersDefault al "x-gettext-po-files" ""+getPoFilesDefault :: Verbosity -> LocalBuildInfo  -> [(String, String)] -> IO [String]+getPoFilesDefault verb l al = toFileList $ findInParametersDefault al "x-gettext-po-files" ""     where toFileList "" = return []-          toFileList x  = liftM concat $ mapM matchFileGlob $ split' x+          toFileList x  = liftM concat $ mapM (matchFileGlob verb (localPkgDescr l)) $ split' x           -- from Blow your mind (HaskellWiki)           -- splits string by newline, space and comma           split' x = concatMap lines $ concatMap words $ unfoldr (\b -> fmap (const . (second $ drop 1) . break (==',') $ b) . listToMaybe $ b) x
src/Internal.hs view
@@ -3,10 +3,26 @@ module Internal where  import           Distribution.Simple+#if MIN_VERSION_Cabal(2,4,0)+import           Distribution.Simple.Glob    (matchDirFileGlob)+import           Distribution.Types.PackageDescription+#else+import qualified Distribution.Simple.Utils   as Utils (matchFileGlob)+import           Distribution.PackageDescription+#endif+import           Distribution.Verbosity      (Verbosity)  fromPackageName :: PackageName -> String #if MIN_VERSION_Cabal(2,0,0) fromPackageName = unPackageName #else fromPackageName (PackageName s) = s+#endif++matchFileGlob :: Verbosity -> PackageDescription -> FilePath -> IO [FilePath]+#if MIN_VERSION_Cabal(2,4,0)+-- | Newer versions of Cabal have removed this function in favour of more configurable implementation+matchFileGlob verb descr = matchDirFileGlob verb (specVersion descr) "."+#else+matchFileGlob _ _ = Utils.matchFileGlob #endif