summaryrefslogtreecommitdiff
path: root/Annex/View.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-08 12:45:32 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-08 12:45:32 -0400
commit6b4fc5e985ed96e14ebc89e67b373dd66c857bc5 (patch)
treeae3df8f2b4f5bee6bc41b0b339e1277601044815 /Annex/View.hs
parentdc70490577892424bffe1f87b73a54adff6fb988 (diff)
view: Avoid using cute unicode homomorphs for '/' and '\' and instead use ugly escaping, as the unicode method doesn't work on non-unicode supporting systems.
Diffstat (limited to 'Annex/View.hs')
-rw-r--r--Annex/View.hs28
1 files changed, 9 insertions, 19 deletions
diff --git a/Annex/View.hs b/Annex/View.hs
index f724889af..92a7ffc48 100644
--- a/Annex/View.hs
+++ b/Annex/View.hs
@@ -226,32 +226,22 @@ toViewPath :: MetaValue -> FilePath
toViewPath = concatMap escapeslash . fromMetaValue
where
escapeslash c
- | c == '/' = [pseudoSlash]
- | c == '\\' = [pseudoBackslash]
- | c == pseudoSlash = [pseudoSlash, pseudoSlash]
- | c == pseudoBackslash = [pseudoBackslash, pseudoBackslash]
+ | c == '/' = "%_"
+ | c == '\\' = "%."
+ | c == '%' = "%%"
| otherwise = [c]
fromViewPath :: FilePath -> MetaValue
fromViewPath = toMetaValue . deescapeslash []
where
deescapeslash s [] = reverse s
- deescapeslash s (c:cs)
- | c == pseudoSlash = case cs of
- (c':cs')
- | c' == pseudoSlash -> deescapeslash (pseudoSlash:s) cs'
- _ -> deescapeslash ('/':s) cs
- | c == pseudoBackslash = case cs of
- (c':cs')
- | c' == pseudoBackslash -> deescapeslash (pseudoBackslash:s) cs'
- _ -> deescapeslash ('/':s) cs
- | otherwise = deescapeslash (c:s) cs
+ deescapeslash s ('%':'_':cs) = deescapeslash ('/':s) cs
+ deescapeslash s ('%':'.':cs) = deescapeslash ('\\':s) cs
+ deescapeslash s ('%':'%':cs) = deescapeslash ('%':s) cs
+ deescapeslash s (c:cs) = deescapeslash (c:s) cs
-pseudoSlash :: Char
-pseudoSlash = '\8725' -- '∕' /= '/'
-
-pseudoBackslash :: Char
-pseudoBackslash = '\9586' -- '╲' /= '\'
+prop_viewPath_roundtrips :: MetaValue -> Bool
+prop_viewPath_roundtrips v = fromViewPath (toViewPath v) == v
pathProduct :: [[FilePath]] -> [FilePath]
pathProduct [] = []