summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Yang2013-10-17 13:03:18 (EDT)
committerChris Recoskie2013-10-17 13:03:18 (EDT)
commita944959fc1ea103c176abae014b63c6a8c6b53fd (patch)
tree325daadef8387c06b40c15c3fb86a27ff50a5088
parent55b0ddca1de2277deab7b62a014f7bec1d10ce55 (diff)
downloadorg.eclipse.ptp-a944959fc1ea103c176abae014b63c6a8c6b53fd.zip
org.eclipse.ptp-a944959fc1ea103c176abae014b63c6a8c6b53fd.tar.gz
org.eclipse.ptp-a944959fc1ea103c176abae014b63c6a8c6b53fd.tar.bz2
Bug 417292 - Escape Character Added to Build Variable String Inside
Quotes Signed-off-by: Yang Yang <bjyangyy@cn.ibm.com>>
-rw-r--r--rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteMakeBuilder.java30
1 files changed, 23 insertions, 7 deletions
diff --git a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteMakeBuilder.java b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteMakeBuilder.java
index 5e780fe..8cf11cd 100644
--- a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteMakeBuilder.java
+++ b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteMakeBuilder.java
@@ -521,7 +521,7 @@ public class RemoteMakeBuilder extends MakeBuilder {
// Then split the line by space would be safe.
// After resolve each variable, will finally have:
// test d e build h="i j k" 'l m'
- String regex = "[$\\{,\\(,\\[,\",\'].*?[\\},\\),\\],\",\']"; //$NON-NLS-1$
+ String regex = "(\\{.*?\\})|(\\(.*?\\))|(\\[.*?\\])|(\".*?\")|(\\'.*?\')"; // //$NON-NLS-1$
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(args);
UUID uuid = UUID.randomUUID();
@@ -571,17 +571,33 @@ public class RemoteMakeBuilder extends MakeBuilder {
char[] array = string.toCharArray();
ArrayList<String> aList = new ArrayList<String>();
StringBuffer buffer = new StringBuffer();
- boolean inComment = false;
+ boolean doubleQuote = false;
+ boolean singleQuote = false;
for (int i = 0; i < array.length; i++) {
char c = array[i];
- if (array[i] == '"' || array[i] == '\'') {
+ if (c == '"') {
if (i > 0 && array[i - 1] == '\\') {
- inComment = false;
- } else {
- inComment = !inComment;
+ doubleQuote = false;
+ } else if (doubleQuote){
+ // Met the second double quotes, and will split on next space.
+ // So reset the doubleComment flag and singleComment flag to false;
+ doubleQuote = !doubleQuote;
+ singleQuote = false;
+ }else {
+ // Met the first double quotes, so change the flag to indicate inside the doubleComment
+ doubleQuote = !doubleQuote;
+ }
+ }else if (c == '\''){
+ if (i > 0 && array[i - 1] == '\\') {
+ singleQuote = false;
+ } else if (singleQuote){
+ singleQuote = !singleQuote;
+ doubleQuote = false;
+ }else {
+ singleQuote = !singleQuote;
}
}
- if (c == ' ' && !inComment) {
+ if (c == ' ' && ( !doubleQuote && !singleQuote)) {
aList.add(buffer.toString());
buffer = new StringBuffer();
} else {