diff --git a/Contrib/Math/SConscript b/Contrib/Math/SConscript index 5ed66e17..fe4104bf 100644 --- a/Contrib/Math/SConscript +++ b/Contrib/Math/SConscript @@ -23,9 +23,4 @@ docs = Split(""" Import('BuildPlugin env') -if env.has_key('MSVS_VERSION') and float(env['MSVS_VERSION'].replace('Exp','')) >= 8.0: - files += ['Source/mathcrtmt.lib'] -else: - files += ['Source/mathcrt.lib'] - BuildPlugin(target, files, libs, examples, docs, nodeflib = False, flags = ['$CPP_FLAG']) diff --git a/Contrib/Math/Source/Math.c b/Contrib/Math/Source/Math.c index 4fdb6482..3fc61771 100644 --- a/Contrib/Math/Source/Math.c +++ b/Contrib/Math/Source/Math.c @@ -1,10 +1,8 @@ #include -#include "mathcrt.h" #include "MyMath.h" #include "Math.h" extern "C" int _fltused; -int _fltused; ExpressionItem *stack; int UserVarsCount, UserFuncsCount; @@ -104,26 +102,26 @@ void PlaceVariable(char *&vb, ParseInfo *pi) #define MATHFUNCNUM 29 const MathFunction MathFunctions[MATHFUNCNUM] = { - {{'s','i','n'}, ITF_MATH1 >> 8, _fsin}, - {{'s','n','h'}, ITF_MATH1 >> 8, _fsinh}, - {{'a','s','n'}, ITF_MATH1 >> 8, _fasin}, - {{'c','o','s'}, ITF_MATH1 >> 8, _fcos}, - {{'c','s','h'}, ITF_MATH1 >> 8, _fcosh}, - {{'a','c','s'}, ITF_MATH1 >> 8, _facos}, - {{'t','a','n'}, ITF_MATH1 >> 8, _ftan}, - {{'t','n','h'}, ITF_MATH1 >> 8, _ftanh}, - {{'a','t','n'}, ITF_MATH1 >> 8, _fatan}, - {{'a','b','s'}, ITF_MATH1 >> 8, _fabs}, - {{'l','n',0}, ITF_MATH1 >> 8, _flog}, - {{'l','o','g'}, ITF_MATH1 >> 8, _flog10}, - {{'e','x','p'}, ITF_MATH1 >> 8, _fexp}, - {{'s','q','t'}, ITF_MATH1 >> 8, _fsqrt}, - {{'c','e','l'}, ITF_MATH1 >> 8, _fceil}, - {{'f','l','r'}, ITF_MATH1 >> 8, _floor}, + {{'s','i','n'}, ITF_MATH1 >> 8, sin}, + {{'s','n','h'}, ITF_MATH1 >> 8, sinh}, + {{'a','s','n'}, ITF_MATH1 >> 8, asin}, + {{'c','o','s'}, ITF_MATH1 >> 8, cos}, + {{'c','s','h'}, ITF_MATH1 >> 8, cosh}, + {{'a','c','s'}, ITF_MATH1 >> 8, acos}, + {{'t','a','n'}, ITF_MATH1 >> 8, tan}, + {{'t','n','h'}, ITF_MATH1 >> 8, tanh}, + {{'a','t','n'}, ITF_MATH1 >> 8, atan}, + {{'a','b','s'}, ITF_MATH1 >> 8, fabs}, + {{'l','n',0}, ITF_MATH1 >> 8, log}, + {{'l','o','g'}, ITF_MATH1 >> 8, log10}, + {{'e','x','p'}, ITF_MATH1 >> 8, exp}, + {{'s','q','t'}, ITF_MATH1 >> 8, sqrt}, + {{'c','e','l'}, ITF_MATH1 >> 8, ceil}, + {{'f','l','r'}, ITF_MATH1 >> 8, floor}, - {{'a','t','2'}, ITF_MATH2 >> 8, (Math1FuncPtr)_fatan2}, - {{'p','o','w'}, ITF_MATH2 >> 8, (Math1FuncPtr)_fpow}, - {{'f','m','d'}, ITF_MATH2 >> 8, (Math1FuncPtr)_fmod}, + {{'a','t','2'}, ITF_MATH2 >> 8, (Math1FuncPtr)atan2}, + {{'p','o','w'}, ITF_MATH2 >> 8, (Math1FuncPtr)pow}, + {{'f','m','d'}, ITF_MATH2 >> 8, (Math1FuncPtr)fmod}, // type conversions {{'i',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_INT}, @@ -136,8 +134,8 @@ const MathFunction MathFunctions[MATHFUNCNUM] = { {{'l',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)FTT_LEN}, {{'c',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)FTT_CHAR}, - {{'f','e','x'}, ITF_MATH2 >> 8, (Math1FuncPtr)_frexp}, - {{'m','d','f'}, ITF_MATH2 >> 8, (Math1FuncPtr)_fmodf}, + {{'f','e','x'}, ITF_MATH2 >> 8, (Math1FuncPtr)frexp}, + {{'m','d','f'}, ITF_MATH2 >> 8, (Math1FuncPtr)modf}, }; void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine) @@ -1537,3 +1535,9 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) CleanAll(ul_reason_for_call == DLL_PROCESS_ATTACH); return TRUE; } + +// crt0.obj is linked in and requires this +int main() +{ + return 0; +} diff --git a/Contrib/Math/Source/Math.sln b/Contrib/Math/Source/Math.sln deleted file mode 100644 index dd4a0de2..00000000 --- a/Contrib/Math/Source/Math.sln +++ /dev/null @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Math", "Math.vcproj", "{0825E168-A8AD-4110-B35A-52B078C39C2A}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {0825E168-A8AD-4110-B35A-52B078C39C2A}.Debug.ActiveCfg = Debug|Win32 - {0825E168-A8AD-4110-B35A-52B078C39C2A}.Debug.Build.0 = Debug|Win32 - {0825E168-A8AD-4110-B35A-52B078C39C2A}.Release.ActiveCfg = Release|Win32 - {0825E168-A8AD-4110-B35A-52B078C39C2A}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/Contrib/Math/Source/Math.vcproj b/Contrib/Math/Source/Math.vcproj deleted file mode 100644 index 2da2c74a..00000000 --- a/Contrib/Math/Source/Math.vcproj +++ /dev/null @@ -1,240 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Contrib/Math/Source/MyMath.c b/Contrib/Math/Source/MyMath.c index c7b79cdd..e9f3a5b7 100644 --- a/Contrib/Math/Source/MyMath.c +++ b/Contrib/Math/Source/MyMath.c @@ -1,5 +1,4 @@ #include -#include "mathcrt.h" #include "MyMath.h" #include "Math.h" @@ -197,11 +196,22 @@ void itoa64(__int64 i, char *buffer) } #define _FLOAT_ROUND_ADJUST (double)5e-15 -extern "C" - int _floatp10(double *fnum, int *fsign, int prec); extern "C" int _ftol(double num); +int _floatp10(double *fnum, int *fsign, int prec) +{ + int fpower, _d; + fcvt(*fnum, prec, &fpower, &_d); + + if (*fnum < 0) + *fsign = -1; + else + *fsign = 1; + + return fpower; +} + #define POS_INFINITY "#INF" #define NEG_INFINITY "-#INF" @@ -314,6 +324,8 @@ void FloatFormat(char *s, double value, int options) { int prec = options & 0xF; + *s = 0; + if(value == HUGE_VAL) { lstrcpy(s, POS_INFINITY); @@ -323,7 +335,18 @@ void FloatFormat(char *s, double value, int options) return; } - if (options & FF_NOEXP) FloatFormatF(s, value, prec); + int decpt, sign; + + char *res = fcvt(value, prec, &decpt, &sign); + + if (res) + { + lstrcpyn(s, res, decpt + 1); + lstrcat(s, "."); + lstrcpy(s + decpt + 1, res + decpt); + } + + /*if (options & FF_NOEXP) FloatFormatF(s, value, prec); else if (options & FF_EXP) FloatFormatE(s, value, options); else @@ -342,7 +365,7 @@ void FloatFormat(char *s, double value, int options) if(prec <= 0) prec = 1; FloatFormatF(s, value, prec); } - } + }*/ } int lstrcmpn(char *s1, const char *s2, int chars) diff --git a/Contrib/Math/Source/MyMath.h b/Contrib/Math/Source/MyMath.h index f4e6f88f..3936236d 100644 --- a/Contrib/Math/Source/MyMath.h +++ b/Contrib/Math/Source/MyMath.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #define DEFAULT_ARRAY_SIZE 1024 #define ITEMTYPE 0xFF0000 diff --git a/Contrib/Math/Source/mathcrt.h b/Contrib/Math/Source/mathcrt.h deleted file mode 100644 index 7762036f..00000000 --- a/Contrib/Math/Source/mathcrt.h +++ /dev/null @@ -1,87 +0,0 @@ -/*---------------------------------------------------------------------------*/ -/* math.h - mathematics header file */ -/*---------------------------------------------------------------------------*/ -#pragma once - -extern "C" -{ - -extern double _infinity; -#define HUGE_VAL _infinity - -#define acos(x) _facos(x) -#define asin(x) _fasin(x) -#define atan(x) _fatan(x) -#define atan2(x, y) _fatan2(x, y) -#define ceil(x) _fceil(x) -#define cos(x) _fcos(x) -#define cosh(x) _fcosh(x) -#define exp(x) _fexp(x) -#define fabs(x) _fabs(x) -#define floor(x) _floor(x) -#define fmod(x, y) _fmod(x, y) -#define frexp(x, n) _frexp(x, n) -#define ldexp(x, n) _fldexp(x, n) -#define log(x) _flog(x) -#define log10(x) _flog10(x) -#define modf(x, y) _fmodf(x, y) -#define pow(x, y) _fpow(x, y) -#define sin(x) _fsin(x) -#define sinh(x) _fsinh(x) -#define sqrt(x) _fsqrt(x) -#define tan(x) _ftan(x) -#define tanh(x) _ftanh(x) - -/*---------------------------------------------------------------------------*/ -/* function prototpes */ -/*---------------------------------------------------------------------------*/ -double acos(double x); -double asin(double x); -double atan(double x); -double atan2(double x, double y); -double ceil(double x); -double cos(double x); -double cosh(double x); -double exp(double x); -double fabs(double x); -double floor(double x); -double fmod(double x, double y); -double frexp(double x, int *n); -double ldexp(double x, int n); -double log(double x); -double log10(double x); -double modf(double x, double *y); -double pow(double x, double y); -double sin(double x); -double sinh(double x); -double sqrt(double x); -double tan(double x); -double tanh(double x); - -/*---------------------------------------------------------------------------*/ -/* float.h - floating point include file */ -/*---------------------------------------------------------------------------*/ -#define FLT_RADIX 2 -#define FLT_ROUNDS 1 -#define FLT_DIG 6 -#define FLT_EPSILON 1.192092896e-07F -#define FLT_MANT_DIG 24 -#define FLT_MAX 3.402823466e+38F -#define FLT_MAX_EXP 38 -#define FLT_MIN 1.175494351e-38F -#define FLT_MIN_EXP (-37) - -#define DBL_DIG 15 -#define DBL_EPSILON 2.2204460492503131e-016 -#define DBL_MANT_DIG 53 -#define DBL_MAX 1.7976931348623158e+308 -#define DBL_MAX_EXP 308 -#define DBL_MIN 2.2250738585072014e-308 -#define DBL_MIN_EXP (-307) - -/*---------------------------------------------------------------------------*/ -/* function prototpes */ -/*---------------------------------------------------------------------------*/ -void _fpreset(void); - -} \ No newline at end of file diff --git a/Contrib/Math/Source/mathcrt.lib b/Contrib/Math/Source/mathcrt.lib deleted file mode 100644 index 4dcadc5f..00000000 Binary files a/Contrib/Math/Source/mathcrt.lib and /dev/null differ diff --git a/Contrib/Math/Source/mathcrtmt.lib b/Contrib/Math/Source/mathcrtmt.lib deleted file mode 100644 index 698ec2b0..00000000 Binary files a/Contrib/Math/Source/mathcrtmt.lib and /dev/null differ