summaryrefslogtreecommitdiffstats
path: root/PATCHES/0004-Windows-Use-not-in-progpath-and-leave-case-as-is.patch
blob: 7b6a6be8d62132402046afd9dead6d5f4ecb2d4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 233bc23e32c5213255d8391dede53aa0b61ec23f Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 5 Aug 2015 23:36:09 +0100
Subject: [PATCH 04/15] Windows: Use '/' not '\' in progpath and leave case
 as-is

Windows can handle both '/' and '\' dirseps. GCC will
have been built using Cygwin, MSYS* or cross-compiled
from a system where dirsep is '/' so it is cleaner to
force the dirseps to be '/' and keep the case as-is.

This way, the value will be consistent with the build
system and string operations, be they internal to GCC
or external to it (e.g. processing map files with sed)
have a better chance of working as expected.

A concrete instance of when this matters is when cross
compiling GNU/Linux glibc on Windows.
---
 libiberty/lrealpath.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c
index b27c8de..8165984 100644
--- a/libiberty/lrealpath.c
+++ b/libiberty/lrealpath.c
@@ -138,15 +138,26 @@ lrealpath (const char *filename)
   {
     char buf[MAX_PATH];
     char* basename;
+    char* slash;
     DWORD len = GetFullPathName (filename, MAX_PATH, buf, &basename);
     if (len == 0 || len > MAX_PATH - 1)
       return strdup (filename);
     else
       {
-	/* The file system is case-preserving but case-insensitive,
-	   Canonicalize to lowercase, using the codepage associated
-	   with the process locale.  */
-        CharLowerBuff (buf, len);
+	/* Turn all back slashes back into forward slashes
+	   and don't make it lowercase.
+	   Rationale:
+	   Windows is as happy with / as it is with \. This will
+	   have been built using Cygwin, MSYS* or cross-compiled
+	   from a system where dirsep is / so it is cleaner just
+	   to keep the dirseps as / (and the case un-modified).
+	   This way, the value will be consistent with the build
+	   system and string operations (be they internal to this
+	   software or external to it, e.g. processing map files
+	   with sed) work as expected.  */
+	slash = buf;
+	while ((slash = strchr(slash,'\\')) !=  NULL)
+	  *slash = '/';
         return strdup (buf);
       }
   }
-- 
2.8.1