Changeset 21916 for trunk/src/oleaut32/variant.c
- Timestamp:
- Dec 18, 2011, 10:28:22 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 bin 2 Makefile.inc 1 env.cmd 2 LocalConfig.kmk
-
-
Property svn:mergeinfo
set to
/branches/gcc-kmk merged eligible
- Property svn:ignore
-
trunk/src/oleaut32/variant.c
r21308 r21916 674 674 * Round the double value to the nearest integer value. 675 675 */ 676 static double r ound( double d )676 static double rnd( double d ) 677 677 { 678 678 double decimals = 0.0, integerValue = 0.0, roundedValue = 0.0; … … 2254 2254 /* Check range of value. 2255 2255 */ 2256 fltIn = r ound( fltIn );2256 fltIn = rnd( fltIn ); 2257 2257 if( fltIn < UI1_MIN || fltIn > UI1_MAX ) 2258 2258 { … … 2274 2274 /* Check range of value. 2275 2275 */ 2276 dblIn = r ound( dblIn );2276 dblIn = rnd( dblIn ); 2277 2277 if( dblIn < UI1_MIN || dblIn > UI1_MAX ) 2278 2278 { … … 2294 2294 /* Check range of value. 2295 2295 */ 2296 dateIn = r ound( dateIn );2296 dateIn = rnd( dateIn ); 2297 2297 if( dateIn < UI1_MIN || dateIn > UI1_MAX ) 2298 2298 { … … 2397 2397 /* Check range of value. 2398 2398 */ 2399 dValue = r ound( dValue );2399 dValue = rnd( dValue ); 2400 2400 if( dValue < UI1_MIN || dValue > UI1_MAX ) 2401 2401 { … … 2413 2413 */ 2414 2414 HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE* pbOut) { 2415 double t = r ound((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);2415 double t = rnd((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 2416 2416 2417 2417 if (t > UI1_MAX || t < UI1_MIN) return DISP_E_OVERFLOW; … … 2461 2461 /* Check range of value. 2462 2462 */ 2463 fltIn = r ound( fltIn );2463 fltIn = rnd( fltIn ); 2464 2464 if( fltIn < I2_MIN || fltIn > I2_MAX ) 2465 2465 { … … 2481 2481 /* Check range of value. 2482 2482 */ 2483 dblIn = r ound( dblIn );2483 dblIn = rnd( dblIn ); 2484 2484 if( dblIn < I2_MIN || dblIn > I2_MAX ) 2485 2485 { … … 2501 2501 /* Check range of value. 2502 2502 */ 2503 dateIn = r ound( dateIn );2503 dateIn = rnd( dateIn ); 2504 2504 if( dateIn < I2_MIN || dateIn > I2_MAX ) 2505 2505 { … … 2603 2603 /* Check range of value. 2604 2604 */ 2605 dValue = r ound( dValue );2605 dValue = rnd( dValue ); 2606 2606 if( dValue < I2_MIN || dValue > I2_MAX ) 2607 2607 { … … 2619 2619 */ 2620 2620 HRESULT WINAPI VarI2FromCy(CY cyIn, short* psOut) { 2621 double t = r ound((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);2621 double t = rnd((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 2622 2622 2623 2623 if (t > I2_MAX || t < I2_MIN) return DISP_E_OVERFLOW; … … 2649 2649 /* Check range of value. 2650 2650 */ 2651 fltIn = r ound( fltIn );2651 fltIn = rnd( fltIn ); 2652 2652 if( fltIn < I4_MIN || fltIn > I4_MAX ) 2653 2653 { … … 2669 2669 /* Check range of value. 2670 2670 */ 2671 dblIn = r ound( dblIn );2671 dblIn = rnd( dblIn ); 2672 2672 if( dblIn < I4_MIN || dblIn > I4_MAX ) 2673 2673 { … … 2689 2689 /* Check range of value. 2690 2690 */ 2691 dateIn = r ound( dateIn );2691 dateIn = rnd( dateIn ); 2692 2692 if( dateIn < I4_MIN || dateIn > I4_MAX ) 2693 2693 { … … 2796 2796 /* Check range of value. 2797 2797 */ 2798 dValue = r ound( dValue );2798 dValue = rnd( dValue ); 2799 2799 if( dValue < I4_MIN || dValue > I4_MAX ) 2800 2800 { … … 2812 2812 */ 2813 2813 HRESULT WINAPI VarI4FromCy(CY cyIn, LONG* plOut) { 2814 double t = r ound((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);2814 double t = rnd((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 2815 2815 2816 2816 if (t > I4_MAX || t < I4_MIN) return DISP_E_OVERFLOW; … … 2986 2986 */ 2987 2987 HRESULT WINAPI VarR4FromCy(CY cyIn, FLOAT* pfltOut) { 2988 *pfltOut = (FLOAT)((((double)cyIn. s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);2988 *pfltOut = (FLOAT)((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 2989 2989 2990 2990 return S_OK; … … 3136 3136 */ 3137 3137 HRESULT WINAPI VarR8FromCy(CY cyIn, double* pdblOut) { 3138 *pdblOut = (double)((((double)cyIn. s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);3139 TRACE("%lu %ld -> %f\n", cyIn. s.Hi, cyIn.s.Lo, *pdblOut);3138 *pdblOut = (double)((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 3139 TRACE("%lu %ld -> %f\n", cyIn.DUMMYSTRUCTNAME_DOT Hi, cyIn.DUMMYSTRUCTNAME_DOT Lo, *pdblOut); 3140 3140 return S_OK; 3141 3141 } … … 3328 3328 */ 3329 3329 HRESULT WINAPI VarDateFromCy(CY cyIn, DATE* pdateOut) { 3330 *pdateOut = (DATE)((((double)cyIn. s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);3330 *pdateOut = (DATE)((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 3331 3331 3332 3332 if (*pdateOut > DATE_MAX || *pdateOut < DATE_MIN) return DISP_E_TYPEMISMATCH; … … 3688 3688 */ 3689 3689 HRESULT WINAPI VarBoolFromCy(CY cyIn, VARIANT_BOOL* pboolOut) { 3690 if (cyIn. s.Hi || cyIn.s.Lo) *pboolOut = -1;3690 if (cyIn.DUMMYSTRUCTNAME_DOT Hi || cyIn.DUMMYSTRUCTNAME_DOT Lo) *pboolOut = -1; 3691 3691 else *pboolOut = 0; 3692 3692 … … 3754 3754 TRACE("( %f, %p ), stub\n", fltIn, pcOut ); 3755 3755 3756 fltIn = r ound( fltIn );3756 fltIn = rnd( fltIn ); 3757 3757 if( fltIn < CHAR_MIN || fltIn > CHAR_MAX ) 3758 3758 { … … 3772 3772 TRACE("( %f, %p ), stub\n", dblIn, pcOut ); 3773 3773 3774 dblIn = r ound( dblIn );3774 dblIn = rnd( dblIn ); 3775 3775 if( dblIn < CHAR_MIN || dblIn > CHAR_MAX ) 3776 3776 { … … 3790 3790 TRACE("( %f, %p ), stub\n", dateIn, pcOut ); 3791 3791 3792 dateIn = r ound( dateIn );3792 dateIn = rnd( dateIn ); 3793 3793 if( dateIn < CHAR_MIN || dateIn > CHAR_MAX ) 3794 3794 { … … 3830 3830 /* Check range of value. 3831 3831 */ 3832 dValue = r ound( dValue );3832 dValue = rnd( dValue ); 3833 3833 if( dValue < CHAR_MIN || dValue > CHAR_MAX ) 3834 3834 { … … 3892 3892 */ 3893 3893 HRESULT WINAPI VarI1FromCy(CY cyIn, CHAR* pcOut) { 3894 double t = r ound((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);3894 double t = rnd((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 3895 3895 3896 3896 if (t > CHAR_MAX || t < CHAR_MIN) return DISP_E_OVERFLOW; … … 3953 3953 TRACE("( %f, %p ), stub\n", fltIn, puiOut ); 3954 3954 3955 fltIn = r ound( fltIn );3955 fltIn = rnd( fltIn ); 3956 3956 if( fltIn < UI2_MIN || fltIn > UI2_MAX ) 3957 3957 { … … 3971 3971 TRACE("( %f, %p ), stub\n", dblIn, puiOut ); 3972 3972 3973 dblIn = r ound( dblIn );3973 dblIn = rnd( dblIn ); 3974 3974 if( dblIn < UI2_MIN || dblIn > UI2_MAX ) 3975 3975 { … … 3989 3989 TRACE("( %f, %p ), stub\n", dateIn, puiOut ); 3990 3990 3991 dateIn = r ound( dateIn );3991 dateIn = rnd( dateIn ); 3992 3992 if( dateIn < UI2_MIN || dateIn > UI2_MAX ) 3993 3993 { … … 4029 4029 /* Check range of value. 4030 4030 */ 4031 dValue = r ound( dValue );4031 dValue = rnd( dValue ); 4032 4032 if( dValue < UI2_MIN || dValue > UI2_MAX ) 4033 4033 { … … 4110 4110 /* Check range of value. 4111 4111 */ 4112 dValue = r ound( dValue );4112 dValue = rnd( dValue ); 4113 4113 if( dValue < UI4_MIN || dValue > UI4_MAX ) 4114 4114 { … … 4126 4126 */ 4127 4127 HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut) { 4128 double t = r ound((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);4128 double t = rnd((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 4129 4129 4130 4130 if (t > UI2_MAX || t < UI2_MIN) return DISP_E_OVERFLOW; … … 4186 4186 HRESULT WINAPI VarUI4FromR4(FLOAT fltIn, ULONG* pulOut) 4187 4187 { 4188 fltIn = r ound( fltIn );4188 fltIn = rnd( fltIn ); 4189 4189 if( fltIn < UI4_MIN || fltIn > UI4_MAX ) 4190 4190 { … … 4204 4204 TRACE("( %f, %p ), stub\n", dblIn, pulOut ); 4205 4205 4206 dblIn = r ound( dblIn );4206 dblIn = rnd( dblIn ); 4207 4207 if( dblIn < UI4_MIN || dblIn > UI4_MAX ) 4208 4208 { … … 4222 4222 TRACE("( %f, %p ), stub\n", dateIn, pulOut ); 4223 4223 4224 dateIn = r ound( dateIn );4224 dateIn = rnd( dateIn ); 4225 4225 if( dateIn < UI4_MIN || dateIn > UI4_MAX ) 4226 4226 { … … 4274 4274 */ 4275 4275 HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG* pulOut) { 4276 double t = r ound((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);4276 double t = rnd((((double)cyIn.DUMMYSTRUCTNAME_DOT Hi * 4294967296.0) + (double)cyIn.DUMMYSTRUCTNAME_DOT Lo) / 10000); 4277 4277 4278 4278 if (t > UI4_MAX || t < UI4_MIN) return DISP_E_OVERFLOW; … … 4288 4288 */ 4289 4289 HRESULT WINAPI VarCyFromUI1(BYTE bIn, CY* pcyOut) { 4290 pcyOut-> s.Hi = 0;4291 pcyOut-> s.Lo = ((ULONG)bIn) * 10000;4290 pcyOut->DUMMYSTRUCTNAME_DOT Hi = 0; 4291 pcyOut->DUMMYSTRUCTNAME_DOT Lo = ((ULONG)bIn) * 10000; 4292 4292 4293 4293 return S_OK; … … 4299 4299 */ 4300 4300 HRESULT WINAPI VarCyFromI2(short sIn, CY* pcyOut) { 4301 if (sIn < 0) pcyOut-> s.Hi = -1;4302 else pcyOut-> s.Hi = 0;4303 pcyOut-> s.Lo = ((ULONG)sIn) * 10000;4301 if (sIn < 0) pcyOut->DUMMYSTRUCTNAME_DOT Hi = -1; 4302 else pcyOut->DUMMYSTRUCTNAME_DOT Hi = 0; 4303 pcyOut->DUMMYSTRUCTNAME_DOT Lo = ((ULONG)sIn) * 10000; 4304 4304 4305 4305 return S_OK; … … 4312 4312 HRESULT WINAPI VarCyFromI4(LONG lIn, CY* pcyOut) { 4313 4313 double t = (double)lIn * (double)10000; 4314 pcyOut-> s.Hi = (LONG)(t / (double)4294967296.0);4315 pcyOut-> s.Lo = (ULONG)fmod(t, (double)4294967296.0);4316 if (lIn < 0) pcyOut-> s.Hi--;4314 pcyOut->DUMMYSTRUCTNAME_DOT Hi = (LONG)(t / (double)4294967296.0); 4315 pcyOut->DUMMYSTRUCTNAME_DOT Lo = (ULONG)fmod(t, (double)4294967296.0); 4316 if (lIn < 0) pcyOut->DUMMYSTRUCTNAME_DOT Hi--; 4317 4317 4318 4318 return S_OK; … … 4324 4324 */ 4325 4325 HRESULT WINAPI VarCyFromR4(FLOAT fltIn, CY* pcyOut) { 4326 double t = r ound((double)fltIn * (double)10000);4327 pcyOut-> s.Hi = (LONG)(t / (double)4294967296.0);4328 pcyOut-> s.Lo = (ULONG)fmod(t, (double)4294967296.0);4329 if (fltIn < 0) pcyOut-> s.Hi--;4326 double t = rnd((double)fltIn * (double)10000); 4327 pcyOut->DUMMYSTRUCTNAME_DOT Hi = (LONG)(t / (double)4294967296.0); 4328 pcyOut->DUMMYSTRUCTNAME_DOT Lo = (ULONG)fmod(t, (double)4294967296.0); 4329 if (fltIn < 0) pcyOut->DUMMYSTRUCTNAME_DOT Hi--; 4330 4330 4331 4331 return S_OK; … … 4337 4337 */ 4338 4338 HRESULT WINAPI VarCyFromR8(double dblIn, CY* pcyOut) { 4339 double t = r ound(dblIn * (double)10000);4340 pcyOut-> s.Hi = (LONG)(t / (double)4294967296.0);4341 pcyOut-> s.Lo = (ULONG)fmod(t, (double)4294967296.0);4342 if (dblIn < 0) pcyOut-> s.Hi--;4339 double t = rnd(dblIn * (double)10000); 4340 pcyOut->DUMMYSTRUCTNAME_DOT Hi = (LONG)(t / (double)4294967296.0); 4341 pcyOut->DUMMYSTRUCTNAME_DOT Lo = (ULONG)fmod(t, (double)4294967296.0); 4342 if (dblIn < 0) pcyOut->DUMMYSTRUCTNAME_DOT Hi--; 4343 4343 4344 4344 return S_OK; … … 4350 4350 */ 4351 4351 HRESULT WINAPI VarCyFromDate(DATE dateIn, CY* pcyOut) { 4352 double t = r ound((double)dateIn * (double)10000);4353 pcyOut-> s.Hi = (LONG)(t / (double)4294967296.0);4354 pcyOut-> s.Lo = (ULONG)fmod(t, (double)4294967296.0);4355 if (dateIn < 0) pcyOut-> s.Hi--;4352 double t = rnd((double)dateIn * (double)10000); 4353 pcyOut->DUMMYSTRUCTNAME_DOT Hi = (LONG)(t / (double)4294967296.0); 4354 pcyOut->DUMMYSTRUCTNAME_DOT Lo = (ULONG)fmod(t, (double)4294967296.0); 4355 if (dateIn < 0) pcyOut->DUMMYSTRUCTNAME_DOT Hi--; 4356 4356 4357 4357 return S_OK; … … 4418 4418 */ 4419 4419 HRESULT WINAPI VarCyFromBool(VARIANT_BOOL boolIn, CY* pcyOut) { 4420 if (boolIn < 0) pcyOut-> s.Hi = -1;4421 else pcyOut-> s.Hi = 0;4422 pcyOut-> s.Lo = (ULONG)boolIn * (ULONG)10000;4420 if (boolIn < 0) pcyOut->DUMMYSTRUCTNAME_DOT Hi = -1; 4421 else pcyOut->DUMMYSTRUCTNAME_DOT Hi = 0; 4422 pcyOut->DUMMYSTRUCTNAME_DOT Lo = (ULONG)boolIn * (ULONG)10000; 4423 4423 4424 4424 return S_OK; … … 4430 4430 */ 4431 4431 HRESULT WINAPI VarCyFromI1(signed char cIn, CY* pcyOut) { 4432 if (cIn < 0) pcyOut-> s.Hi = -1;4433 else pcyOut-> s.Hi = 0;4434 pcyOut-> s.Lo = (ULONG)cIn * (ULONG)10000;4432 if (cIn < 0) pcyOut->DUMMYSTRUCTNAME_DOT Hi = -1; 4433 else pcyOut->DUMMYSTRUCTNAME_DOT Hi = 0; 4434 pcyOut->DUMMYSTRUCTNAME_DOT Lo = (ULONG)cIn * (ULONG)10000; 4435 4435 4436 4436 return S_OK; … … 4442 4442 */ 4443 4443 HRESULT WINAPI VarCyFromUI2(USHORT usIn, CY* pcyOut) { 4444 pcyOut-> s.Hi = 0;4445 pcyOut-> s.Lo = (ULONG)usIn * (ULONG)10000;4444 pcyOut->DUMMYSTRUCTNAME_DOT Hi = 0; 4445 pcyOut->DUMMYSTRUCTNAME_DOT Lo = (ULONG)usIn * (ULONG)10000; 4446 4446 4447 4447 return S_OK; … … 4454 4454 HRESULT WINAPI VarCyFromUI4(ULONG ulIn, CY* pcyOut) { 4455 4455 double t = (double)ulIn * (double)10000; 4456 pcyOut-> s.Hi = (LONG)(t / (double)4294967296.0);4457 pcyOut-> s.Lo = (ULONG)fmod(t, (double)4294967296.0);4456 pcyOut->DUMMYSTRUCTNAME_DOT Hi = (LONG)(t / (double)4294967296.0); 4457 pcyOut->DUMMYSTRUCTNAME_DOT Lo = (ULONG)fmod(t, (double)4294967296.0); 4458 4458 4459 4459 return S_OK; … … 4570 4570 TRACE("Calculated currency is xint=%ld\n", xint); 4571 4571 VarCyFromInt( (int) xint, &V_UNION(pvar,cyVal) ); 4572 TRACE("Calculated cy is %ld,%lu\n", V_UNION(pvar,cyVal). s.Hi, V_UNION(pvar,cyVal).s.Lo);4572 TRACE("Calculated cy is %ld,%lu\n", V_UNION(pvar,cyVal).DUMMYSTRUCTNAME_DOT Hi, V_UNION(pvar,cyVal).DUMMYSTRUCTNAME_DOT Lo); 4573 4573 return VarCyFromInt( (int) xint, &V_UNION(pvar,cyVal) ); 4574 4574 } … … 5570 5570 rc = VarCyFromR8((cyVal * (double) mulBy), pcyOut); 5571 5571 TRACE("Multiply %f by %ld = %f [%ld,%lu]\n", cyVal, mulBy, (cyVal * (double) mulBy), 5572 pcyOut-> s.Hi, pcyOut->s.Lo);5572 pcyOut->DUMMYSTRUCTNAME_DOT Hi, pcyOut->DUMMYSTRUCTNAME_DOT Lo); 5573 5573 } 5574 5574 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.