rushfort@esunix.UUCP (Kevin Rushforth) (01/17/87)
I have found two bugs in VC relating to the "@AVG" function. The first is an error in the gram.y file causing the function to be incorrectly recognized by the string "@AVE" instead of the correct "@AVG". The save file routine (P command) writes the average function out as "@avg" which is subsequently not recognized when the save file is read in (G command). The second bug occurs in the averaging routine itself when no valid values are found in the specified range. This causes a divide by 0 error which aborts execution on many machines. Following are the context diffs for "gram.y" and "interp.c" diff -c OLD/gram.y NEW/gram.y *** OLD/gram.y Fri Jan 16 22:29:56 1987 --- NEW/gram.y Fri Jan 16 22:29:15 1987 *************** *** 46,52 %token K_FIXED %token K_SUM %token K_PROD ! %token K_AVE %left '?' ':' %left '|' --- 46,52 ----- %token K_FIXED %token K_SUM %token K_PROD ! %token K_AVG %left '?' ':' %left '|' *************** *** 86,92 { $$ = new (O_REDUCE('+'), $4, $6); } | '@' K_PROD '(' var ':' var ')' { $$ = new (O_REDUCE('*'), $4, $6); } ! | '@' K_AVE '(' var ':' var ')' { $$ = new (O_REDUCE('a'), $4, $6); } | '(' e ')' { $$ = $2; } | '+' term { $$ = $2; } --- 86,92 ----- { $$ = new (O_REDUCE('+'), $4, $6); } | '@' K_PROD '(' var ':' var ')' { $$ = new (O_REDUCE('*'), $4, $6); } ! | '@' K_AVG '(' var ':' var ')' { $$ = new (O_REDUCE('a'), $4, $6); } | '(' e ')' { $$ = $2; } | '+' term { $$ = $2; } diff -c OLD/interp.c NEW/interp.c *** OLD/interp.c Fri Jan 16 22:30:31 1987 --- NEW/interp.c Fri Jan 16 22:29:15 1987 *************** *** 60,66 count++; } ! return (v / (double)count); } double eval(e) --- 60,69 ----- count++; } ! if(count == 0) ! return 0.0; ! else ! return (v / (double)count); } double eval(e) -- Kevin C. Rushforth Evans & Sutherland Computer Corporation UUCP Address: {ihnp4,decvax}!decwrl!esunix!rushfort Alternate: {ihnp4,seismo}!utah-cs!utah-gr!uplherc!esunix!rushfort