stevel 02/03/18 22:30:52
Modified: src/main/org/apache/tools/ant ProjectHelper.java
Log:
no code changes, only comments to make sense of what is going on
Revision Changes Path
1.80 +19 -6
jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
Index: ProjectHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- ProjectHelper.java 11 Mar 2002 13:01:48 -0000 1.79
+++ ProjectHelper.java 19 Mar 2002 06:30:52 -0000 1.80
@@ -438,25 +438,36 @@
* <code>${</code> without a closing
* <code>}</code>
*/
- public static void parsePropertyString(String value, Vector fragments,
Vector propertyRefs)
+ public static void parsePropertyString(String value, Vector fragments,
Vector propertyRefs)
throws BuildException {
int prev = 0;
int pos;
+ //search for the next instance of $ from the 'prev' position
while ((pos = value.indexOf("$", prev)) >= 0) {
+
+ //if there was any text before this, add it as a fragment
+ //TODO, this check could me modified to go if pos>prev;
+ //seems like this current version could stick empty strings
+ //into the list
if (pos > 0) {
fragments.addElement(value.substring(prev, pos));
}
-
- if (pos == (value.length() - 1)) {
+ //if we are at the end of the string, we tack on a $
+ //then move past it
+ if( pos == (value.length() - 1)) {
fragments.addElement("$");
prev = pos + 1;
- } else if (value.charAt(pos + 1) != '{' ) {
+ }
+ //peek ahead to see if the next char is a property or not
+ else if (value.charAt(pos + 1) != '{' ) {
+ //not a property: insert the char as a literal
fragments.addElement(value.substring(pos + 1, pos + 2));
prev = pos + 2;
} else {
+ //property found, extract its name or bail on a typo
int endName = value.indexOf('}', pos);
if (endName < 0) {
- throw new BuildException("Syntax error in property: "
+ throw new BuildException("Syntax error in property: "
+ value );
}
String propertyName = value.substring(pos + 2, endName);
@@ -465,9 +476,11 @@
prev = endName + 1;
}
}
-
+ //no more $ signs found
+ //if there is any tail to the file, append it
if (prev < value.length()) {
fragments.addElement(value.substring(prev));
}
}
+//end class
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>