mux/src/funmath.cpp File Reference

#include "copyright.h"
#include "autoconf.h"
#include "config.h"
#include "externs.h"
#include <float.h>
#include <limits.h>
#include <math.h>
#include "functions.h"
#include "funmath.h"
#include "sha1.h"

Include dependency graph for funmath.cpp:

Go to the source code of this file.

Data Structures

union  SpecialFloatUnion
class  CSpellNum

Defines

#define MUX_FPGROUP_PASS   0x00
#define MUX_FPGROUP_ZERO   0x10
#define MUX_FPGROUP_PINF   0x20
#define MUX_FPGROUP_NINF   0x30
#define MUX_FPGROUP_IND   0x40
#define MUX_FPGROUP_NAN   0x50
#define MUX_FPGROUP(x)   ((x) & 0xF0)
#define MUX_FPCLASS_PINF   (MUX_FPGROUP_PINF|0)
#define MUX_FPCLASS_NINF   (MUX_FPGROUP_NINF|1)
#define MUX_FPCLASS_QNAN   (MUX_FPGROUP_IND |2)
#define MUX_FPCLASS_SNAN   (MUX_FPGROUP_NAN |3)
#define MUX_FPCLASS_ND   (MUX_FPGROUP_ZERO|4)
#define MUX_FPCLASS_NZ   (MUX_FPGROUP_ZERO|5)
#define MUX_FPCLASS_PZ   (MUX_FPGROUP_ZERO|6)
#define MUX_FPCLASS_PD   (MUX_FPGROUP_ZERO|7)
#define MUX_FPCLASS_PN   (MUX_FPGROUP_PASS|8)
#define MUX_FPCLASS_NN   (MUX_FPGROUP_PASS|9)
#define MUX_FPCLASS(x)   ((x) & 0x0F)
#define IEEE_MASK_SIGN   0x8000000000000000ull
#define IEEE_MASK_EXPONENT   0x7FF0000000000000ull
#define IEEE_MASK_MANTISSA   0x000FFFFFFFFFFFFFull
#define IEEE_MASK_QNAN   0x0008000000000000ull
#define ARBITRARY_NUMBER   1
#define IEEE_MAKE_TABLESIZE   5
#define VADD_F   0
#define VSUB_F   1
#define VMUL_F   2
#define VDOT_F   3
#define VCROSS_F   4

Functions

double MakeSpecialFloat (int iWhich)
static int mux_fpclass (double result)
static double AddWithError (double &err, double a, double b)
static double NearestPretty (double R)
static int DCL_CDECL f_comp_abs (const void *s1, const void *s2)
static double AddDoubles (int n, double pd[])
static void fval (char *buff, char **bufc, double result)
 FUNCTION (fun_add)
 FUNCTION (fun_ladd)
 FUNCTION (fun_iadd)
 FUNCTION (fun_sub)
 FUNCTION (fun_isub)
 FUNCTION (fun_mul)
 FUNCTION (fun_imul)
 FUNCTION (fun_gt)
 FUNCTION (fun_gte)
 FUNCTION (fun_lt)
 FUNCTION (fun_lte)
 FUNCTION (fun_eq)
 FUNCTION (fun_neq)
 FUNCTION (fun_max)
 FUNCTION (fun_min)
 FUNCTION (fun_sign)
 FUNCTION (fun_isign)
 FUNCTION (fun_shl)
 FUNCTION (fun_shr)
 FUNCTION (fun_inc)
 FUNCTION (fun_dec)
 FUNCTION (fun_trunc)
 FUNCTION (fun_fdiv)
 FUNCTION (fun_idiv)
 FUNCTION (fun_floordiv)
 FUNCTION (fun_mod)
 FUNCTION (fun_remainder)
 FUNCTION (fun_abs)
 FUNCTION (fun_iabs)
 FUNCTION (fun_dist2d)
 FUNCTION (fun_dist3d)
static void handle_vectors (char *vecarg1, char *vecarg2, char *buff, char **bufc, SEP *psep, SEP *posep, int flag)
 FUNCTION (fun_vadd)
 FUNCTION (fun_vsub)
 FUNCTION (fun_vmul)
 FUNCTION (fun_vdot)
 FUNCTION (fun_vcross)
 FUNCTION (fun_vmag)
 FUNCTION (fun_vunit)
 FUNCTION (fun_floor)
 FUNCTION (fun_ceil)
 FUNCTION (fun_round)
 FUNCTION (fun_pi)
 FUNCTION (fun_e)
static double ConvertRDG2R (double d, const char *szUnits)
static double ConvertR2RDG (double d, const char *szUnits)
 FUNCTION (fun_ctu)
 FUNCTION (fun_sin)
 FUNCTION (fun_cos)
 FUNCTION (fun_tan)
 FUNCTION (fun_asin)
 FUNCTION (fun_acos)
 FUNCTION (fun_atan)
 FUNCTION (fun_exp)
 FUNCTION (fun_power)
 FUNCTION (fun_fmod)
 FUNCTION (fun_ln)
 FUNCTION (fun_log)
 FUNCTION (fun_sqrt)
 FUNCTION (fun_isnum)
 FUNCTION (fun_israt)
 FUNCTION (fun_isint)
 FUNCTION (fun_and)
 FUNCTION (fun_or)
 FUNCTION (fun_andbool)
 FUNCTION (fun_orbool)
 FUNCTION (fun_cand)
 FUNCTION (fun_cor)
 FUNCTION (fun_candbool)
 FUNCTION (fun_corbool)
 FUNCTION (fun_xor)
 FUNCTION (fun_not)
 FUNCTION (fun_t)
 FUNCTION (fun_spellnum)
 FUNCTION (fun_roman)
 FUNCTION (fun_land)
 FUNCTION (fun_lor)
 FUNCTION (fun_band)
 FUNCTION (fun_bor)
 FUNCTION (fun_bnand)
 FUNCTION (fun_bxor)
 FUNCTION (fun_crc32)
 FUNCTION (fun_sha1)

Variables

static const char * mux_FPStrings [] = { "+Inf", "-Inf", "Ind", "NaN", "0", "0", "0", "0" }
static SpecialFloatUnion SpecialFloatTable [IEEE_MAKE_TABLESIZE]
static const long nMaximums [10]
static double g_aDoubles [LBUF_SIZE]
int const g_nDoubles = sizeof(g_aDoubles)/sizeof(double)
static const char * bigones []
static const char * singles []
static const char * teens []
static const char * tens []
static const char * th_prefix []


Define Documentation

#define ARBITRARY_NUMBER   1

Definition at line 60 of file funmath.cpp.

#define IEEE_MAKE_TABLESIZE   5

Definition at line 61 of file funmath.cpp.

#define IEEE_MASK_EXPONENT   0x7FF0000000000000ull

Definition at line 55 of file funmath.cpp.

Referenced by mux_fpclass().

#define IEEE_MASK_MANTISSA   0x000FFFFFFFFFFFFFull

Definition at line 56 of file funmath.cpp.

Referenced by mux_fpclass().

#define IEEE_MASK_QNAN   0x0008000000000000ull

Definition at line 57 of file funmath.cpp.

Referenced by mux_fpclass().

#define IEEE_MASK_SIGN   0x8000000000000000ull

Definition at line 54 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS (  )     ((x) & 0x0F)

Definition at line 46 of file funmath.cpp.

Referenced by FUNCTION(), and fval().

#define MUX_FPCLASS_ND   (MUX_FPGROUP_ZERO|4)

Definition at line 40 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_NINF   (MUX_FPGROUP_NINF|1)

Definition at line 37 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_NN   (MUX_FPGROUP_PASS|9)

Definition at line 45 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_NZ   (MUX_FPGROUP_ZERO|5)

Definition at line 41 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_PD   (MUX_FPGROUP_ZERO|7)

Definition at line 43 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_PINF   (MUX_FPGROUP_PINF|0)

Definition at line 36 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_PN   (MUX_FPGROUP_PASS|8)

Definition at line 44 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_PZ   (MUX_FPGROUP_ZERO|6)

Definition at line 42 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_QNAN   (MUX_FPGROUP_IND |2)

Definition at line 38 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPCLASS_SNAN   (MUX_FPGROUP_NAN |3)

Definition at line 39 of file funmath.cpp.

Referenced by mux_fpclass().

#define MUX_FPGROUP (  )     ((x) & 0xF0)

Definition at line 32 of file funmath.cpp.

Referenced by FUNCTION(), and fval().

#define MUX_FPGROUP_IND   0x40

Definition at line 30 of file funmath.cpp.

#define MUX_FPGROUP_NAN   0x50

Definition at line 31 of file funmath.cpp.

#define MUX_FPGROUP_NINF   0x30

Definition at line 29 of file funmath.cpp.

#define MUX_FPGROUP_PASS   0x00

Definition at line 26 of file funmath.cpp.

Referenced by FUNCTION(), and fval().

#define MUX_FPGROUP_PINF   0x20

Definition at line 28 of file funmath.cpp.

#define MUX_FPGROUP_ZERO   0x10

Definition at line 27 of file funmath.cpp.

Referenced by FUNCTION().

#define VADD_F   0

Definition at line 1036 of file funmath.cpp.

Referenced by FUNCTION(), and handle_vectors().

#define VCROSS_F   4

Definition at line 1040 of file funmath.cpp.

Referenced by FUNCTION(), and handle_vectors().

#define VDOT_F   3

Definition at line 1039 of file funmath.cpp.

Referenced by FUNCTION(), and handle_vectors().

#define VMUL_F   2

Definition at line 1038 of file funmath.cpp.

Referenced by FUNCTION(), and handle_vectors().

#define VSUB_F   1

Definition at line 1037 of file funmath.cpp.

Referenced by FUNCTION(), and handle_vectors().


Function Documentation

static double AddDoubles ( int  n,
double  pd[] 
) [static]

Definition at line 200 of file funmath.cpp.

References AddWithError(), f_comp_abs(), and NearestPretty().

Referenced by FUNCTION().

00201 {
00202     qsort(pd, n, sizeof(double), f_comp_abs);
00203     double sum = 0.0;
00204     if (0 < n)
00205     {
00206         sum = pd[0];
00207         double sum_err = 0.0;
00208         int i;
00209         for (i = 1; i < n; i++)
00210         {
00211             double addend_err;
00212             double addend = AddWithError(addend_err, sum_err, pd[i]);
00213             double sum1_err;
00214             double sum1 = AddWithError(sum1_err, sum, addend);
00215             sum = AddWithError(sum_err, sum1, addend_err + sum1_err);
00216         }
00217     }
00218     return NearestPretty(sum);
00219 }

static double AddWithError ( double &  err,
double  a,
double  b 
) [static]

Definition at line 131 of file funmath.cpp.

Referenced by AddDoubles().

00132 {
00133     double sum = a+b;
00134     err = b-(sum-a);
00135     return sum;
00136 }

static double ConvertR2RDG ( double  d,
const char *  szUnits 
) [static]

Definition at line 1576 of file funmath.cpp.

References mux_tolower.

Referenced by FUNCTION().

01577 {
01578     switch (mux_tolower(szUnits[0]))
01579     {
01580     case 'd':
01581         // Radians to Degrees.
01582         //
01583         d *= 57.29577951308232;
01584         break;
01585 
01586     case 'g':
01587         // Radians to Gradians.
01588         //
01589         d *= 63.66197723675813;
01590         break;
01591     }
01592     return d;
01593 }

static double ConvertRDG2R ( double  d,
const char *  szUnits 
) [static]

Definition at line 1557 of file funmath.cpp.

References mux_tolower.

Referenced by FUNCTION().

01558 {
01559     switch (mux_tolower(szUnits[0]))
01560     {
01561     case 'd':
01562         // Degrees to Radians.
01563         //
01564         d *= 0.017453292519943295;
01565         break;
01566 
01567     case 'g':
01568         // Gradians to Radians.
01569         //
01570         d *= 0.015707963267948967;
01571         break;
01572     }
01573     return d;
01574 }

static int DCL_CDECL f_comp_abs ( const void *  s1,
const void *  s2 
) [static]

Definition at line 179 of file funmath.cpp.

Referenced by AddDoubles().

00180 {
00181     double a = fabs(*(double *)s1);
00182     double b = fabs(*(double *)s2);
00183 
00184     if (a > b)
00185     {
00186         return -1;
00187     }
00188     else if (a < b)
00189     {
00190         return 1;
00191     }
00192     return 0;
00193 }

FUNCTION ( fun_sha1   ) 

Definition at line 2763 of file funmath.cpp.

References safe_str, SHA1_Compute(), SHA1_Final(), SHA1_Init(), and UNUSED_PARAMETER.

02764 {
02765     UNUSED_PARAMETER(executor);
02766     UNUSED_PARAMETER(caller);
02767     UNUSED_PARAMETER(enactor);
02768     UNUSED_PARAMETER(cargs);
02769     UNUSED_PARAMETER(ncargs);
02770 
02771     int i;
02772     SHA1_CONTEXT shac;
02773     SHA1_Init(&shac);
02774     for (i = 0; i < nfargs; i++)
02775     {
02776         SHA1_Compute(&shac, strlen(fargs[i]), fargs[i]);
02777     }
02778     SHA1_Final(&shac);
02779     for (i = 0; i <= 4; i++)
02780     {
02781         char buf[9];
02782         sprintf(buf, "%08X", shac.H[i]);
02783         safe_str(buf, buff, bufc);
02784     }
02785 }

FUNCTION ( fun_crc32   ) 

Definition at line 2746 of file funmath.cpp.

References CRC32_ProcessBuffer(), safe_i64toa(), and UNUSED_PARAMETER.

02747 {
02748     UNUSED_PARAMETER(executor);
02749     UNUSED_PARAMETER(caller);
02750     UNUSED_PARAMETER(enactor);
02751     UNUSED_PARAMETER(cargs);
02752     UNUSED_PARAMETER(ncargs);
02753 
02754     UINT32 ulCRC32 = 0;
02755     for (int i = 0; i < nfargs; i++)
02756     {
02757         int n = strlen(fargs[i]);
02758         ulCRC32 = CRC32_ProcessBuffer(ulCRC32, fargs[i], n);
02759     }
02760     safe_i64toa(ulCRC32, buff, bufc);
02761 }

FUNCTION ( fun_bxor   ) 

Definition at line 2722 of file funmath.cpp.

References is_integer(), mux_atoi64(), safe_i64toa(), safe_str, and UNUSED_PARAMETER.

02723 {
02724     UNUSED_PARAMETER(executor);
02725     UNUSED_PARAMETER(caller);
02726     UNUSED_PARAMETER(enactor);
02727     UNUSED_PARAMETER(cargs);
02728     UNUSED_PARAMETER(ncargs);
02729 
02730     UINT64 val = 0;
02731     for (int i = 0; i < nfargs; i++)
02732     {
02733         if (is_integer(fargs[i], NULL))
02734         {
02735             val ^= mux_atoi64(fargs[i]);
02736         }
02737         else
02738         {
02739             safe_str("#-1 ARGUMENTS MUST BE INTEGERS", buff, bufc);
02740             return;
02741         }
02742     }
02743     safe_i64toa(val, buff, bufc);
02744 }

FUNCTION ( fun_bnand   ) 

Definition at line 2700 of file funmath.cpp.

References is_integer(), mux_atoi64(), safe_i64toa(), safe_str, and UNUSED_PARAMETER.

02701 {
02702     UNUSED_PARAMETER(executor);
02703     UNUSED_PARAMETER(caller);
02704     UNUSED_PARAMETER(enactor);
02705     UNUSED_PARAMETER(nfargs);
02706     UNUSED_PARAMETER(cargs);
02707     UNUSED_PARAMETER(ncargs);
02708 
02709     if (  is_integer(fargs[0], NULL)
02710        && is_integer(fargs[1], NULL))
02711     {
02712         INT64 a = mux_atoi64(fargs[0]);
02713         INT64 b = mux_atoi64(fargs[1]);
02714         safe_i64toa(a & ~(b), buff, bufc);
02715     }
02716     else
02717     {
02718         safe_str("#-1 ARGUMENTS MUST BE INTEGERS", buff, bufc);
02719     }
02720 }

FUNCTION ( fun_bor   ) 

Definition at line 2676 of file funmath.cpp.

References is_integer(), mux_atoi64(), safe_i64toa(), safe_str, and UNUSED_PARAMETER.

02677 {
02678     UNUSED_PARAMETER(executor);
02679     UNUSED_PARAMETER(caller);
02680     UNUSED_PARAMETER(enactor);
02681     UNUSED_PARAMETER(cargs);
02682     UNUSED_PARAMETER(ncargs);
02683 
02684     UINT64 val = 0;
02685     for (int i = 0; i < nfargs; i++)
02686     {
02687         if (is_integer(fargs[i], NULL))
02688         {
02689             val |= mux_atoi64(fargs[i]);
02690         }
02691         else
02692         {
02693             safe_str("#-1 ARGUMENTS MUST BE INTEGERS", buff, bufc);
02694             return;
02695         }
02696     }
02697     safe_i64toa(val, buff, bufc);
02698 }

FUNCTION ( fun_band   ) 

Definition at line 2652 of file funmath.cpp.

References is_integer(), mux_atoi64(), safe_i64toa(), safe_str, UINT64_MAX_VALUE, and UNUSED_PARAMETER.

02653 {
02654     UNUSED_PARAMETER(executor);
02655     UNUSED_PARAMETER(caller);
02656     UNUSED_PARAMETER(enactor);
02657     UNUSED_PARAMETER(cargs);
02658     UNUSED_PARAMETER(ncargs);
02659 
02660     UINT64 val = UINT64_MAX_VALUE;
02661     for (int i = 0; i < nfargs; i++)
02662     {
02663         if (is_integer(fargs[i], NULL))
02664         {
02665             val &= mux_atoi64(fargs[i]);
02666         }
02667         else
02668         {
02669             safe_str("#-1 ARGUMENTS MUST BE INTEGERS", buff, bufc);
02670             return;
02671         }
02672     }
02673     safe_i64toa(val, buff, bufc);
02674 }

FUNCTION ( fun_lor   ) 

Definition at line 2625 of file funmath.cpp.

References DELIM_DFLT, DELIM_STRING, isTRUE, mux_atol(), OPTIONAL_DELIM, safe_bool, split_token(), trim_space_sep(), and UNUSED_PARAMETER.

02626 {
02627     UNUSED_PARAMETER(executor);
02628     UNUSED_PARAMETER(caller);
02629     UNUSED_PARAMETER(enactor);
02630     UNUSED_PARAMETER(cargs);
02631     UNUSED_PARAMETER(ncargs);
02632 
02633     bool bValue = false;
02634     if (0 < nfargs)
02635     {
02636         SEP sep;
02637         if (!OPTIONAL_DELIM(2, sep, DELIM_DFLT|DELIM_STRING))
02638         {
02639             return;
02640         }
02641 
02642         char *cp = trim_space_sep(fargs[0], &sep);
02643         while (cp && !bValue)
02644         {
02645             char *curr = split_token(&cp, &sep);
02646             bValue = isTRUE(mux_atol(curr));
02647         }
02648     }
02649     safe_bool(bValue, buff, bufc);
02650 }

FUNCTION ( fun_land   ) 

Definition at line 2598 of file funmath.cpp.

References DELIM_DFLT, DELIM_STRING, isTRUE, mux_atol(), OPTIONAL_DELIM, safe_bool, split_token(), trim_space_sep(), and UNUSED_PARAMETER.

02599 {
02600     UNUSED_PARAMETER(executor);
02601     UNUSED_PARAMETER(caller);
02602     UNUSED_PARAMETER(enactor);
02603     UNUSED_PARAMETER(cargs);
02604     UNUSED_PARAMETER(ncargs);
02605 
02606     bool bValue = true;
02607     if (0 < nfargs)
02608     {
02609         SEP sep;
02610         if (!OPTIONAL_DELIM(2, sep, DELIM_DFLT|DELIM_STRING))
02611         {
02612             return;
02613         }
02614 
02615         char *cp = trim_space_sep(fargs[0], &sep);
02616         while (cp && bValue)
02617         {
02618             char *curr = split_token(&cp, &sep);
02619             bValue = isTRUE(mux_atol(curr));
02620         }
02621     }
02622     safe_bool(bValue, buff, bufc);
02623 }

FUNCTION ( fun_roman   ) 

Definition at line 2495 of file funmath.cpp.

References mux_isdigit, mux_isspace, safe_chr, safe_range, safe_str, and UNUSED_PARAMETER.

02496 {
02497     UNUSED_PARAMETER(executor);
02498     UNUSED_PARAMETER(caller);
02499     UNUSED_PARAMETER(enactor);
02500     UNUSED_PARAMETER(nfargs);
02501     UNUSED_PARAMETER(cargs);
02502     UNUSED_PARAMETER(ncargs);
02503 
02504     const char *number = fargs[0];
02505 
02506     // Trim Spaces from beginning.
02507     //
02508     while (mux_isspace(*number))
02509     {
02510         number++;
02511     }
02512 
02513     // Trim Zeroes from Beginning.
02514     //
02515     while (*number == '0')
02516     {
02517         number++;
02518     }
02519 
02520     const char *pA = number;
02521     while (mux_isdigit(*number))
02522     {
02523         number++;
02524     }
02525     size_t nA = number - pA;
02526 
02527     // Skip trailing spaces.
02528     //
02529     while (mux_isspace(*number))
02530     {
02531         number++;
02532     }
02533 
02534     // Validate that argument is numeric with a value between 1 and 3999.
02535     //
02536     if (*number || nA < 1)
02537     {
02538         safe_str("#-1 ARGUMENT MUST BE A POSITIVE NUMBER", buff, bufc);
02539         return;
02540     }
02541     else if (  nA > 4
02542             || (  nA == 1
02543                && pA[0] == '0')
02544             || (  nA == 4
02545                && '3' < pA[0]))
02546     {
02547         safe_range(buff, bufc);
02548         return;
02549     }
02550 
02551     // I:1, V:5, X:10, L:50, C:100, D:500, M:1000
02552     //
02553     // Ones:      _ I II III IV V VI VII VIII IX
02554     // Tens:      _ X XX XXX XL L LX LXX LXXX XC
02555     // Hundreds:  _ C CC CCC CD D DC DCC DCCC CM
02556     // Thousands: _ M MM MMM
02557     //
02558     static const char aLetters[4][3] =
02559     {
02560         { 'I', 'V', 'X' },
02561         { 'X', 'L', 'C' },
02562         { 'C', 'D', 'M' },
02563         { 'M', ' ', ' ' }
02564     };
02565 
02566     static const char *aCode[10] =
02567     {
02568         "",
02569         "1",
02570         "11",
02571         "111",
02572         "12",
02573         "2",
02574         "21",
02575         "211",
02576         "2111",
02577         "13"
02578     };
02579 
02580     while (nA--)
02581     {
02582         const char *pCode = aCode[*pA - '0'];
02583         const char *pLetters = aLetters[nA];
02584 
02585         while (*pCode)
02586         {
02587             safe_chr(pLetters[*pCode - '1'], buff, bufc);
02588             pCode++;
02589         }
02590         pA++;
02591     }
02592 }

FUNCTION ( fun_spellnum   ) 

Definition at line 2482 of file funmath.cpp.

References CSpellNum::SpellNum(), and UNUSED_PARAMETER.

02483 {
02484     UNUSED_PARAMETER(executor);
02485     UNUSED_PARAMETER(caller);
02486     UNUSED_PARAMETER(enactor);
02487     UNUSED_PARAMETER(nfargs);
02488     UNUSED_PARAMETER(cargs);
02489     UNUSED_PARAMETER(ncargs);
02490 
02491     CSpellNum sn;
02492     sn.SpellNum(fargs[0], buff, bufc);
02493 }

FUNCTION ( fun_t   ) 

Definition at line 2146 of file funmath.cpp.

References safe_bool, safe_chr, UNUSED_PARAMETER, and xlate().

02147 {
02148     UNUSED_PARAMETER(executor);
02149     UNUSED_PARAMETER(caller);
02150     UNUSED_PARAMETER(enactor);
02151     UNUSED_PARAMETER(cargs);
02152     UNUSED_PARAMETER(ncargs);
02153 
02154     if (  nfargs <= 0
02155        || fargs[0][0] == '\0')
02156     {
02157         safe_chr('0', buff, bufc);
02158     }
02159     else
02160     {
02161         safe_bool(xlate(fargs[0]), buff, bufc);
02162     }
02163 }

FUNCTION ( fun_not   ) 

Definition at line 2134 of file funmath.cpp.

References safe_bool, UNUSED_PARAMETER, and xlate().

02135 {
02136     UNUSED_PARAMETER(executor);
02137     UNUSED_PARAMETER(caller);
02138     UNUSED_PARAMETER(enactor);
02139     UNUSED_PARAMETER(nfargs);
02140     UNUSED_PARAMETER(cargs);
02141     UNUSED_PARAMETER(ncargs);
02142 
02143     safe_bool(!xlate(fargs[0]), buff, bufc);
02144 }

FUNCTION ( fun_xor   ) 

Definition at line 2117 of file funmath.cpp.

References mux_atol(), safe_bool, and UNUSED_PARAMETER.

02118 {
02119     UNUSED_PARAMETER(executor);
02120     UNUSED_PARAMETER(caller);
02121     UNUSED_PARAMETER(enactor);
02122     UNUSED_PARAMETER(cargs);
02123     UNUSED_PARAMETER(ncargs);
02124 
02125     bool val = false;
02126     for (int i = 0; i < nfargs; i++)
02127     {
02128         int tval = mux_atol(fargs[i]);
02129         val = (val && !tval) || (!val && tval);
02130     }
02131     safe_bool(val, buff, bufc);
02132 }

FUNCTION ( fun_corbool   ) 

Definition at line 2100 of file funmath.cpp.

References alloc_lbuf, CMuxAlarm::bAlarmed, EV_EVAL, EV_FCHECK, EV_STRIP_CURLY, free_lbuf, mux_exec(), MuxAlarm, safe_bool, and xlate().

02101 {
02102     bool val = false;
02103     char *temp = alloc_lbuf("fun_corbool");
02104     for (int i = 0; i < nfargs && !val && !MuxAlarm.bAlarmed; i++)
02105     {
02106         char *bp = temp;
02107         char *str = fargs[i];
02108         mux_exec(temp, &bp, executor, caller, enactor,
02109             EV_STRIP_CURLY | EV_FCHECK | EV_EVAL, &str, cargs, ncargs);
02110         *bp = '\0';
02111         val = xlate(temp);
02112     }
02113     free_lbuf(temp);
02114     safe_bool(val, buff, bufc);
02115 }

FUNCTION ( fun_candbool   ) 

Definition at line 2083 of file funmath.cpp.

References alloc_lbuf, CMuxAlarm::bAlarmed, EV_EVAL, EV_FCHECK, EV_STRIP_CURLY, free_lbuf, mux_exec(), MuxAlarm, safe_bool, and xlate().

02084 {
02085     bool val = true;
02086     char *temp = alloc_lbuf("fun_candbool");
02087     for (int i = 0; i < nfargs && val && !MuxAlarm.bAlarmed; i++)
02088     {
02089         char *bp = temp;
02090         char *str = fargs[i];
02091         mux_exec(temp, &bp, executor, caller, enactor,
02092             EV_STRIP_CURLY | EV_FCHECK | EV_EVAL, &str, cargs, ncargs);
02093         *bp = '\0';
02094         val = xlate(temp);
02095     }
02096     free_lbuf(temp);
02097     safe_bool(val, buff, bufc);
02098 }

FUNCTION ( fun_cor   ) 

Definition at line 2066 of file funmath.cpp.

References alloc_lbuf, CMuxAlarm::bAlarmed, EV_EVAL, EV_FCHECK, EV_STRIP_CURLY, free_lbuf, isTRUE, mux_atol(), mux_exec(), MuxAlarm, and safe_bool.

02067 {
02068     bool val = false;
02069     char *temp = alloc_lbuf("fun_cor");
02070     for (int i = 0; i < nfargs && !val && !MuxAlarm.bAlarmed; i++)
02071     {
02072         char *bp = temp;
02073         char *str = fargs[i];
02074         mux_exec(temp, &bp, executor, caller, enactor,
02075             EV_STRIP_CURLY | EV_FCHECK | EV_EVAL, &str, cargs, ncargs);
02076         *bp = '\0';
02077         val = isTRUE(mux_atol(temp));
02078     }
02079     free_lbuf(temp);
02080     safe_bool(val, buff, bufc);
02081 }

FUNCTION ( fun_cand   ) 

Definition at line 2049 of file funmath.cpp.

References alloc_lbuf, CMuxAlarm::bAlarmed, EV_EVAL, EV_FCHECK, EV_STRIP_CURLY, free_lbuf, isTRUE, mux_atol(), mux_exec(), MuxAlarm, and safe_bool.

02050 {
02051     bool val = true;
02052     char *temp = alloc_lbuf("fun_cand");
02053     for (int i = 0; i < nfargs && val && !MuxAlarm.bAlarmed; i++)
02054     {
02055         char *bp = temp;
02056         char *str = fargs[i];
02057         mux_exec(temp, &bp, executor, caller, enactor,
02058             EV_STRIP_CURLY | EV_FCHECK | EV_EVAL, &str, cargs, ncargs);
02059         *bp = '\0';
02060         val = isTRUE(mux_atol(temp));
02061     }
02062     free_lbuf(temp);
02063     safe_bool(val, buff, bufc);
02064 }

FUNCTION ( fun_orbool   ) 

Definition at line 2033 of file funmath.cpp.

References safe_bool, UNUSED_PARAMETER, and xlate().

02034 {
02035     UNUSED_PARAMETER(executor);
02036     UNUSED_PARAMETER(caller);
02037     UNUSED_PARAMETER(enactor);
02038     UNUSED_PARAMETER(cargs);
02039     UNUSED_PARAMETER(ncargs);
02040 
02041     bool val = false;
02042     for (int i = 0; i < nfargs && !val; i++)
02043     {
02044         val = xlate(fargs[i]);
02045     }
02046     safe_bool(val, buff, bufc);
02047 }

FUNCTION ( fun_andbool   ) 

Definition at line 2017 of file funmath.cpp.

References safe_bool, UNUSED_PARAMETER, and xlate().

02018 {
02019     UNUSED_PARAMETER(executor);
02020     UNUSED_PARAMETER(caller);
02021     UNUSED_PARAMETER(enactor);
02022     UNUSED_PARAMETER(cargs);
02023     UNUSED_PARAMETER(ncargs);
02024 
02025     bool val = true;
02026     for (int i = 0; i < nfargs && val; i++)
02027     {
02028         val = xlate(fargs[i]);
02029     }
02030     safe_bool(val, buff, bufc);
02031 }

FUNCTION ( fun_or   ) 

Definition at line 2001 of file funmath.cpp.

References isTRUE, mux_atol(), safe_bool, and UNUSED_PARAMETER.

02002 {
02003     UNUSED_PARAMETER(executor);
02004     UNUSED_PARAMETER(caller);
02005