From: <ha...@us...> - 2007-02-08 20:23:32
|
Revision: 6724 http://svn.sourceforge.net/jmol/?rev=6724&view=rev Author: hansonr Date: 2007-02-08 12:23:27 -0800 (Thu, 08 Feb 2007) Log Message: ----------- 11.0 compiler fix for decimal point prior to semicolon and alpha (bug introduced 5/6/06 in rev. 5076) Modified Paths: -------------- branches/v11_0/Jmol/src/org/jmol/viewer/Compiler.java Modified: branches/v11_0/Jmol/src/org/jmol/viewer/Compiler.java =================================================================== --- branches/v11_0/Jmol/src/org/jmol/viewer/Compiler.java 2007-02-08 17:00:24 UTC (rev 6723) +++ branches/v11_0/Jmol/src/org/jmol/viewer/Compiler.java 2007-02-08 20:23:27 UTC (rev 6724) @@ -233,7 +233,7 @@ ltoken.addElement(new Token(Token.decimal, new Float(value))); continue; } - if (lookingAtDecimal((tokCommand & Token.negnums) != 0)) { + if (lookingAtDecimal()) { value = // can't use parseFloat with jvm 1.1 // Float.parseFloat(script.substring(ichToken, ichToken + cchToken)); @@ -387,8 +387,7 @@ char ch; int ichEnd = ichToken; int ichFirstSharp = -1; - while (ichEnd < cchScript && (ch = script.charAt(ichEnd)) != ';' - && ch != '\r' && ch != '\n') { + while (ichEnd < cchScript && !eol(ch = script.charAt(ichEnd))) { if (ch == '#' && ichFirstSharp == -1) { ichFirstSharp = ichEnd; //Logger.debug("I see a first sharp @ " + ichFirstSharp); @@ -436,6 +435,10 @@ return true; } + boolean eol(char ch) { + return (ch == ';' || ch == '\r' || ch == '\n'); + } + boolean lookingAtEndOfLine() { //log("lookingAtEndOfLine"); if (ichToken >= cchScript) @@ -568,9 +571,7 @@ boolean lookingAtSpecialString() { int ichT = ichToken; - char ch; - while (ichT < cchScript && (ch = script.charAt(ichT)) != ';' && ch != '\r' - && ch != '\n') + while (ichT < cchScript && !eol(script.charAt(ichT))) ++ichT; cchToken = ichT - ichToken; log("lookingAtSpecialString cchToken=" + cchToken); @@ -627,7 +628,7 @@ return (float) value; } - boolean lookingAtDecimal(boolean allowNegative) { + boolean lookingAtDecimal() { if (ichToken == cchScript) return false; int ichT = ichToken; @@ -635,27 +636,24 @@ ++ichT; boolean digitSeen = false; char ch = 'X'; - while (ichT < cchScript && Character.isDigit(ch = script.charAt(ichT))) { - ++ichT; + while (ichT < cchScript && Character.isDigit(ch = script.charAt(ichT++))) digitSeen = true; - } - if (ichT == cchScript || ch != '.') + if (ch != '.') return false; + // only here if "dddd." + // to support 1.ca, let's check the character after the dot // to determine if it is an alpha - if (ch == '.' - && (ichT + 1 < cchScript) - && (Character.isLetter(script.charAt(ichT + 1)) || script - .charAt(ichT + 1) == '?')) - return false; - //well, guess what? we also have to look for 86.1Na, so... - if (ch == '.' - && (ichT + 2 < cchScript) - && (Character.isLetter(script.charAt(ichT + 2)) || script - .charAt(ichT + 2) == '?')) - return false; - - ++ichT; + char ch1; + if (ichT < cchScript && !eol(ch1 = script.charAt(ichT))) { + if (Character.isLetter(ch1) || ch1 == '?') + return false; + //well, guess what? we also have to look for 86.1Na, so... + //watch out for moveto..... 56.;refresh... + if (ichT + 1 < cchScript + && (Character.isLetter(ch1 = script.charAt(ichT + 1)) || ch1 == '?')) + return false; + } while (ichT < cchScript && Character.isDigit(script.charAt(ichT))) { ++ichT; digitSeen = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |