Menu

#4 Doesn't work with paths containing spaces [+patch]

open
nobody
None
5
2009-01-03
2009-01-03
Anonymous
No

On my windows machine running Ganymede and v0.1.1 of the tool I commonly have my projects or my workspace at a location whose path contains spaces. E.g. "C:\Program Files\Eclipse_RCP\workspace". Unfortunately this breaks the tool as LaunchExternalDiffTool.java simply replaces the %first and %second markers with the two file paths and then splits by " " which doesn't result in each path ending up in a single argument given to the diff tool.

The following patch fixes this issue by doing the split before the markers are substituted:

91,93c90,91
< String modCmdLineArgs = commandLineArgs.replaceAll("%first", firstArg);
< String modCmdLineArgs2 = modCmdLineArgs.replaceAll("%second", secondArg);
< String[] cmdLineSplit = modCmdLineArgs2.split(" ");
---
> String[] cmdLineSplit = commandLineArgs.split(" "); // TODO this can break if there are options containing spaces enclosed within quotes in but they're unlikely to be present ...
94,99c93,101
<
<
<
< String[] cmdLine = new String[size + 1];
<
---
> for(int index = 0; index < size; index++) {
> if (cmdLineSplit[index].equals("%first")) {
> cmdLineSplit[index] = firstArg;
> } else if (cmdLineSplit[index].equals("%second")) {
> cmdLineSplit[index] = secondArg;
> }
> }
>
> String[] cmdLine = new String[size + 1];
133c135
< "A problem occurred trying to start your External diff Toool. Please check the settings under Window | Preferences | General | Compare/External Tool.");
---
> "A problem occurred trying to start your External diff Tool. Please check the settings under Window | Preferences | General | Compare/External Tool.");

Discussion


Log in to post a comment.