[LON-CAPA-cvs] cvs: capa /capa51/pProj capaParserUtils.c
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 23 Jan 2007 07:10:16 -0000
albertel Tue Jan 23 02:10:16 2007 EDT
Modified files:
/capa/capa51/pProj capaParserUtils.c
Log:
- divide by zero was not being noticed (part of bug4751)
Index: capa/capa51/pProj/capaParserUtils.c
diff -u capa/capa51/pProj/capaParserUtils.c:1.18 capa/capa51/pProj/capaParserUtils.c:1.19
--- capa/capa51/pProj/capaParserUtils.c:1.18 Thu Dec 1 17:10:36 2005
+++ capa/capa51/pProj/capaParserUtils.c Tue Jan 23 02:10:14 2007
@@ -1470,13 +1470,20 @@
/* difference to see if it was satisfied */
/* RETURN: 0 no error */
/* 1 error */
+/* 2 parse error */
int
f_eval_formula(f_val, f_str, v_str, pt_str) double *f_val;char *f_str;char *v_str; char *pt_str;
{
int var_cnt;
-
+ extern int ErrorMsg_count;
+ extern char * ErrorMsg_p;
/* before setup formula symbol tree, make sure it is clean */
-
+ if(ErrorMsg_p) {
+ capa_mfree(ErrorMsg_p);
+ ErrorMsg_p = NULL;
+ ErrorMsg_count = 0;
+ }
+
var_cnt = setup_formula_id(v_str,pt_str);
/* printf("\nSETUP formula ID (%s),(%s) returned %d\n",v_str,pt_str,var_cnt); */
/* copy the formula into lexer buffer */
@@ -1486,6 +1493,9 @@
FormulaParseOK = 1;
fml_parse(); /* main entry point */
if( FormulaParseOK ) {
+ if( ErrorMsg_count > 0 ) {
+ return (2);
+ }
*f_val = FormulaVal;
/* printf("\nEVAL formulaOK = (%.16g)\n",FormulaVal); */
return (0);