Ticket #3975: normalise-trailing-dot.patch

File normalise-trailing-dot.patch, 3.6 KB (added by conrad, 3 years ago)
Line 
1Thu Feb 11 11:52:51 JST 2010  Conrad Parker <conrad@metadecks.org>
2  * normalise: Handle trailing "." in path names
3 
4  For example, (normalise "../.") was returning "../.", now ".."
5 
6  This patch modifies dropDots such that the check for (".":[]) only
7  occurs once for the path, after which a driver function dropDots' is
8  used which skips this check. Hence "." can be removed from the
9  end of a longer path, but a path of just "." is unchanged.
10
11New patches:
12
13[normalise: Handle trailing "." in path names
14Conrad Parker <conrad@metadecks.org>**20100211025251
15 Ignore-this: 290b1f6bfde981cfa26dd1c9019be5b5
16 
17 For example, (normalise "../.") was returning "../.", now ".."
18 
19 This patch modifies dropDots such that the check for (".":[]) only
20 occurs once for the path, after which a driver function dropDots' is
21 used which skips this check. Hence "." can be removed from the
22 end of a longer path, but a path of just "." is unchanged.
23] hunk ./System/FilePath/Internal.hs 700
24         propSep (x:xs) = x : propSep xs
25         propSep [] = []
26 
27-        dropDots acc (".":xs) | not $ null xs = dropDots acc xs
28-        dropDots acc (x:xs) = dropDots (x:acc) xs
29-        dropDots acc [] = reverse acc
30+        dropDots acc ["."] = ["."]
31+        dropDots acc xs = dropDots' acc xs
32+
33+        dropDots' acc (".":xs) = dropDots' acc xs
34+        dropDots' acc (x:xs) = dropDots' (x:acc) xs
35+        dropDots' acc [] = reverse acc
36 
37 normaliseDrive :: FilePath -> FilePath
38 normaliseDrive drive | isPosix = drive
39
40Context:
41
42[lower base requirement down to base-2
43Sergei Trofimovich <slyfox@community.haskell.org>**20091216213421
44 Ignore-this: 51811f50ae13b1772cda99d532f72372
45 At least ghc-6.6.1 is able to build it without problems.
46 (package can be used in cabal-1.8, which is known to work
47 on ghc-6.4+)
48]
49[Bump the version number
50Ian Lynagh <igloo@earth.li>**20100119132830]
51[correct punctuation in Synopsis (#3762)
52Simon Marlow <marlowsd@gmail.com>**20091216095818
53 Ignore-this: 4e3f848e771344db079cd363caba0082
54]
55[UNDO: The current directory is ".", not "" (GHC bug #2034) (patch version 2)
56Simon Marlow <marlowsd@gmail.com>**20091104122943
57 Ignore-this: 93c3643daca557cead63e3853fbd30e0
58 
59 rolling back accidentally pushed patch:
60 
61 Wed Nov  4 10:50:57 GMT 2009  Simon Marlow <marlowsd@gmail.com>
62   * The current directory is ".", not "" (GHC bug #2034) (patch version 2)
63]
64[The current directory is ".", not "" (GHC bug #2034) (patch version 2)
65Simon Marlow <marlowsd@gmail.com>**20091104105057
66 Ignore-this: 4042cd0afb71d8c69a98d0d7c4da99bb
67   
68 So now
69         splitFileName "foo" = ("./", "foo")
70 
71 which gives us the additional property that
72 
73 > Valid x => isValid (fst (splitFileName x))
74 
75 This property is important, because it means that we can pass the
76 result of takeDirectory to any of the functions in System.Directory,
77 whereas previously we would have to check for the empty case first.
78 
79 After discussion on the libraries list, I removed the second part of
80 the original change:
81 
82         "." </> x = x
83 
84 This small bit of normalisation was there to ensure that the property
85 
86 > Valid x => uncurry </> (splitFileName x) == x
87 
88 still held.  However, it was arguably inconsistent (see the
89 discussion).  Now this property has an exception:
90 
91 > Valid x => uncurry (</>) (splitFileName x) == x || fst (splitFileName x) == "./"
92 
93 This is a small price to pay to gain the new property above.
94]
95[Bump version to 1.1.0.3
96Ian Lynagh <igloo@earth.li>**20090920141902]
97[Fix "Cabal check" warnings
98Ian Lynagh <igloo@earth.li>**20090811215908]
99[TAG 2009-06-25
100Ian Lynagh <igloo@earth.li>**20090625160245]
101Patch bundle hash:
10297b3e6aa900d1bae00b88fed07ce61fe73219807