summaryrefslogtreecommitdiff
path: root/java/src/Ice/PropertiesI.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/Ice/PropertiesI.java')
-rw-r--r--java/src/Ice/PropertiesI.java59
1 files changed, 31 insertions, 28 deletions
diff --git a/java/src/Ice/PropertiesI.java b/java/src/Ice/PropertiesI.java
index d78651ae2d7..cc266f79004 100644
--- a/java/src/Ice/PropertiesI.java
+++ b/java/src/Ice/PropertiesI.java
@@ -431,47 +431,50 @@ public final class PropertiesI implements Properties
{
String s = line;
- int hash = s.indexOf('#');
- if(hash == 0)
- {
- return; // ignore comment lines
- }
- else if(hash != -1)
+ //
+ // Remove comments and unescape #'s
+ //
+ int idx = 0;
+ while((idx = s.indexOf("#", idx)) != -1)
{
- s = s.substring(0, hash);
+ if(idx == 0 || s.charAt(idx - 1) != '\\')
+ {
+ s = s.substring(0, idx);
+ break;
+ }
+ ++idx;
}
+ s = s.replace("\\#", "#");
- s = s.trim();
-
- final char[] arr = s.toCharArray();
- int end = -1;
- for(int i = 0; i < arr.length; i++)
+ //
+ // Split key/value and unescape ='s
+ //
+ int split = -1;
+ idx = 0;
+ while((idx = s.indexOf("=", idx)) != -1)
{
- if(arr[i] == ' ' || arr[i] == '\t' || arr[i] == '\r' || arr[i] == '\n' || arr[i] == '=')
+ if(idx == 0 || s.charAt(idx - 1) != '\\')
{
- end = i;
+ split = idx;
break;
}
+ ++idx;
}
- if(end == -1)
+ if(split == 0 || split == -1)
{
+ s = s.trim();
+ if(s.length() != 0)
+ {
+ Ice.Util.getProcessLogger().warning("invalid config file entry: \"" + line + "\"");
+ }
return;
}
- String key = s.substring(0, end);
+ String key = s.substring(0, split).trim();
+ String value = s.substring(split + 1, s.length()).trim();
- end = s.indexOf('=', end);
- if(end == -1)
- {
- return;
- }
- ++end;
-
- String value = "";
- if(end < s.length())
- {
- value = s.substring(end).trim();
- }
+ key = key.replace("\\=", "=");
+ value = value.replace("\\=", "=");
setProperty(key, value);
}