CPDecimalAdd tested for underflow twice when reporting overflow of two negative operands, so the overflow was never swapped to underflow.
* CPDecimal: Swap CPCalculationOverflow to CPCalculationUnderflow for a negative result, matching CPDecimalSubtract.
* CPDecimalTest: Add a test that the overflow of two negative operands is reported as underflow.
References to undeclared variables created implicit globals, and an Internet Explorer code path referenced the now unsupported ActiveXObject.
* CPDecimal: Declare adderror in CPDecimalAdd and error1 in _SimpleDivide and _SimpleMultiply.
* CPFunctionOperation: Declare functionOp in +functionOperationWithFunction:.
* CPRunLoop: Declare CPMainRunLoop at file level instead of creating it as an implicit global in +initialize.
* CPWebDAVManager: Remove the ActiveXObject path from XMLDocumentFromString.
Without this fix, CPDecimal will return NaN for numbers that have leading zeros, e.g., 0123.
This fix changes the matching regex to allow leading zeros to pass. This is then converted to a proper number later on, e.g., "0123" => 123. This is in line with Cocoa behaviour.
This commit also includes updated unit tests.
And in general divisions where the quotient had fewer digits than the dividend when disregarding exponent would fail.
We want to stop dividing when we've gone over all the digits in the dividend and the remainder is 0.