From da9df79e538949f700d89fbde49b6677ff7a99ca Mon Sep 17 00:00:00 2001 From: Scott Tepavich Date: Wed, 7 Nov 2012 13:02:26 -0800 Subject: [PATCH] Bug 393791 - Cannot substitute Windows path to Unix path on Linux --- .../sourcelookup/MapEntrySourceContainer.java | 52 +++++++++---------- .../MapEntrySourceContainerType.java | 2 +- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java index 8735d96e3b6..751c3ed9636 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java @@ -74,34 +74,32 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { public static IPath createPath(String path) { if (path == null) return null; - if (path.contains("\\")) { //$NON-NLS-1$ - // handle Windows slashes and canonicalize - path = path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // also check for device or UNC - int firstSep = path.indexOf("/"); //$NON-NLS-1$ - int idx = path.indexOf(":"); //$NON-NLS-1$ - // ':' indicates a Windows device separator if it comes before - // the first segment separator - if (idx > 0 && (firstSep < 0 || idx < firstSep)) { - String device = path.substring(0, idx + 1); - path = path.substring(idx + 1); - return new Path(path).setDevice(device); - } else { - // Cygwin or UNC path - if (path.startsWith("//")) { //$NON-NLS-1$ - String network; - idx = path.indexOf("/", 2); //$NON-NLS-1$ - if (idx > 0) { - network = path.substring(0, idx); - path = path.substring(idx); - } else { - network = path; - path = ""; //$NON-NLS-1$ - } - return new Path(network, path).makeUNC(true); + + // Check for windows full-path formatting. + if (path.matches("^([a-zA-Z])[:](.*)$")) { //$NON-NLS-1$ + String device = null; + String missingfile = path.replace("\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$ + int idx = missingfile.indexOf(":"); //$NON-NLS-1$ + if ( idx > 0 ) { + device = missingfile.substring(0, idx + 1); + missingfile = missingfile.substring(idx + 1); } + return new Path(device, missingfile); + } + + int idx = 0; + // Cygwin or UNC path + if (path.startsWith("//")) { //$NON-NLS-1$ + String network; + idx = path.indexOf("/", 2); //$NON-NLS-1$ + if (idx > 0) { + network = path.substring(0, idx); + path = path.substring(idx); + } else { + network = path; + path = ""; //$NON-NLS-1$ + } + return new Path(network, path).makeUNC(true); } // fallthrough diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainerType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainerType.java index 7e536e80630..a87f1fe3f52 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainerType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainerType.java @@ -37,7 +37,7 @@ public class MapEntrySourceContainerType extends AbstractSourceContainerTypeDele Element element = (Element)node; if (ELEMENT_NAME.equals(element.getNodeName())) { String path = element.getAttribute(BACKEND_PATH); - IPath backend = new Path(path); + IPath backend = MapEntrySourceContainer.createPath(path); if (!backend.isValidPath(path)) { abort(InternalSourceLookupMessages.MapEntrySourceContainerType_0, null); }