Skip to content
Open
Show file tree
Hide file tree
Changes from 138 commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
e17b356
Sample money test
gbeeley Aug 7, 2020
6995cb0
Merge branch 'money_type' of https://github.com/LightSys/centrallix i…
cscederborg Aug 7, 2020
c9313c8
A second set of test files to determine if I still appear as gbeeley …
cscederborg Aug 8, 2020
2838eab
Change MoneyType struct to contain a single long long instead of Whol…
cscederborg Aug 10, 2020
204f78b
Commenting out direct MoneyType usage in centrallix/utility
cscederborg Aug 10, 2020
4f3170d
Commenting out direct MoneyType usage in centrallix/expression
cscederborg Aug 11, 2020
016e2a7
Commenting out direct MoneyType usage
cscederborg Aug 11, 2020
19d8480
Converted obj_internal_FormatMoney to use the new 64 bit MoneyType
cscederborg Aug 12, 2020
114334d
Converted objDataToDouble to new 64 bit MoneyType
cscederborg Aug 12, 2020
065399f
Converted objDataCompare to new 64 bit MoneyType
cscederborg Aug 12, 2020
c50ffc9
Converted objDataToWords to new 64 bit MoneyType
cscederborg Aug 12, 2020
a04da49
Converted objDataToInteger to new 64 bit MoneyType
cscederborg Aug 12, 2020
754bbf9
Basic testrunner file for running arbitrary Centrallix functions
sheesania Aug 12, 2020
ebeb912
Merge remote-tracking branch 'origin/money_type_testrunner' into mone…
cscederborg Aug 13, 2020
9c4b387
Basic system for native C tests in /centrallix using assert
sheesania Aug 13, 2020
3db48cf
Display native C test output in blue
sheesania Aug 13, 2020
713863a
Removing old native C testing framework
sheesania Aug 13, 2020
50eea78
Remove old temporary testrunner
sheesania Aug 13, 2020
cfc6473
Update README
sheesania Aug 13, 2020
d7d4c14
Update README for new direct C testing system
sheesania Aug 13, 2020
d9ef490
Merge branch 'money_type_testrunner' of https://github.com/LightSys/c…
sheesania Aug 13, 2020
982068f
Remove extraneous name comments from old native C baselines
sheesania Aug 13, 2020
64a7451
Example direct C test with assert and include
sheesania Aug 13, 2020
c4fe742
Converted objDataToMoney to 64 bit MoneyType representaion
cscederborg Aug 13, 2020
54c84cc
Updated functions that accounted for the unsigned nature of FractionPart
cscederborg Aug 13, 2020
ebb86eb
Resolving Code Review Comments
cscederborg Aug 14, 2020
56d86be
Included byteswap.h and cleaned up old comments
cscederborg Aug 14, 2020
c5e596b
Merge branch 'money_type_testrunner' of https://github.com/LightSys/c…
cscederborg Aug 17, 2020
875da6e
Initial MoneyType Tests for obj_datatype functions
cscederborg Aug 18, 2020
d876235
MoneyType Tests for obj_datatype functions; Removal of Example
cscederborg Aug 18, 2020
a912e91
More MoneyType Tests for obj_datatype functions
cscederborg Aug 18, 2020
afc2e99
Expanded functionality for moneytype tests
cscederborg Aug 19, 2020
e8c6343
Converted to 64 bit MoneyType Representation
cscederborg Aug 19, 2020
aa64e39
Converted to 64 bit MoneyType Representation
cscederborg Aug 19, 2020
af21f8b
Round and truncate exp functions converted to 64 bit
cscederborg Aug 20, 2020
4a61dfa
Addressing Code Review Comments and Improving Tests
cscederborg Aug 21, 2020
b4d87af
Fixing mt test 4 and removing testing comments
cscederborg Aug 21, 2020
88bffb8
Resolving Code Review comments
cscederborg Aug 21, 2020
7a9a8a3
Handling roudning, code review comments
cscederborg Aug 25, 2020
3f85d4f
Conversion to 64bit MoneyType in /osdrivers
cscederborg Aug 26, 2020
925a682
Remaining miscellaneous conversions to 64 bit moneytype
cscederborg Sep 1, 2020
a83b8c8
obj_internal_BuildBinaryItem Expression initialization and hex compar…
cscederborg Sep 3, 2020
f597aec
Renamed tests to be more specific
cscederborg Sep 4, 2020
ec90c38
Resolving Code Review comments and Expression Testing
cscederborg Sep 8, 2020
4d00e6e
Initial setup for ParseColumn; Creation of Obfuscate Test
cscederborg Sep 23, 2020
d727791
Working fp_internal_ParseColumn function and testing for 64bit MoneyType
cscederborg Sep 29, 2020
1d8e589
Added ll const tag to literals. Removed old comments in json_util.c.
cscederborg Dec 10, 2020
e224e66
Added ll const tag to literals. Cleaned up math and comparisons
cscederborg Dec 10, 2020
669e7eb
Resolving code review comments. Comments for obj, and comparison for …
cscederborg Dec 11, 2020
6b5f5ed
Updated QPrintf documentation. Added %LL specifier and shifted IDs fo…
cscederborg Dec 11, 2020
a70e287
Cleaning up test suite items. Showed truncation in fp test.
cscederborg Dec 14, 2020
1b727d2
Updated qprintf sysdoc to contain %LL. Creation of test for %LL, not …
cscederborg Dec 15, 2020
51d0918
Sample money test
gbeeley Aug 7, 2020
de1a325
A second set of test files to determine if I still appear as gbeeley …
cscederborg Aug 8, 2020
e320fe5
Change MoneyType struct to contain a single long long instead of Whol…
cscederborg Aug 10, 2020
f7623e4
Commenting out direct MoneyType usage in centrallix/utility
cscederborg Aug 10, 2020
0bbc802
Commenting out direct MoneyType usage in centrallix/expression
cscederborg Aug 11, 2020
20f8685
Commenting out direct MoneyType usage
cscederborg Aug 11, 2020
34ef3f9
Converted obj_internal_FormatMoney to use the new 64 bit MoneyType
cscederborg Aug 12, 2020
a8d47cf
Converted objDataToDouble to new 64 bit MoneyType
cscederborg Aug 12, 2020
11b0a3c
Converted objDataCompare to new 64 bit MoneyType
cscederborg Aug 12, 2020
31d5ceb
Converted objDataToWords to new 64 bit MoneyType
cscederborg Aug 12, 2020
2e1d133
Converted objDataToInteger to new 64 bit MoneyType
cscederborg Aug 12, 2020
13ac93b
Converted objDataToMoney to 64 bit MoneyType representaion
cscederborg Aug 13, 2020
351c2e3
Updated functions that accounted for the unsigned nature of FractionPart
cscederborg Aug 13, 2020
eddbd77
Resolving Code Review Comments
cscederborg Aug 14, 2020
05960ba
Included byteswap.h and cleaned up old comments
cscederborg Aug 14, 2020
c3a35d5
Initial MoneyType Tests for obj_datatype functions
cscederborg Aug 18, 2020
1515d91
MoneyType Tests for obj_datatype functions; Removal of Example
cscederborg Aug 18, 2020
32cf361
More MoneyType Tests for obj_datatype functions
cscederborg Aug 18, 2020
5ee4218
Expanded functionality for moneytype tests
cscederborg Aug 19, 2020
9a17479
Converted to 64 bit MoneyType Representation
cscederborg Aug 19, 2020
d293cb7
Converted to 64 bit MoneyType Representation
cscederborg Aug 19, 2020
2086352
Round and truncate exp functions converted to 64 bit
cscederborg Aug 20, 2020
6841adb
Addressing Code Review Comments and Improving Tests
cscederborg Aug 21, 2020
39b8deb
Fixing mt test 4 and removing testing comments
cscederborg Aug 21, 2020
12b9993
Resolving Code Review comments
cscederborg Aug 21, 2020
2d70028
Handling roudning, code review comments
cscederborg Aug 25, 2020
bf0ca3d
Conversion to 64bit MoneyType in /osdrivers
cscederborg Aug 26, 2020
0740053
Remaining miscellaneous conversions to 64 bit moneytype
cscederborg Sep 1, 2020
a0bb05d
obj_internal_BuildBinaryItem Expression initialization and hex compar…
cscederborg Sep 3, 2020
8fc1cef
Renamed tests to be more specific
cscederborg Sep 4, 2020
a94c668
Resolving Code Review comments and Expression Testing
cscederborg Sep 8, 2020
908729d
Initial setup for ParseColumn; Creation of Obfuscate Test
cscederborg Sep 23, 2020
9ef21dd
Working fp_internal_ParseColumn function and testing for 64bit MoneyType
cscederborg Sep 29, 2020
9f7c946
Added ll const tag to literals. Removed old comments in json_util.c.
cscederborg Dec 10, 2020
1b37e50
Added ll const tag to literals. Cleaned up math and comparisons
cscederborg Dec 10, 2020
9c9f8db
Resolving code review comments. Comments for obj, and comparison for …
cscederborg Dec 11, 2020
afc313a
Updated QPrintf documentation. Added %LL specifier and shifted IDs fo…
cscederborg Dec 11, 2020
34e5c46
Cleaning up test suite items. Showed truncation in fp test.
cscederborg Dec 14, 2020
92c7c9a
Updated qprintf sysdoc to contain %LL. Creation of test for %LL, not …
cscederborg Dec 15, 2020
69351cb
First sybase simplification attempt. Fixing endianness by shifting an…
cscederborg Dec 16, 2020
ebd7748
Sybase simplification. Bit shifting and OR to fix endianness.
cscederborg Dec 16, 2020
b8f338e
Fixing Expression Testing, fixed division and internal format. Proper…
cscederborg Dec 17, 2020
80e570b
Merge branch 'remove_net_raw' into money_type
sheesania Dec 18, 2020
55af853
QPrintf for %LL specifier and accompanying test.
cscederborg Dec 18, 2020
d449702
Merge branch 'money_type' of https://github.com/LightSys/centrallix i…
cscederborg Dec 18, 2020
2b34025
Http_rest JSON negative handling. Obfuscate long long to int conversion.
cscederborg Dec 22, 2020
4bcfa78
Objdrv_fp.c, using pow() instead of repeated division.
cscederborg Dec 23, 2020
161497e
Test updates, fixing a reference in osdriver. Obfuscate test framewor…
cscederborg Dec 24, 2020
83a0b2e
Renamed internal format Money test to accurately reflect function bei…
cscederborg Dec 30, 2020
1b27fd6
Resolving code review comments. Bound checking, more test cases, nega…
cscederborg Dec 30, 2020
8d4457a
Fixing extra spacing and commented-out code
sheesania Apr 9, 2021
41b9a18
Change obj_internal_BuildBinaryItem test to using public function obj…
sheesania Apr 13, 2021
4564328
Merge branch 'master' into money_type
sheesania Apr 13, 2021
ee8f7d4
Remove extraneous qprintf %LL test
sheesania Apr 13, 2021
0caaffe
Merge branch 'qprintf_ll_specifier' into money_type
sheesania Apr 16, 2021
7c292d1
Remove comment
sheesania Apr 20, 2021
02ee697
Fix moneytype obfuscation + tests
sheesania Apr 27, 2021
7085c00
Basic helper for testing calls to mssError
sheesania May 3, 2021
2cd7a94
Working test for MoneyType to integer overflows
sheesania May 3, 2021
83d9c80
Test for obfuscating MoneyTypes > INT_MAX
sheesania May 3, 2021
07506ef
Remove extraneous comment
sheesania May 3, 2021
69d13c3
Remove sample test files
sheesania May 3, 2021
7e5183c
Fix "integer constant too large for its type"
sheesania May 13, 2021
cd073cd
Fix makefile for test helpers
sheesania May 13, 2021
a65f438
Basic test helper for stdout output
sheesania May 24, 2021
5e019e5
Better error/edge case handling for stdout error helper
sheesania May 24, 2021
a5420a0
Better test helper doc strings
sheesania May 24, 2021
adca88d
Test for moneytype changes in exp_internal_DumpExpression_r
sheesania May 24, 2021
d2149f9
Test comparing MoneyType expressions
sheesania May 25, 2021
9eea437
Move conversion to old money representation for JSON into separate fu…
sheesania May 28, 2021
5b87af4
Fix dbl_internal_ParseColumn for MoneyType + test
sheesania Jun 2, 2021
cb8df45
Small fixes and cleanup of objdrv_fp MoneyType test
sheesania Jun 2, 2021
dea8823
Test for json > MoneyType parsing
sheesania Jun 16, 2021
e8ec84d
Tests for MoneyType round expressions
sheesania Jun 16, 2021
ad91c3b
Test MoneyType round behavior with no decimal places parameter
sheesania Jun 16, 2021
e936ff3
Tests for MoneyType truncate expressions
sheesania Jun 16, 2021
c64cf6e
Tests for MoneyType max expression
sheesania Jun 16, 2021
79888de
Tests for MoneyType min expressions
sheesania Jun 16, 2021
5c817dc
Merge branch 'master' into money_type
sheesania Jul 12, 2021
86f2f82
Basic framework for Sybase -> MoneyType test
sheesania Jul 13, 2021
5a528cd
Tests for getting MoneyType from objdrv_sybase + simplification of ob…
sheesania Jul 13, 2021
c05cc67
Fix and test int overflow when printing money type > INT_MAX
sheesania Jul 19, 2021
a7b6b80
Test for expDumpExpression with money > INT_MAX
sheesania Jul 19, 2021
52aad43
Test for objBuildBinaryImage with money > INT_MAX
sheesania Jul 19, 2021
ff310de
Add test for potential int overflow in objDataCompare for money + sma…
sheesania Jul 19, 2021
c872360
Fix + test int overflow in objDataToWords for money > INT_MAX
sheesania Jul 19, 2021
8e73edf
Clarify comment
sheesania Feb 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions centrallix-lib/include/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ typedef struct _SV
/** Money structure **/
typedef struct _MN
{
int WholePart; /* integer part = floor($amount) */
unsigned short FractionPart; /* fract part = $amount - floor($amount) */
long long Value; /* Fixed-point representation in 1/10000 of a dollar */
}
MoneyType, *pMoneyType;

Expand Down
7 changes: 5 additions & 2 deletions centrallix/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ ifeq ($TOTESTFILES,)
else
TOTESTDEPS=test_obj
endif
CTESTHELPERS:=$(wildcard tests/helpers/*.c)
TESTHELPERS:=$(patsubst %.c,%.o,$(CTESTHELPERS))

# Some basic build parameters.
PROFILE=@PROFILE@
Expand Down Expand Up @@ -529,8 +531,8 @@ tests/centrallix.conf-test: tests/centrallix.conf-test.in
tests/t_driver.o: tests/t_driver.c
$(CC) $(CFLAGS) $< -c -o $@

tests/test_%.bin: tests/test_%.o tests/t_driver.o centrallix.o $(V3LSOBJS) $(STATIC_LIBS)
$(CC) $< tests/t_driver.o centrallix.o $(V3LSOBJS) $(LIBDIRS) $(PROFILE) $(COVERAGE) -Wl@EXPORT_DYNAMIC@ -o $@ $(LIBS) @NCURSES_LIBS@
tests/test_%.bin: tests/test_%.o tests/t_driver.o centrallix.o $(V3LSOBJS) $(STATIC_LIBS) $(TESTHELPERS)
$(CC) $< tests/t_driver.o centrallix.o $(V3LSOBJS) $(TESTHELPERS) $(LIBDIRS) $(PROFILE) $(COVERAGE) -Wl@EXPORT_DYNAMIC@ -o $@ $(LIBS) @NCURSES_LIBS@ @SYBASE_LIBS@

test: tests/centrallix.conf-test $(TOTESTDEPS) $(TOTESTFILES) $(CBTESTFILES)
@printf "%-62.62s %s\n" "Test Name" "Stat"
Expand Down Expand Up @@ -646,6 +648,7 @@ clean:
@rm -f man/*.gz
@rm -f tests/*.to.tmp tests/*.out
@rm -f tests/*.o tests/*.bin
@rm -f tests/helpers/*.o
@rm -rf thirdparty/*-inst
@rm -f *.gcov */*.gcov
@rm -f *.gcda */*.gcda
Expand Down
3 changes: 1 addition & 2 deletions centrallix/expression/exp_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ exp_internal_CompileExpression_r(pLxSession lxs, int level, pParamObjects objlis
if (t == MLX_TOK_INTEGER)
{
i = mlxIntVal(lxs);
etmp->Types.Money.WholePart = i;
etmp->Types.Money.FractionPart = 0;
etmp->Types.Money.Value = (i * 10000ll);
}
else
{
Expand Down
121 changes: 22 additions & 99 deletions centrallix/expression/exp_evaluate.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ expEvalDivide(pExpression tree, pParamObjects objlist)
pExpression i0,i1;
MoneyType m;
int i;
int is_negative = 0;
long long mv, mv2;
double md;

Expand Down Expand Up @@ -227,7 +226,7 @@ expEvalDivide(pExpression tree, pParamObjects objlist)
/** Check for divide by zero **/
if ((i1->DataType == DATA_T_INTEGER && i1->Integer == 0) ||
(i1->DataType == DATA_T_DOUBLE && i1->Types.Double == 0.0) ||
(i1->DataType == DATA_T_MONEY && i1->Types.Money.WholePart == 0 && i1->Types.Money.FractionPart == 0))
(i1->DataType == DATA_T_MONEY && i1->Types.Money.Value == 0))
{
mssError(1,"EXP","Attempted divide by zero");
return -1;
Expand Down Expand Up @@ -280,38 +279,12 @@ expEvalDivide(pExpression tree, pParamObjects objlist)
case DATA_T_INTEGER:
tree->DataType = DATA_T_MONEY;
memcpy(&m, &(i0->Types.Money), sizeof(MoneyType));
if (m.WholePart < 0)
{
is_negative = !is_negative;
if (m.FractionPart != 0)
{
m.WholePart = m.WholePart + 1;
m.FractionPart = 10000 - m.FractionPart;
}
m.WholePart = -m.WholePart;
}
i = i1->Integer;
if (i < 0)
{
i = -i;
is_negative = !is_negative;
}
if (i == 0)
if (i1->Integer == 0)
{
mssError(1,"EXP","Attempted divide by zero");
return -1;
}
tree->Types.Money.WholePart = m.WholePart / i;
tree->Types.Money.FractionPart = (10000*(m.WholePart % i) + m.FractionPart)/i;
if (is_negative)
{
if (tree->Types.Money.FractionPart != 0)
{
tree->Types.Money.WholePart = tree->Types.Money.WholePart + 1;
tree->Types.Money.FractionPart = 10000 - tree->Types.Money.FractionPart;
}
tree->Types.Money.WholePart = -tree->Types.Money.WholePart;
}
tree->Types.Money.Value = (long long)(m.Value / i1->Integer);
break;
case DATA_T_DOUBLE:
tree->DataType = DATA_T_MONEY;
Expand All @@ -320,23 +293,11 @@ expEvalDivide(pExpression tree, pParamObjects objlist)
mssError(1,"EXP","Attempted divide by zero");
return -1;
}
mv = ((long long)(i0->Types.Money.WholePart)) * 10000 + i0->Types.Money.FractionPart;
md = mv / i1->Types.Double;
if (md < 0) md -= 0.5;
else md += 0.5;
mv = md;
tree->Types.Money.WholePart = mv/10000;
mv = mv % 10000;
if (mv < 0)
{
mv += 10000;
tree->Types.Money.WholePart -= 1;
}
tree->Types.Money.FractionPart = mv;
tree->Types.Money.Value = llround(i0->Types.Money.Value/i1->Types.Double);
break;
case DATA_T_MONEY:
mv = ((long long)(i0->Types.Money.WholePart)) * 10000 + i0->Types.Money.FractionPart;
mv2 = ((long long)(i1->Types.Money.WholePart)) * 10000 + i1->Types.Money.FractionPart;
mv = i0->Types.Money.Value;
mv2 = i1->Types.Money.Value;
if (mv2 == 0)
{
mssError(1,"EXP","Attempted divide by zero");
Expand Down Expand Up @@ -428,8 +389,7 @@ expEvalMultiply(pExpression tree, pParamObjects objlist)
break;
case DATA_T_MONEY:
tree->DataType = DATA_T_MONEY;
mv = ((long long)(i1->Types.Money.WholePart)) * 10000 + i1->Types.Money.FractionPart;
mv *= i0->Integer;
mv = i1->Types.Money.Value * i0->Integer;
break;
case DATA_T_STRING:
tree->DataType = DATA_T_STRING;
Expand All @@ -453,8 +413,7 @@ expEvalMultiply(pExpression tree, pParamObjects objlist)
{
case DATA_T_MONEY:
tree->DataType = DATA_T_MONEY;
mv = ((long long)(i1->Types.Money.WholePart)) * 10000 + i1->Types.Money.FractionPart;
mv *= i0->Types.Double;
mv = i1->Types.Money.Value * i0->Types.Double;
break;
default:
tree->Types.Double = i0->Types.Double * objDataToDouble(i1->DataType, dptr);
Expand All @@ -465,7 +424,7 @@ expEvalMultiply(pExpression tree, pParamObjects objlist)

case DATA_T_MONEY:
tree->DataType = DATA_T_MONEY;
mv = ((long long)(i0->Types.Money.WholePart)) * 10000 + i0->Types.Money.FractionPart;
mv = i0->Types.Money.Value;
switch(i1->DataType)
{
case DATA_T_INTEGER:
Expand Down Expand Up @@ -505,14 +464,7 @@ expEvalMultiply(pExpression tree, pParamObjects objlist)
/** Common processing **/
if (tree->DataType == DATA_T_MONEY)
{
tree->Types.Money.WholePart = mv/10000;
mv = mv % 10000;
if (mv < 0)
{
mv += 10000;
tree->Types.Money.WholePart -= 1;
}
tree->Types.Money.FractionPart = mv;
tree->Types.Money.Value = mv;
}
else if (tree->DataType == DATA_T_STRING)
{
Expand Down Expand Up @@ -604,17 +556,9 @@ expEvalMinus(pExpression tree, pParamObjects objlist)
tree->Types.Double = (double)(i0->Integer) - i1->Types.Double;
break;
case DATA_T_MONEY:
/** Treat Int as a dollar value **/
tree->DataType = DATA_T_MONEY;
tree->Types.Money.WholePart = i0->Integer - i1->Types.Money.WholePart;
if (i1->Types.Money.FractionPart == 0)
{
tree->Types.Money.FractionPart = 0;
}
else
{
tree->Types.Money.WholePart--;
tree->Types.Money.FractionPart = 10000 - i1->Types.Money.FractionPart;
}
tree->Types.Money.Value = (i0->Integer * 10000ll) - i1->Types.Money.Value;
break;
default:
tree->Integer = i0->Integer - objDataToInteger(i1->DataType, dptr, NULL);
Expand All @@ -635,7 +579,7 @@ expEvalMinus(pExpression tree, pParamObjects objlist)
break;
case DATA_T_MONEY:
tree->DataType = DATA_T_DOUBLE;
tree->Types.Double = i0->Types.Double - (i1->Types.Money.WholePart + i1->Types.Money.FractionPart/10000.0);
tree->Types.Double = i0->Types.Double - (i1->Types.Money.Value / 10000.0);
break;
default:
tree->DataType = DATA_T_DOUBLE;
Expand All @@ -649,25 +593,16 @@ expEvalMinus(pExpression tree, pParamObjects objlist)
{
case DATA_T_INTEGER:
tree->DataType = DATA_T_MONEY;
tree->Types.Money.WholePart = i0->Types.Money.WholePart - i1->Integer;
tree->Types.Money.FractionPart = i0->Types.Money.FractionPart;
/** Since Value is in 1/10000 of a dollar, integer must be multiplied to scale **/
tree->Types.Money.Value = i0->Types.Money.Value - (i1->Integer * 10000ll);
break;
case DATA_T_DOUBLE:
tree->DataType = DATA_T_DOUBLE;
tree->Types.Double = (i0->Types.Money.WholePart + i0->Types.Money.FractionPart/10000.0) - i1->Types.Double;
tree->Types.Double = (i0->Types.Money.Value / 10000.0) - i1->Types.Double;
break;
case DATA_T_MONEY:
tree->DataType = DATA_T_MONEY;
tree->Types.Money.WholePart = i0->Types.Money.WholePart - i1->Types.Money.WholePart;
tree->Types.Money.FractionPart = 10000 + i0->Types.Money.FractionPart - i1->Types.Money.FractionPart;
if (tree->Types.Money.FractionPart >= 10000)
{
tree->Types.Money.FractionPart -= 10000;
}
else
{
tree->Types.Money.WholePart--;
}
tree->Types.Money.Value = i0->Types.Money.Value - i1->Types.Money.Value;
break;
default:
if (objDataToMoney(i1->DataType, dptr, &m) < 0)
Expand All @@ -676,12 +611,7 @@ expEvalMinus(pExpression tree, pParamObjects objlist)
return -1;
}
tree->DataType = DATA_T_MONEY;
tree->Types.Money.WholePart = i0->Types.Money.WholePart - m.WholePart;
tree->Types.Money.FractionPart = 10000 + i0->Types.Money.FractionPart - m.FractionPart;
if (tree->Types.Money.FractionPart >= 10000)
tree->Types.Money.FractionPart -= 10000;
else
tree->Types.Money.WholePart--;
tree->Types.Money.Value = i0->Types.Money.Value - m.Value;
break;
}
break;
Expand Down Expand Up @@ -806,8 +736,8 @@ expEvalPlus(pExpression tree, pParamObjects objlist)

case DATA_T_MONEY:
tree->DataType = DATA_T_MONEY;
tree->Types.Money.WholePart = i1->Types.Money.WholePart + i0->Integer;
tree->Types.Money.FractionPart = i1->Types.Money.FractionPart;
/** Int must be converted to 1/10000 of a dollar **/
tree->Types.Money.Value = i1->Types.Money.Value + (i0->Integer * 10000ll);
break;

default:
Expand Down Expand Up @@ -843,13 +773,7 @@ expEvalPlus(pExpression tree, pParamObjects objlist)

case DATA_T_MONEY:
objDataToMoney(i1->DataType, dptr, &m);
tree->Types.Money.WholePart = i0->Types.Money.WholePart + m.WholePart;
tree->Types.Money.FractionPart = i0->Types.Money.FractionPart + m.FractionPart;
if (tree->Types.Money.FractionPart >= 10000)
{
tree->Types.Money.FractionPart -= 10000;
tree->Types.Money.WholePart++;
}
tree->Types.Money.Value = i0->Types.Money.Value + m.Value;
break;

case DATA_T_DATETIME:
Expand Down Expand Up @@ -1502,8 +1426,7 @@ expRevEvalProperty(pExpression tree, pParamObjects objlist)
}
else if (tree->DataType == DATA_T_INTEGER && attr_type == DATA_T_MONEY)
{
tree->Types.Money.WholePart = tree->Integer;
tree->Types.Money.FractionPart = 0;
tree->Types.Money.Value = (tree->Integer * 10000ll);
}
else if (tree->DataType == DATA_T_DOUBLE && attr_type == DATA_T_MONEY)
{
Expand Down
Loading