Commit c434a767 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Fix cabal_macros.h for package names containing '-'

As with the Paths_pkgname module, we map '-' to '_' as the
former is not a valid character in cpp macro identifiers.
Fixes cpp redefinition warnings. First reported by gwern.
parent a237d34d
...@@ -40,7 +40,7 @@ generate _pkg_descr lbi = concat $ ...@@ -40,7 +40,7 @@ generate _pkg_descr lbi = concat $
"/* DO NOT EDIT: This file is automatically generated by Cabal */\n\n" : "/* DO NOT EDIT: This file is automatically generated by Cabal */\n\n" :
[ concat [ concat
["/* package ",display pkgid," */\n" ["/* package ",display pkgid," */\n"
,"#define MIN_VERSION_",display name,"(major1,major2,minor) \\\n" ,"#define MIN_VERSION_",pkgname,"(major1,major2,minor) \\\n"
," (major1) < ",major1," || \\\n" ," (major1) < ",major1," || \\\n"
," (major1) == ",major1," && (major2) < ",major2," || \\\n" ," (major1) == ",major1," && (major2) < ",major2," || \\\n"
," (major1) == ",major1," && (major2) == ",major2," && (minor) <= ",minor ," (major1) == ",major1," && (major2) == ",major2," && (minor) <= ",minor
...@@ -48,4 +48,8 @@ generate _pkg_descr lbi = concat $ ...@@ -48,4 +48,8 @@ generate _pkg_descr lbi = concat $
] ]
| pkgid@(PackageIdentifier name version) <- packageDeps lbi | pkgid@(PackageIdentifier name version) <- packageDeps lbi
, let (major1:major2:minor:_) = map show (versionBranch version ++ repeat 0) , let (major1:major2:minor:_) = map show (versionBranch version ++ repeat 0)
pkgname = map fixchar (display name)
] ]
where fixchar '-' = '_'
fixchar c = c
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment