Diff for /parser3/src/classes/math.C between versions 1.35 and 1.41

version 1.35, 2003/11/20 15:35:29 version 1.41, 2005/08/26 11:12:45
Line 1 Line 1
 /** @file  /** @file
         Parser: @b math parser class.          Parser: @b math parser class.
   
         Copyright(c) 2001-2003 ArtLebedev Group(http://www.artlebedev.com)          Copyright(c) 2001-2005 ArtLebedev Group(http://www.artlebedev.com)
         Author: Alexandr Petrosian <paf@design.ru>(http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru>(http://paf.design.ru)
   
         portions from gen_uuid.c,          portions from gen_uuid.c,
         Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o.          Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o.
 */  */
   
 static const char* IDENT_MATH_C="$Date$";  static const char * const IDENT_MATH_C="$Date$";
   
 #include "pa_vmethod_frame.h"  #include "pa_vmethod_frame.h"
 #include "pa_common.h"  #include "pa_common.h"
Line 164  static inline int _random(uint top) { Line 164  static inline int _random(uint top) {
 }  }
   
 static void _random(Request& r, MethodParams& params) {  static void _random(Request& r, MethodParams& params) {
         Value& range=params.as_junction(0, "range must be expression");          double top=params.as_double(0, "range must be expression", r);
         double top=r.process_to_value(range).as_double();  
         if(top<=0 || top>MAX_UINT)          if(top<=0 || top>MAX_UINT)
                 throw Exception("parser.runtime",                  throw Exception("parser.runtime",
                         0,                          0,
Line 181  static double degrees(double param) { re Line 180  static double degrees(double param) { re
 static double radians(double param) { return param /180 *PI; }  static double radians(double param) { return param /180 *PI; }
   
 static void math1(Request& r, MethodParams& params, math1_func_ptr func) {  static void math1(Request& r, MethodParams& params, math1_func_ptr func) {
         Value& param=params.as_junction(0, "parameter must be expression");          double param=params.as_double(0, "parameter must be expression", r);
           double result=func(param);
         double result=func(r.process_to_value(param).as_double());  
         r.write_no_lang(*new VDouble(result));          r.write_no_lang(*new VDouble(result));
 }  }
   
Line 208  MATH1(sqrt); Line 206  MATH1(sqrt);
   
 typedef double (*math2_func_ptr)(double, double);  typedef double (*math2_func_ptr)(double, double);
 static void math2(Request& r, MethodParams& params, math2_func_ptr func) {  static void math2(Request& r, MethodParams& params, math2_func_ptr func) {
         Value& a=params.as_junction(0, "parameter must be expression");          double a=params.as_double(0, "parameter must be expression", r);
         Value& b=params.as_junction(1, "parameter must be expression");          double b=params.as_double(1, "parameter must be expression", r);
           double result=func(a, b);
         double result=func(  
                 r.process_to_value(a).as_double(),  
                 r.process_to_value(b).as_double());  
         r.write_no_lang(*new VDouble(result));          r.write_no_lang(*new VDouble(result));
 }  }
   
Line 227  inline bool is_salt_body_char(int c) { Line 222  inline bool is_salt_body_char(int c) {
         return isalnum(c) || c == '.' || c=='/';          return isalnum(c) || c == '.' || c=='/';
 }  }
 static size_t calc_prefix_size(const char* salt) {  static size_t calc_prefix_size(const char* salt) {
         if(size_t salt_size=strlen(salt)) {          if(strlen(salt)) {
                 if(!is_salt_body_char(salt[0])) { // $...  {...                  if(!is_salt_body_char((unsigned char)salt[0])) { // $...  {...
                         const char* cur=salt+1; // skip                          const char* cur=salt+1; // skip
                         while(is_salt_body_char(*cur++)) // ...$  ...}                          while(is_salt_body_char((unsigned char)*cur++)) // ...$  ...}
                                 ;                                  ;
                         return cur-salt;                          return cur-salt;
                 } else                  } else

Removed from v.1.35  
changed lines
  Added in v.1.41


E-mail: