@@ -101,13 +101,20 @@ public static String getRelativeToCanonical(String path, String canonical,
101
101
102
102
if (path .equals (canonical )) return "" ;
103
103
104
- String path0 = path .replace ('\\' , '/' );
105
- String normCanonical0 = canonical .replace ('\\' , File .separatorChar );
106
- String normCanonical = normCanonical0 .endsWith (File .separator ) ?
107
- normCanonical0 : normCanonical0 + File .separator ;
104
+ // The following fixup of \\ is really to allow
105
+ // IndexDatabaseTest.testGetDefinitions() to succeed on Linux or macOS.
106
+ // That test has an assertion that operation is the "same for windows
107
+ // delimiters" and passes a path with backslashes. On Windows, the
108
+ // following fixup would not be needed, since File and Paths recognize
109
+ // backslash as a delimiter. On Linux and macOS, any backslash needs to
110
+ // be normalized.
111
+ path = path .replace ('\\' , File .separatorChar );
112
+ canonical = canonical .replace ('\\' , File .separatorChar );
113
+ String normCanonical = canonical .endsWith (File .separator ) ?
114
+ canonical : canonical + File .separator ;
108
115
Deque <String > tail = null ;
109
116
110
- File iterPath = new File (path0 );
117
+ File iterPath = new File (path );
111
118
while (iterPath != null ) {
112
119
String iterCanon = iterPath .getCanonicalPath ();
113
120
0 commit comments