|
From: <ho...@us...> - 2004-02-27 02:52:51
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2928/src Modified Files: display_text.c evaluate.c parser_stuff.c variables.c Log Message: Added considerations about math library that improve portability Index: display_text.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display_text.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** display_text.c 27 Feb 2004 00:34:07 -0000 1.1 --- display_text.c 27 Feb 2004 02:44:28 -0000 1.2 *************** *** 69,73 **** if (base==10) { // base 10 -> EASY output_text= (char *) malloc (50 + extra_size); ! sprintf (output_text, "%-15.10Lg\n", ResultValue ()); } else { // other base result= ResultValue (); --- 69,73 ---- if (base==10) { // base 10 -> EASY output_text= (char *) malloc (50 + extra_size); ! sprintf (output_text, FORMAT_STRING, ResultValue ()); } else { // other base result= ResultValue (); Index: evaluate.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/evaluate.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** evaluate.c 4 Feb 2004 02:54:25 -0000 1.10 --- evaluate.c 27 Feb 2004 02:44:28 -0000 1.11 *************** *** 21,25 **** - // // Sets up rad_to_any to perform the right angle conversion --- 21,24 ---- *************** *** 46,92 **** VALUE_TYPE result=(VALUE_TYPE) 0.; ! if (id==FUN_ABS) result= fabsl (arg); ! if (id==FUN_SIN) result= sinl (arg/rad_to_any); ! if (id==FUN_COS) result= cosl (arg/rad_to_any); ! if (id==FUN_TAN) result= tanl (arg/rad_to_any); ! if (id==FUN_ASIN) { if (arg<(VALUE_TYPE) -1. || arg>(VALUE_TYPE) 1.) NotifyError (PERROR_INVALID_ARG_ASIN, NULL); ! else result= rad_to_any*asinl (arg); } ! if (id==FUN_ACOS) { if (arg<(VALUE_TYPE) -1. || arg>(VALUE_TYPE) 1.) NotifyError (PERROR_INVALID_ARG_ACOS, NULL); ! result= rad_to_any*acosl (arg); } ! if (id==FUN_ATAN) result= rad_to_any*atanl (arg); ! if (id==FUN_SINH) result= sinhl (arg/rad_to_any); ! if (id==FUN_COSH) result= coshl (arg/rad_to_any); ! if (id==FUN_TANH) result= tanhl (arg/rad_to_any); ! if (id==FUN_ASINH) result= rad_to_any*asinhl (arg); ! if (id==FUN_ACOSH) result= rad_to_any*acoshl (arg); ! if (id==FUN_ATANH) result= rad_to_any*atanhl (arg); ! if (id==FUN_EXP) result= expl (arg); ! if (id==FUN_LN) { if (arg<=0.0) NotifyError (PERROR_INVALID_ARG_LN, NULL); ! else result= logl (arg); } ! if (id==FUN_EXP10) result= powl (10, arg); ! if (id==FUN_LOG) { if (arg<=0.0) NotifyError (PERROR_INVALID_ARG_LOG, NULL); ! else result= log10l (arg); } ! if (id==FUN_SQRT) { if (arg<=0.) NotifyError (PERROR_INVALID_ARG_SQRT, NULL); ! else result= sqrtl (arg); } ! if (id==FUN_INT) { ! result= nearbyintl (arg); } ! if (id==FUN_FLOOR) { ! result= floorl (arg); } ! if (id==FUN_CEIL) { ! result= ceill (arg); } CheckNumber (result); --- 45,92 ---- VALUE_TYPE result=(VALUE_TYPE) 0.; ! if (id==FUNID_ABS) result= FUN_ABS (arg); ! if (id==FUNID_SIN) result= FUN_SIN (arg/rad_to_any); ! if (id==FUNID_COS) result= FUN_COS (arg/rad_to_any); ! if (id==FUNID_TAN) result= FUN_TAN (arg/rad_to_any); ! if (id==FUNID_ASIN) { if (arg<(VALUE_TYPE) -1. || arg>(VALUE_TYPE) 1.) NotifyError (PERROR_INVALID_ARG_ASIN, NULL); ! else result= rad_to_any*FUN_ASIN (arg); } ! if (id==FUNID_ACOS) { if (arg<(VALUE_TYPE) -1. || arg>(VALUE_TYPE) 1.) NotifyError (PERROR_INVALID_ARG_ACOS, NULL); ! result= rad_to_any*FUN_ACOS (arg); } ! if (id==FUNID_ATAN) result= rad_to_any*FUN_ATAN (arg); ! if (id==FUNID_SINH) result= FUN_SINH (arg/rad_to_any); ! if (id==FUNID_COSH) result= FUN_COSH (arg/rad_to_any); ! if (id==FUNID_TANH) result= FUN_TANH (arg/rad_to_any); ! if (id==FUNID_ASINH) result= rad_to_any*FUN_ASINH (arg); ! if (id==FUNID_ACOSH) result= rad_to_any*FUN_ACOSH (arg); ! if (id==FUNID_ATANH) result= rad_to_any*FUN_ATANH (arg); ! if (id==FUNID_EXP) result= FUN_EXP (arg); ! if (id==FUNID_LN) { if (arg<=0.0) NotifyError (PERROR_INVALID_ARG_LN, NULL); ! else result= FUN_LN (arg); } ! if (id==FUNID_EXP10) result= FUN_EXP10 (10, arg); ! if (id==FUNID_LOG) { if (arg<=0.0) NotifyError (PERROR_INVALID_ARG_LOG, NULL); ! else result= FUN_LOG (arg); } ! if (id==FUNID_SQRT) { if (arg<=0.) NotifyError (PERROR_INVALID_ARG_SQRT, NULL); ! else result= FUN_SQRT (arg); } ! if (id==FUNID_INT) { ! if (FUN_FLOOR (arg) + 0.5 > arg) result= FUN_FLOOR (arg); ! else result= FUN_CEIL (arg); } ! if (id==FUNID_FLOOR) { ! result= FUN_FLOOR (arg); } ! if (id==FUNID_CEIL) { ! result= FUN_CEIL (arg); } CheckNumber (result); *************** *** 162,166 **** value= arg1/arg2; // check if division by zero occured ! if (isinf (value)) NotifyError (PERROR_DIVISION_ZERO, NULL); return value; } --- 162,166 ---- value= arg1/arg2; // check if division by zero occured ! if (ISINF (value)) NotifyError (PERROR_DIVISION_ZERO, NULL); return value; } *************** *** 186,190 **** VALUE_TYPE value; ! value= fmodl (arg1, arg2); return value; } --- 186,190 ---- VALUE_TYPE value; ! value= FUN_MOD (arg1, arg2); return value; } *************** *** 198,202 **** VALUE_TYPE value; ! value= powl (arg1, arg2); CheckNumber (value); return value; --- 198,202 ---- VALUE_TYPE value; ! value= FUN_EXP10 (arg1, arg2); CheckNumber (value); return value; *************** *** 230,235 **** void CheckNumber (VALUE_TYPE value) { ! if (isinf (value)) NotifyError (PERROR_OVERFLOW, NULL); ! if (isnan (value)) NotifyError (PERROR_NAN, NULL); } --- 230,235 ---- void CheckNumber (VALUE_TYPE value) { ! if (ISINF ((double) value)) NotifyError (PERROR_OVERFLOW, NULL); ! if (isnan ((double) value)) NotifyError (PERROR_NAN, NULL); } *************** *** 248,252 **** if (base==10) { // base 10, we can do non integer stuff ! strtod (strnumber, NULL); value= strtod (strnumber, &tail); if (*tail!='\0') { // error parsing number --- 248,252 ---- if (base==10) { // base 10, we can do non integer stuff ! //strtold (strnumber, NULL); value= strtod (strnumber, &tail); if (*tail!='\0') { // error parsing number Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** parser_stuff.c 4 Feb 2004 02:54:32 -0000 1.16 --- parser_stuff.c 27 Feb 2004 02:44:28 -0000 1.17 *************** *** 162,166 **** epos= pos; ! while (isdigit (input[epos]) || isalpha (input[epos]) || input[epos]=='.') ++epos; // we've got an 'entry', lets check it --- 162,167 ---- epos= pos; ! while (isdigit ((int) input[epos]) || isalpha ((int) input[epos]) ! || input[epos]=='.') ++epos; // we've got an 'entry', lets check it *************** *** 171,175 **** (input[epos]=='+' || input[epos]=='-')) { ++epos; ! while (isdigit (input[epos])) ++epos; } // if 'syntactically' opened or closed --- 172,176 ---- (input[epos]=='+' || input[epos]=='-')) { ++epos; ! while (isdigit ((int) input[epos])) ++epos; } // if 'syntactically' opened or closed Index: variables.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/variables.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** variables.c 4 Feb 2004 01:06:38 -0000 1.2 --- variables.c 27 Feb 2004 02:44:28 -0000 1.3 *************** *** 65,69 **** if (isalpha (name[0]) || name[0]=='_') { ! while (isalpha (name[i]) || isdigit (name[i]) || name[i]=='_') ++i; if (name[i]=='\0') ok= 1; } --- 65,69 ---- if (isalpha (name[0]) || name[0]=='_') { ! while (isalpha ((int) name[i]) || isdigit ((int) name[i]) || name[i]=='_') ++i; if (name[i]=='\0') ok= 1; } |