From: <ha...@us...> - 2006-03-22 12:29:34
|
Revision: 4681 Author: hansonr Date: 2006-03-22 04:29:28 -0800 (Wed, 22 Mar 2006) ViewCVS: http://svn.sourceforge.net/jmol/?rev=4681&view=rev Log Message: ----------- Eval: just adding some error traps; some may be unnecessary. Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Eval.java Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-03-22 02:43:59 UTC (rev 4680) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-03-22 12:29:28 UTC (rev 4681) @@ -738,6 +738,10 @@ evalError("variable undefined:" + varName); } + void endOfStatementUnexpected() throws ScriptException { + evalError("unexpected end of script command"); + } + void badArgumentCount() throws ScriptException { evalError("bad argument count"); } @@ -1769,6 +1773,8 @@ Hashtable variables = new Hashtable(); void define() throws ScriptException { + if (statementLength == 1) + keywordExpected(); String variable = (String) statement[1].value; variables.put(variable, (expression(statement, 2))); } @@ -1813,6 +1819,8 @@ int i = 1; // ignore optional file format String filename = "fileset"; + if (statementLength == 1) + filenameExpected(); if (statement[i].tok == Token.identifier) ++i; if (statement[i].tok != Token.string) @@ -2148,6 +2156,8 @@ } void script() throws ScriptException { + if (statementLength == 1) + endOfStatementUnexpected(); if (statement[1].tok != Token.string) filenameExpected(); pushContext(); @@ -2173,6 +2183,8 @@ } void translate() throws ScriptException { + if (statementLength <3) + endOfStatementUnexpected(); if (statement[2].tok != Token.integer) integerExpected(); int percent = statement[2].intValue; @@ -2198,6 +2210,8 @@ } void zoom() throws ScriptException { + if (statementLength == 1) + endOfStatementUnexpected(); if (statement[1].tok == Token.integer) { int percent = statement[1].intValue; if (percent < 5 || percent > Viewer.MAXIMUM_ZOOM_PERCENTAGE) @@ -2220,6 +2234,8 @@ void delay() throws ScriptException { long timeBegin = System.currentTimeMillis(); long millis = 0; + if (statementLength == 1) + endOfStatementUnexpected(); Token token = statement[1]; switch (token.tok) { case Token.integer: @@ -2315,6 +2331,8 @@ } void slab() throws ScriptException { + if (statementLength == 1) + endOfStatementUnexpected(); if (statement[1].tok == Token.integer) { int percent = statement[1].intValue; if (percent < 0 || percent > 100) @@ -2612,6 +2630,8 @@ } void dots() throws ScriptException { + if (statementLength == 1) + endOfStatementUnexpected(); short mad = 0; switch (statement[1].tok) { case Token.on: @@ -2638,6 +2658,9 @@ void proteinShape(int shapeType) throws ScriptException { short mad = 0; + if (statementLength == 1) + endOfStatementUnexpected(); + int tok = statement[1].tok; switch (tok) { case Token.on: @@ -2883,6 +2906,8 @@ */ void set() throws ScriptException { + if (statementLength == 1) + endOfStatementUnexpected(); switch (statement[1].tok) { case Token.axes: setAxes(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |