ccache: applied a number of patches from the ccache-win32 issue tracker
[msysgit.git] / src / ccache-win32 / patches / 0004-ccache-handle-both-forward-and-backward-slashes-as-p.patch
blobee6fac25aa73aa73ad20b878f3a26f8bf8030e94
1 From c7d25bb9c54af16d70f98bff1bc55de314023d7a Mon Sep 17 00:00:00 2001
2 From: Pat Thoyts <patthoyts@users.sourceforge.net>
3 Date: Wed, 15 May 2013 13:25:52 +0100
4 Subject: [PATCH] ccache: handle both forward and backward slashes as path
5 names
7 I was using a mingw ccache from these sources, when it started complaining
8 about not being able to unlink files from the Administrator home directory.
10 So what should have been happening was deleting stuff from
12 C:\Dokumente und Einstellungen\Administrator\.ccache
14 What happened is that the program interpreted
16 dirname("C:\Dokumente und Einstellungen\Administrator/.ccache")
18 as "C:\Dokumente und Einstellungen" due to the dirname code not properly
19 seeing "/" as seperator. So this can be fixed by rewriting dirname() as in
20 the patch I'll attach.
22 [ccache-win32 issue #7]
24 Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
25 ---
26 util.c | 11 ++++++-----
27 1 file changed, 6 insertions(+), 5 deletions(-)
29 diff --git a/util.c b/util.c
30 index 531883d..c129914 100644
31 --- a/util.c
32 +++ b/util.c
33 @@ -285,12 +285,13 @@ char *str_basename(const char *s)
34 /* return the dir name of a file - caller frees */
35 char *dirname(char *s)
37 - char *p;
38 + char *p, *delim;
39 s = x_strdup(s);
40 - p = strrchr(s, '/');
41 - p = strrchr(s, '\\');
42 - if (p) {
43 - *p = 0;
44 + for (p = s; *p; p++)
45 + if (*p == '/' || *p == '\\')
46 + delim = p;
47 + if (delim) {
48 + *delim = 0;
50 return s;
52 --
53 1.8.1.msysgit.1