|
|
@@ -24,9 +24,9 @@ static const double g_rgdblTens[] =
|
|
|
1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28
|
|
|
};
|
|
|
|
|
|
-static inline wchar_t ToDigit(long wVal)
|
|
|
+static inline wchar16 ToDigit(long wVal)
|
|
|
{
|
|
|
- //return reinterpret_cast<wchar_t>((wVal < 10) ? '0' + (ushort) wVal : 'a' - 10 + (ushort) wVal);
|
|
|
+ //return reinterpret_cast<wchar16>((wVal < 10) ? '0' + (ushort) wVal : 'a' - 10 + (ushort) wVal);
|
|
|
return (ushort)((wVal < 10) ? '0' + (ushort) wVal : 'a' - 10 + (ushort) wVal);
|
|
|
}
|
|
|
|
|
|
@@ -1256,7 +1256,7 @@ LDone:
|
|
|
return dbl;
|
|
|
}
|
|
|
|
|
|
-template double Js::NumberUtilities::StrToDbl<wchar_t>( const wchar_t * psz, const wchar_t **ppchLim, bool& likelyInt );
|
|
|
+template double Js::NumberUtilities::StrToDbl<wchar16>( const wchar16 * psz, const wchar16 **ppchLim, bool& likelyInt );
|
|
|
template double Js::NumberUtilities::StrToDbl<utf8char_t>(const utf8char_t * psz, const utf8char_t **ppchLim, bool& likelyInt);
|
|
|
|
|
|
/***************************************************************************
|
|
|
@@ -1919,18 +1919,18 @@ static BOOL FormatDigits(_In_reads_(pbLim - pbSrc) byte *pbSrc, byte *pbLim, int
|
|
|
Assert(wExp10 < 1000);
|
|
|
if (wExp10 >= 100)
|
|
|
{
|
|
|
- *pchDst++ = (wchar_t)('0' + wExp10 / 100);
|
|
|
+ *pchDst++ = (wchar16)('0' + wExp10 / 100);
|
|
|
wExp10 %= 100;
|
|
|
- *pchDst++ = (wchar_t)('0' + wExp10 / 10);
|
|
|
+ *pchDst++ = (wchar16)('0' + wExp10 / 10);
|
|
|
wExp10 %= 10;
|
|
|
}
|
|
|
else if (wExp10 >= 10)
|
|
|
{
|
|
|
- *pchDst++ = (wchar_t)('0' + wExp10 / 10);
|
|
|
+ *pchDst++ = (wchar16)('0' + wExp10 / 10);
|
|
|
wExp10 %= 10;
|
|
|
}
|
|
|
#pragma prefast(suppress:26014, "We have calculate the check the buffer size above already")
|
|
|
- *pchDst++ = (wchar_t)('0' + wExp10);
|
|
|
+ *pchDst++ = (wchar16)('0' + wExp10);
|
|
|
*pchDst = 0;
|
|
|
}
|
|
|
else if (wExp10 <= 0)
|
|
|
@@ -1963,7 +1963,7 @@ static BOOL FormatDigits(_In_reads_(pbLim - pbSrc) byte *pbSrc, byte *pbLim, int
|
|
|
|
|
|
__success(return <= nDstBufSize)
|
|
|
#pragma prefast(suppress:6101, "when return value is > nDstBufSize, the pchDst is not initialized. Prefast doesn't seems to pick that up in the annotation")
|
|
|
-static int FormatDigitsFixed(byte *pbSrc, byte *pbLim, int wExp10, int nFractionDigits, __out_ecount_part(nDstBufSize, return) wchar_t *pchDst, int nDstBufSize)
|
|
|
+static int FormatDigitsFixed(byte *pbSrc, byte *pbLim, int wExp10, int nFractionDigits, __out_ecount_part(nDstBufSize, return) wchar16 *pchDst, int nDstBufSize)
|
|
|
{
|
|
|
AnalysisAssert(pbLim > pbSrc);
|
|
|
AssertArrMem(pbSrc, pbLim - pbSrc);
|
|
|
@@ -2054,7 +2054,7 @@ static int FormatDigitsExponential(
|
|
|
byte * pbLim,
|
|
|
int wExp10,
|
|
|
int nFractionDigits,
|
|
|
- __out_ecount_part(cchDst,return) wchar_t * pchDst,
|
|
|
+ __out_ecount_part(cchDst,return) wchar16 * pchDst,
|
|
|
int cchDst
|
|
|
)
|
|
|
{
|
|
|
@@ -2105,7 +2105,7 @@ static int FormatDigitsExponential(
|
|
|
if (cchDst < n) return n;
|
|
|
|
|
|
#if DBG // save pchDst to validate n
|
|
|
- wchar_t * pchDstStart = pchDst;
|
|
|
+ wchar16 * pchDstStart = pchDst;
|
|
|
#endif
|
|
|
|
|
|
// First digit
|
|
|
@@ -2148,17 +2148,17 @@ static int FormatDigitsExponential(
|
|
|
// Exponent Digits
|
|
|
if (wExp10 >= 100)
|
|
|
{
|
|
|
- *pchDst++ = (wchar_t)('0' + wExp10 / 100);
|
|
|
+ *pchDst++ = (wchar16)('0' + wExp10 / 100);
|
|
|
wExp10 %= 100;
|
|
|
- *pchDst++ = (wchar_t)('0' + wExp10 / 10);
|
|
|
+ *pchDst++ = (wchar16)('0' + wExp10 / 10);
|
|
|
wExp10 %= 10;
|
|
|
}
|
|
|
else if (wExp10 >= 10)
|
|
|
{
|
|
|
- *pchDst++ = (wchar_t)('0' + wExp10 / 10);
|
|
|
+ *pchDst++ = (wchar16)('0' + wExp10 / 10);
|
|
|
wExp10 %= 10;
|
|
|
}
|
|
|
- *pchDst++ = (wchar_t)('0' + wExp10);
|
|
|
+ *pchDst++ = (wchar16)('0' + wExp10);
|
|
|
|
|
|
*pchDst = 0;
|
|
|
Assert(1 + pchDst - pchDstStart == n);
|
|
|
@@ -2241,7 +2241,7 @@ static int RoundTo(byte *pbSrc, byte *pbLim, int nDigits, __out_bcount(nDigits+1
|
|
|
* Returns the number of chars. in the result. If 'nDstBufSize'
|
|
|
* is less than this number, no data is written to the buffer 'pchDst'.
|
|
|
*/
|
|
|
-int Js::NumberUtilities::FDblToStr(double dbl, Js::NumberUtilities::FormatType ft, int nDigits, __out_ecount(cchDst) wchar_t *pchDst, int cchDst)
|
|
|
+int Js::NumberUtilities::FDblToStr(double dbl, Js::NumberUtilities::FormatType ft, int nDigits, __out_ecount(cchDst) wchar16 *pchDst, int cchDst)
|
|
|
{
|
|
|
int n = 0; // the no. of chars in the result.
|
|
|
int wExp10;
|
|
|
@@ -2254,7 +2254,7 @@ int Js::NumberUtilities::FDblToStr(double dbl, Js::NumberUtilities::FormatType f
|
|
|
{
|
|
|
n = 4; //(int)wcslen(OLESTR("NaN")) + 1;
|
|
|
if( cchDst >= n )
|
|
|
- wcscpy_s(pchDst, cchDst, L"NaN");
|
|
|
+ wcscpy_s(pchDst, cchDst, CH_WSTR("NaN"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -2269,7 +2269,7 @@ int Js::NumberUtilities::FDblToStr(double dbl, Js::NumberUtilities::FormatType f
|
|
|
{
|
|
|
if (neg)
|
|
|
*pchDst++ = '-';
|
|
|
- wcscpy_s(pchDst, cchDst - neg, L"Infinity");
|
|
|
+ wcscpy_s(pchDst, cchDst - neg, CH_WSTR("Infinity"));
|
|
|
}
|
|
|
}
|
|
|
return n;
|
|
|
@@ -2362,12 +2362,12 @@ int Js::NumberUtilities::FDblToStr(double dbl, Js::NumberUtilities::FormatType f
|
|
|
return n;
|
|
|
}
|
|
|
|
|
|
-BOOL Js::NumberUtilities::FDblToStr(double dbl, __out_ecount(cchDst) wchar_t *pchDst, int cchDst)
|
|
|
+BOOL Js::NumberUtilities::FDblToStr(double dbl, __out_ecount(cchDst) wchar16 *pchDst, int cchDst)
|
|
|
{
|
|
|
if (!Js::NumberUtilities::IsFinite(dbl))
|
|
|
{
|
|
|
if (Js::NumberUtilities::IsNan(dbl))
|
|
|
- return 0 == wcscpy_s(pchDst, cchDst, L"NaN");
|
|
|
+ return 0 == wcscpy_s(pchDst, cchDst, CH_WSTR("NaN"));
|
|
|
else
|
|
|
{
|
|
|
if (dbl < 0)
|
|
|
@@ -2377,7 +2377,7 @@ BOOL Js::NumberUtilities::FDblToStr(double dbl, __out_ecount(cchDst) wchar_t *pc
|
|
|
cchDst--;
|
|
|
}
|
|
|
|
|
|
- return 0 == wcscpy_s(pchDst, cchDst, L"Infinity");
|
|
|
+ return 0 == wcscpy_s(pchDst, cchDst, CH_WSTR("Infinity"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2412,7 +2412,7 @@ BOOL Js::NumberUtilities::FNonZeroFiniteDblToStr(double dbl, __out_ecount(cchDst
|
|
|
|
|
|
#if DBG
|
|
|
double dblT;
|
|
|
- const wchar_t *pch;
|
|
|
+ const wchar16 *pch;
|
|
|
|
|
|
// In Debug, always call FDblToRgbPrecise and verify that it converts back.
|
|
|
if (FDblToRgbPrecise(dbl, rgb, &wExp10, &pbLim))
|
|
|
@@ -2420,7 +2420,7 @@ BOOL Js::NumberUtilities::FNonZeroFiniteDblToStr(double dbl, __out_ecount(cchDst
|
|
|
if (FormatDigits(rgb, pbLim, wExp10, pchDst, cchDst))
|
|
|
{
|
|
|
bool likelyInt = true;
|
|
|
- dblT = StrToDbl<wchar_t>(pchDst, &pch,likelyInt);
|
|
|
+ dblT = StrToDbl<wchar16>(pchDst, &pch,likelyInt);
|
|
|
Assert(0 == *pch);
|
|
|
Assert(dblT == dbl);
|
|
|
}
|
|
|
@@ -2446,7 +2446,7 @@ BOOL Js::NumberUtilities::FNonZeroFiniteDblToStr(double dbl, __out_ecount(cchDst
|
|
|
|
|
|
#if DBG
|
|
|
bool likelyInt = true;
|
|
|
- dblT = StrToDbl<wchar_t>(pchDst, &pch, likelyInt);
|
|
|
+ dblT = StrToDbl<wchar16>(pchDst, &pch, likelyInt);
|
|
|
Assert(0 == *pch);
|
|
|
Assert(dblT == dbl);
|
|
|
#endif //DBG
|
|
|
@@ -2484,7 +2484,7 @@ BOOL Js::NumberUtilities::FNonZeroFiniteDblToStr(double dbl, _In_range_(2, 36) i
|
|
|
int wExp2, wExp, wDig;
|
|
|
int maxOutDigits, cchSig, cch;
|
|
|
int len = nDstBufSize;
|
|
|
- wchar_t * ppsz = psz;
|
|
|
+ wchar16 * ppsz = psz;
|
|
|
|
|
|
if (0x80000000 & Js::NumberUtilities::LuHiDbl(dbl))
|
|
|
{
|
|
|
@@ -2611,16 +2611,16 @@ BOOL Js::NumberUtilities::FNonZeroFiniteDblToStr(double dbl, _In_range_(2, 36) i
|
|
|
{
|
|
|
if (wExp >= 1000)
|
|
|
{
|
|
|
- *ppsz++ = (wchar_t)('0' + wExp / 1000);
|
|
|
+ *ppsz++ = (wchar16)('0' + wExp / 1000);
|
|
|
wExp %= 1000;
|
|
|
}
|
|
|
- *ppsz++ = (wchar_t)('0' + wExp / 100);
|
|
|
+ *ppsz++ = (wchar16)('0' + wExp / 100);
|
|
|
wExp %= 100;
|
|
|
}
|
|
|
- *ppsz++ = (wchar_t)('0' + wExp / 10);
|
|
|
+ *ppsz++ = (wchar16)('0' + wExp / 10);
|
|
|
wExp %= 10;
|
|
|
}
|
|
|
- *ppsz++ = (wchar_t)('0' + wExp);
|
|
|
+ *ppsz++ = (wchar16)('0' + wExp);
|
|
|
*ppsz++ = ')';
|
|
|
*ppsz = 0;
|
|
|
|
|
|
@@ -2747,13 +2747,13 @@ double Js::NumberUtilities::DblFromDecimal(DECIMAL * pdecIn)
|
|
|
return dblRet;
|
|
|
}
|
|
|
|
|
|
-void Js::NumberUtilities::CodePointAsSurrogatePair(codepoint_t codePointValue, __out wchar_t* first, __out wchar_t* second)
|
|
|
+void Js::NumberUtilities::CodePointAsSurrogatePair(codepoint_t codePointValue, __out wchar16* first, __out wchar16* second)
|
|
|
{
|
|
|
AssertMsg(first != nullptr && second != nullptr, "Null ptr's passed in for out.");
|
|
|
AssertMsg(IsInSupplementaryPlane(codePointValue), "Code point is not a surrogate pair.");
|
|
|
codePointValue -= 0x10000;
|
|
|
- *first = (wchar_t)(codePointValue >> 10) + 0xD800;
|
|
|
- *second = (wchar_t)(codePointValue & 0x3FF /* This is same as cpv % 0x400 */) + 0xDC00;
|
|
|
+ *first = (wchar16)(codePointValue >> 10) + 0xD800;
|
|
|
+ *second = (wchar16)(codePointValue & 0x3FF /* This is same as cpv % 0x400 */) + 0xDC00;
|
|
|
}
|
|
|
|
|
|
codepoint_t Js::NumberUtilities::SurrogatePairAsCodePoint(codepoint_t first, codepoint_t second)
|