This is a patch (cvs diff tonight) that fixes a formula parsing bug that
was resulting in an index out of bounds on teh forumla string.
Basically, it didn't know when to stop asking for more characters.
Also uncommented the Multiply and Devide ops which seem to work.
(attached)
Index: jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java
===================================================================
RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java,v
retrieving revision 1.23
diff -u -r1.23 FormulaParser.java
--- jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java 6 Jul 2002 18:45:16 -0000 1.23
+++ jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java 12 Jul 2002 01:56:00 -0000
@@ -89,6 +89,7 @@
private String formulaString;
private int pointer=0;
+ private int formulaLength;
private List tokens = new java.util.Stack();
//private Stack tokens = new java.util.Stack();
@@ -112,11 +113,19 @@
formulaString = formula;
pointer=0;
this.book = book;
+ formulaLength = formulaString.length();
}
/** Read New Character From Input Stream */
private void GetChar() {
+ // Check to see if we've walked off the end of the string.
+ // Just return if so and reset Look to smoething to keep
+ // SkipWhitespace from spinning
+ if (pointer == formulaLength) {
+ Look = (char)0;
+ return;
+ }
Look=formulaString.charAt(pointer++);
//System.out.println("Got char: "+Look);
}
@@ -419,8 +428,8 @@
while (IsAddop(Look)) {
if ( Look == '+' ) Add();
if (Look == '-') Subtract();
- // if (Look == '*') Multiply();
- // if (Look == '/') Divide();
+ if (Look == '*') Multiply();
+ if (Look == '/') Divide();
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>