Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-05-17 00:57:17 +0000
committerDoug Schaefer2017-05-17 00:57:17 +0000
commit43e62924a1b24840057e9d0af5ed4e79fd5305a7 (patch)
tree44a60a796eb2edfb2962e0a1c48c709e2f2027e5 /toolchains
parent4b2e1e5b41cf92bf022759fa851be1a348dd598f (diff)
downloadorg.eclipse.cdt-43e62924a1b24840057e9d0af5ed4e79fd5305a7.tar.gz
org.eclipse.cdt-43e62924a1b24840057e9d0af5ed4e79fd5305a7.tar.xz
org.eclipse.cdt-43e62924a1b24840057e9d0af5ed4e79fd5305a7.zip
Bug 498171 Propagate scanner info fix for Arduino.
Diffstat (limited to 'toolchains')
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java55
1 files changed, 47 insertions, 8 deletions
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
index e610c9fb582..01ba5a08f1f 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
@@ -18,7 +18,6 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -129,6 +128,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
return super.getAdapter(adapter);
}
+ @Override
public String getLaunchMode() {
return launchMode;
}
@@ -556,7 +556,8 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
throw Activator.coreException("Upload command not specified", null);
}
if (isWindows) {
- return splitCommand(command);
+ List<String> args = splitCommand(command);
+ return args.toArray(new String[args.size()]);
} else {
return new String[] { "sh", "-c", command }; //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -659,9 +660,9 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
}
ExtendedScannerInfo baseInfo = new ExtendedScannerInfo(null, includes);
- String[] command = splitCommand(commandString);
- IScannerInfo info = getToolChain().getScannerInfo(getBuildConfiguration(), Paths.get(command[0]),
- Arrays.copyOfRange(command, 1, command.length), baseInfo, resource, getBuildDirectoryURI());
+ List<String> command = splitCommand(commandString);
+ IScannerInfo info = getToolChain().getScannerInfo(getBuildConfiguration(), command,
+ baseInfo, resource, getBuildDirectoryURI());
// cache the results
cachedScannerInfo = info;
@@ -683,9 +684,47 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
return str;
}
- private String[] splitCommand(String command) {
- // TODO deal with quotes properly, for now just strip
- return command.replaceAll("\"", "").split("\\s+"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private List<String> splitCommand(String command) {
+ boolean inQuotes = false;
+ boolean inDouble = false;
+
+ List<String> args = new ArrayList<>();
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < command.length(); i++) {
+ char c = command.charAt(i);
+ switch (c) {
+ case ' ':
+ if (inQuotes || inDouble) {
+ builder.append(c);
+ } else if (builder.length() > 0) {
+ args.add(builder.toString());
+ builder = new StringBuilder();
+ }
+ break;
+ case '\'':
+ if (inDouble) {
+ builder.append(c);
+ } else {
+ inQuotes = !inQuotes;
+ }
+ break;
+ case '"':
+ if (inQuotes) {
+ builder.append(c);
+ } else {
+ inDouble = !inDouble;
+ }
+ break;
+ default:
+ builder.append(c);
+ }
+ }
+
+ if (builder.length() > 0) {
+ args.add(builder.toString());
+ }
+
+ return args;
}
@Override

Back to the top