Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDavid Inglis2004-08-20 15:27:21 -0400
committerDavid Inglis2004-08-20 15:27:21 -0400
commit8abbfa146e497b5db11402cc5ad28adb6d0b89f2 (patch)
tree471cedc628c3a5bf379e275ca7be4a5c2961de5a /build
parentf599a0998b513813e893edd3feae6164d3c0a645 (diff)
downloadorg.eclipse.cdt-8abbfa146e497b5db11402cc5ad28adb6d0b89f2.tar.gz
org.eclipse.cdt-8abbfa146e497b5db11402cc5ad28adb6d0b89f2.tar.xz
org.eclipse.cdt-8abbfa146e497b5db11402cc5ad28adb6d0b89f2.zip
fixed buggy encoding/decoding of environment strings
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java34
1 files changed, 25 insertions, 9 deletions
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
index ccd4b7c015a..da7fbb489b1 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
@@ -234,19 +234,34 @@ public class BuildInfoFactory {
protected Map decodeMap(String value) {
Map map = new HashMap();
+ StringBuffer envStr = new StringBuffer(value);
try {
- while (value != null && value.length() > 0) {
+ while (envStr.length() > 0) {
int ndx = 0;
- while (value.charAt(ndx) != '|' || (ndx != 0 && value.charAt(ndx - 1) == '\\')) {
+ while (ndx < envStr.length() ) {
+ if (envStr.charAt(ndx) == '|') {
+ if (envStr.charAt(ndx - 1) == '\\') { // escaped '|' - remove '\' and continue on.
+ envStr.deleteCharAt(ndx - 1);
+ } else {
+ break;
+ }
+ }
ndx++;
}
- StringBuffer line = new StringBuffer(value.substring(0, ndx));
+ StringBuffer line = new StringBuffer(envStr.substring(0, ndx));
int lndx = 0;
- while (line.charAt(lndx) != '=' || (lndx != 0 && line.charAt(lndx - 1) == '\\')) {
+ while (lndx < line.length() ) {
+ if (line.charAt(lndx) == '=') {
+ if (line.charAt(lndx - 1) == '\\') { // escaped '=' - remove '\' and continue on.
+ line.deleteCharAt(lndx - 1);
+ } else {
+ break;
+ }
+ }
lndx++;
}
map.put(line.substring(0, lndx), line.substring(lndx + 1));
- value = value.substring(ndx+1);
+ envStr.delete(0, ndx+1);
}
} catch (StringIndexOutOfBoundsException e) {
}
@@ -260,7 +275,7 @@ public class BuildInfoFactory {
Entry entry = (Entry) entries.next();
str.append(escapeChars((String) entry.getKey(), "=|")); //$NON-NLS-1$
str.append("="); //$NON-NLS-1$
- str.append(escapeChars((String) entry.getValue(), "=|)")); //$NON-NLS-1$
+ str.append(escapeChars((String) entry.getValue(), "|")); //$NON-NLS-1$
str.append("|"); //$NON-NLS-1$
}
return str.toString();
@@ -269,8 +284,9 @@ public class BuildInfoFactory {
protected String escapeChars(String string, String escapeChars) {
StringBuffer str = new StringBuffer(string);
for(int i = 0; i < str.length(); i++) {
- if ( escapeChars.indexOf(str.charAt(i)) != -1) {
- str.insert(i-1, '\\');
+ if ( escapeChars.indexOf(str.charAt(i)) != -1 ) {
+ str.insert(i, '\\');
+ i++;
}
}
return str.toString();
@@ -361,7 +377,7 @@ public class BuildInfoFactory {
}
protected String getString(String name) {
- return (String) args.get(name);
+ return args.get(name) != null ? (String)args.get(name) : "";
}
protected String getBuilderID() {

Back to the top