| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 #include "core/fxcrt/include/fx_xml.h" | 10 #include "core/fxcrt/include/fx_xml.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 void CFX_Locale::GetTimeZone(FX_TIMEZONE& tz) const { | 211 void CFX_Locale::GetTimeZone(FX_TIMEZONE& tz) const { |
| 212 tz.tzHour = 0; | 212 tz.tzHour = 0; |
| 213 tz.tzMinute = 0; | 213 tz.tzMinute = 0; |
| 214 if (!m_pElement) { | 214 if (!m_pElement) { |
| 215 return; | 215 return; |
| 216 } | 216 } |
| 217 CXML_Element* pxmlTimeZone = m_pElement->GetElement("", "timeZone"); | 217 CXML_Element* pxmlTimeZone = m_pElement->GetElement("", "timeZone"); |
| 218 if (pxmlTimeZone) { | 218 if (pxmlTimeZone) { |
| 219 CFX_WideString wsTimeZone = pxmlTimeZone->GetContent(0); | 219 CFX_WideString wsTimeZone = pxmlTimeZone->GetContent(0); |
| 220 FX_ParseTimeZone(wsTimeZone, wsTimeZone.GetLength(), tz); | 220 FX_ParseTimeZone(wsTimeZone.c_str(), wsTimeZone.GetLength(), tz); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 void CFX_Locale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { | 223 void CFX_Locale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { |
| 224 if (!m_pElement) { | 224 if (!m_pElement) { |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName); | 227 FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName); |
| 228 } | 228 } |
| 229 static void FX_GetPattern(CXML_Element* pXmlElement, | 229 static void FX_GetPattern(CXML_Element* pXmlElement, |
| 230 const CFX_ByteString& bsCategory, | 230 const CFX_ByteString& bsCategory, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 lcnum.m_Fractional = 0; | 308 lcnum.m_Fractional = 0; |
| 309 lcnum.m_Exponent = 0; | 309 lcnum.m_Exponent = 0; |
| 310 | 310 |
| 311 if (wsValue.IsEmpty()) | 311 if (wsValue.IsEmpty()) |
| 312 return FALSE; | 312 return FALSE; |
| 313 | 313 |
| 314 const int32_t nIntegralMaxLen = 17; | 314 const int32_t nIntegralMaxLen = 17; |
| 315 int32_t cc = 0; | 315 int32_t cc = 0; |
| 316 bool bNegative = false; | 316 bool bNegative = false; |
| 317 bool bExpSign = false; | 317 bool bExpSign = false; |
| 318 const FX_WCHAR* str = (const FX_WCHAR*)wsValue; | 318 const FX_WCHAR* str = wsValue.c_str(); |
| 319 int32_t len = wsValue.GetLength(); | 319 int32_t len = wsValue.GetLength(); |
| 320 while (cc < len && FX_IsSpace(str[cc])) | 320 while (cc < len && FX_IsSpace(str[cc])) |
| 321 cc++; | 321 cc++; |
| 322 | 322 |
| 323 if (cc >= len) | 323 if (cc >= len) |
| 324 return FALSE; | 324 return FALSE; |
| 325 | 325 |
| 326 if (str[cc] == '+') { | 326 if (str[cc] == '+') { |
| 327 cc++; | 327 cc++; |
| 328 } else if (str[cc] == '-') { | 328 } else if (str[cc] == '-') { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } | 455 } |
| 456 return wsResult; | 456 return wsResult; |
| 457 } | 457 } |
| 458 | 458 |
| 459 CFX_FormatString::CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID) | 459 CFX_FormatString::CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID) |
| 460 : m_pLocaleMgr(pLocaleMgr), m_bUseLCID(bUseLCID) {} | 460 : m_pLocaleMgr(pLocaleMgr), m_bUseLCID(bUseLCID) {} |
| 461 CFX_FormatString::~CFX_FormatString() {} | 461 CFX_FormatString::~CFX_FormatString() {} |
| 462 void CFX_FormatString::SplitFormatString(const CFX_WideString& wsFormatString, | 462 void CFX_FormatString::SplitFormatString(const CFX_WideString& wsFormatString, |
| 463 CFX_WideStringArray& wsPatterns) { | 463 CFX_WideStringArray& wsPatterns) { |
| 464 int32_t iStrLen = wsFormatString.GetLength(); | 464 int32_t iStrLen = wsFormatString.GetLength(); |
| 465 const FX_WCHAR* pStr = (const FX_WCHAR*)wsFormatString; | 465 const FX_WCHAR* pStr = wsFormatString.c_str(); |
| 466 const FX_WCHAR* pToken = pStr; | 466 const FX_WCHAR* pToken = pStr; |
| 467 const FX_WCHAR* pEnd = pStr + iStrLen; | 467 const FX_WCHAR* pEnd = pStr + iStrLen; |
| 468 FX_BOOL iQuote = FALSE; | 468 FX_BOOL iQuote = FALSE; |
| 469 while (TRUE) { | 469 while (TRUE) { |
| 470 if (pStr >= pEnd) { | 470 if (pStr >= pEnd) { |
| 471 CFX_WideString sub(pToken, pStr - pToken); | 471 CFX_WideString sub(pToken, pStr - pToken); |
| 472 wsPatterns.Add(sub); | 472 wsPatterns.Add(sub); |
| 473 return; | 473 return; |
| 474 } else if (*pStr == '\'') { | 474 } else if (*pStr == '\'') { |
| 475 iQuote = !iQuote; | 475 iQuote = !iQuote; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 } | 566 } |
| 567 wsOutput = pStrPattern[iPattern--] + wsOutput; | 567 wsOutput = pStrPattern[iPattern--] + wsOutput; |
| 568 } | 568 } |
| 569 return wsOutput; | 569 return wsOutput; |
| 570 } | 570 } |
| 571 FX_LOCALECATEGORY CFX_FormatString::GetCategory( | 571 FX_LOCALECATEGORY CFX_FormatString::GetCategory( |
| 572 const CFX_WideString& wsPattern) { | 572 const CFX_WideString& wsPattern) { |
| 573 FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; | 573 FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; |
| 574 int32_t ccf = 0; | 574 int32_t ccf = 0; |
| 575 int32_t iLenf = wsPattern.GetLength(); | 575 int32_t iLenf = wsPattern.GetLength(); |
| 576 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; | 576 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 577 FX_BOOL bBraceOpen = FALSE; | 577 FX_BOOL bBraceOpen = FALSE; |
| 578 while (ccf < iLenf) { | 578 while (ccf < iLenf) { |
| 579 if (pStr[ccf] == '\'') { | 579 if (pStr[ccf] == '\'') { |
| 580 FX_GetLiteralText(pStr, ccf, iLenf); | 580 FX_GetLiteralText(pStr, ccf, iLenf); |
| 581 } else if (!bBraceOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { | 581 } else if (!bBraceOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { |
| 582 CFX_WideString wsCategory(pStr[ccf]); | 582 CFX_WideString wsCategory(pStr[ccf]); |
| 583 ccf++; | 583 ccf++; |
| 584 while (TRUE) { | 584 while (TRUE) { |
| 585 if (ccf == iLenf) { | 585 if (ccf == iLenf) { |
| 586 return eCategory; | 586 return eCategory; |
| 587 } | 587 } |
| 588 if (pStr[ccf] == '.' || pStr[ccf] == '(') { | 588 if (pStr[ccf] == '.' || pStr[ccf] == '(') { |
| 589 break; | 589 break; |
| 590 } | 590 } |
| 591 if (pStr[ccf] == '{') { | 591 if (pStr[ccf] == '{') { |
| 592 bBraceOpen = TRUE; | 592 bBraceOpen = TRUE; |
| 593 break; | 593 break; |
| 594 } | 594 } |
| 595 wsCategory += pStr[ccf]; | 595 wsCategory += pStr[ccf]; |
| 596 ccf++; | 596 ccf++; |
| 597 } | 597 } |
| 598 uint32_t dwHash = | 598 uint32_t dwHash = |
| 599 FX_HashCode_String_GetW(wsCategory, wsCategory.GetLength()); | 599 FX_HashCode_String_GetW(wsCategory.c_str(), wsCategory.GetLength()); |
| 600 if (dwHash == FX_LOCALECATEGORY_DateHash) { | 600 if (dwHash == FX_LOCALECATEGORY_DateHash) { |
| 601 if (eCategory == FX_LOCALECATEGORY_Time) { | 601 if (eCategory == FX_LOCALECATEGORY_Time) { |
| 602 return FX_LOCALECATEGORY_DateTime; | 602 return FX_LOCALECATEGORY_DateTime; |
| 603 } | 603 } |
| 604 eCategory = FX_LOCALECATEGORY_Date; | 604 eCategory = FX_LOCALECATEGORY_Date; |
| 605 } else if (dwHash == FX_LOCALECATEGORY_TimeHash) { | 605 } else if (dwHash == FX_LOCALECATEGORY_TimeHash) { |
| 606 if (eCategory == FX_LOCALECATEGORY_Date) { | 606 if (eCategory == FX_LOCALECATEGORY_Date) { |
| 607 return FX_LOCALECATEGORY_DateTime; | 607 return FX_LOCALECATEGORY_DateTime; |
| 608 } | 608 } |
| 609 eCategory = FX_LOCALECATEGORY_Time; | 609 eCategory = FX_LOCALECATEGORY_Time; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 626 return eCategory; | 626 return eCategory; |
| 627 } | 627 } |
| 628 static uint16_t FX_WStringToLCID(const FX_WCHAR* pstrLCID) { | 628 static uint16_t FX_WStringToLCID(const FX_WCHAR* pstrLCID) { |
| 629 if (!pstrLCID) { | 629 if (!pstrLCID) { |
| 630 return 0; | 630 return 0; |
| 631 } | 631 } |
| 632 wchar_t* pEnd; | 632 wchar_t* pEnd; |
| 633 return (uint16_t)wcstol((wchar_t*)pstrLCID, &pEnd, 16); | 633 return (uint16_t)wcstol((wchar_t*)pstrLCID, &pEnd, 16); |
| 634 } | 634 } |
| 635 uint16_t CFX_FormatString::GetLCID(const CFX_WideString& wsPattern) { | 635 uint16_t CFX_FormatString::GetLCID(const CFX_WideString& wsPattern) { |
| 636 return FX_WStringToLCID(GetLocaleName(wsPattern)); | 636 return FX_WStringToLCID(GetLocaleName(wsPattern).c_str()); |
| 637 } | 637 } |
| 638 CFX_WideString CFX_FormatString::GetLocaleName( | 638 CFX_WideString CFX_FormatString::GetLocaleName( |
| 639 const CFX_WideString& wsPattern) { | 639 const CFX_WideString& wsPattern) { |
| 640 int32_t ccf = 0; | 640 int32_t ccf = 0; |
| 641 int32_t iLenf = wsPattern.GetLength(); | 641 int32_t iLenf = wsPattern.GetLength(); |
| 642 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; | 642 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 643 while (ccf < iLenf) { | 643 while (ccf < iLenf) { |
| 644 if (pStr[ccf] == '\'') { | 644 if (pStr[ccf] == '\'') { |
| 645 FX_GetLiteralText(pStr, ccf, iLenf); | 645 FX_GetLiteralText(pStr, ccf, iLenf); |
| 646 } else if (pStr[ccf] == '(') { | 646 } else if (pStr[ccf] == '(') { |
| 647 ccf++; | 647 ccf++; |
| 648 CFX_WideString wsLCID; | 648 CFX_WideString wsLCID; |
| 649 while (ccf < iLenf && pStr[ccf] != ')') { | 649 while (ccf < iLenf && pStr[ccf] != ')') { |
| 650 wsLCID += pStr[ccf++]; | 650 wsLCID += pStr[ccf++]; |
| 651 } | 651 } |
| 652 return wsLCID; | 652 return wsLCID; |
| 653 } | 653 } |
| 654 ccf++; | 654 ccf++; |
| 655 } | 655 } |
| 656 return CFX_WideString(); | 656 return CFX_WideString(); |
| 657 } | 657 } |
| 658 IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern, | 658 IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern, |
| 659 const CFX_WideStringC& wsCategory, | 659 const CFX_WideStringC& wsCategory, |
| 660 CFX_WideString& wsPurgePattern) { | 660 CFX_WideString& wsPurgePattern) { |
| 661 IFX_Locale* pLocale = NULL; | 661 IFX_Locale* pLocale = NULL; |
| 662 int32_t ccf = 0; | 662 int32_t ccf = 0; |
| 663 int32_t iLenf = wsPattern.GetLength(); | 663 int32_t iLenf = wsPattern.GetLength(); |
| 664 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; | 664 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 665 FX_BOOL bBrackOpen = FALSE; | 665 FX_BOOL bBrackOpen = FALSE; |
| 666 while (ccf < iLenf) { | 666 while (ccf < iLenf) { |
| 667 if (pStr[ccf] == '\'') { | 667 if (pStr[ccf] == '\'') { |
| 668 int32_t iCurChar = ccf; | 668 int32_t iCurChar = ccf; |
| 669 FX_GetLiteralText(pStr, ccf, iLenf); | 669 FX_GetLiteralText(pStr, ccf, iLenf); |
| 670 wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); | 670 wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); |
| 671 } else if (!bBrackOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { | 671 } else if (!bBrackOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { |
| 672 CFX_WideString wsSearchCategory(pStr[ccf]); | 672 CFX_WideString wsSearchCategory(pStr[ccf]); |
| 673 ccf++; | 673 ccf++; |
| 674 while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && | 674 while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 #define FX_NUMSTYLE_Exponent 0x02 | 710 #define FX_NUMSTYLE_Exponent 0x02 |
| 711 #define FX_NUMSTYLE_DotVorv 0x04 | 711 #define FX_NUMSTYLE_DotVorv 0x04 |
| 712 IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, | 712 IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, |
| 713 int32_t& iDotIndex, | 713 int32_t& iDotIndex, |
| 714 uint32_t& dwStyle, | 714 uint32_t& dwStyle, |
| 715 CFX_WideString& wsPurgePattern) { | 715 CFX_WideString& wsPurgePattern) { |
| 716 dwStyle = 0; | 716 dwStyle = 0; |
| 717 IFX_Locale* pLocale = NULL; | 717 IFX_Locale* pLocale = NULL; |
| 718 int32_t ccf = 0; | 718 int32_t ccf = 0; |
| 719 int32_t iLenf = wsPattern.GetLength(); | 719 int32_t iLenf = wsPattern.GetLength(); |
| 720 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; | 720 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 721 FX_BOOL bFindDot = FALSE; | 721 FX_BOOL bFindDot = FALSE; |
| 722 FX_BOOL bBrackOpen = FALSE; | 722 FX_BOOL bBrackOpen = FALSE; |
| 723 while (ccf < iLenf) { | 723 while (ccf < iLenf) { |
| 724 if (pStr[ccf] == '\'') { | 724 if (pStr[ccf] == '\'') { |
| 725 int32_t iCurChar = ccf; | 725 int32_t iCurChar = ccf; |
| 726 FX_GetLiteralText(pStr, ccf, iLenf); | 726 FX_GetLiteralText(pStr, ccf, iLenf); |
| 727 wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); | 727 wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); |
| 728 } else if (!bBrackOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { | 728 } else if (!bBrackOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { |
| 729 CFX_WideString wsCategory(pStr[ccf]); | 729 CFX_WideString wsCategory(pStr[ccf]); |
| 730 ccf++; | 730 ccf++; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 748 pLocale = GetPatternLocale(wsLCID.AsStringC()); | 748 pLocale = GetPatternLocale(wsLCID.AsStringC()); |
| 749 } else if (pStr[ccf] == '{') { | 749 } else if (pStr[ccf] == '{') { |
| 750 bBrackOpen = TRUE; | 750 bBrackOpen = TRUE; |
| 751 break; | 751 break; |
| 752 } else if (pStr[ccf] == '.') { | 752 } else if (pStr[ccf] == '.') { |
| 753 CFX_WideString wsSubCategory; | 753 CFX_WideString wsSubCategory; |
| 754 ccf++; | 754 ccf++; |
| 755 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 755 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 756 wsSubCategory += pStr[ccf++]; | 756 wsSubCategory += pStr[ccf++]; |
| 757 } | 757 } |
| 758 uint32_t dwSubHash = | 758 uint32_t dwSubHash = FX_HashCode_String_GetW( |
| 759 FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); | 759 wsSubCategory.c_str(), wsSubCategory.GetLength()); |
| 760 FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; | 760 FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; |
| 761 for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { | 761 for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { |
| 762 if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { | 762 if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { |
| 763 eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] | 763 eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] |
| 764 .eSubCategory; | 764 .eSubCategory; |
| 765 break; | 765 break; |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 wsSubCategory.Empty(); | 768 wsSubCategory.Empty(); |
| 769 if (!pLocale) { | 769 if (!pLocale) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 if (!pLocale) { | 809 if (!pLocale) { |
| 810 pLocale = m_pLocaleMgr->GetDefLocale(); | 810 pLocale = m_pLocaleMgr->GetDefLocale(); |
| 811 } | 811 } |
| 812 return pLocale; | 812 return pLocale; |
| 813 } | 813 } |
| 814 static FX_BOOL FX_GetNumericDotIndex(const CFX_WideString& wsNum, | 814 static FX_BOOL FX_GetNumericDotIndex(const CFX_WideString& wsNum, |
| 815 const CFX_WideString& wsDotSymbol, | 815 const CFX_WideString& wsDotSymbol, |
| 816 int32_t& iDotIndex) { | 816 int32_t& iDotIndex) { |
| 817 int32_t ccf = 0; | 817 int32_t ccf = 0; |
| 818 int32_t iLenf = wsNum.GetLength(); | 818 int32_t iLenf = wsNum.GetLength(); |
| 819 const FX_WCHAR* pStr = (const FX_WCHAR*)wsNum; | 819 const FX_WCHAR* pStr = wsNum.c_str(); |
| 820 int32_t iLenDot = wsDotSymbol.GetLength(); | 820 int32_t iLenDot = wsDotSymbol.GetLength(); |
| 821 while (ccf < iLenf) { | 821 while (ccf < iLenf) { |
| 822 if (pStr[ccf] == '\'') { | 822 if (pStr[ccf] == '\'') { |
| 823 FX_GetLiteralText(pStr, ccf, iLenf); | 823 FX_GetLiteralText(pStr, ccf, iLenf); |
| 824 } else if (ccf + iLenDot <= iLenf && | 824 } else if (ccf + iLenDot <= iLenf && |
| 825 !FXSYS_wcsncmp(pStr + ccf, (const FX_WCHAR*)wsDotSymbol, | 825 !FXSYS_wcsncmp(pStr + ccf, wsDotSymbol.c_str(), iLenDot)) { |
| 826 iLenDot)) { | |
| 827 iDotIndex = ccf; | 826 iDotIndex = ccf; |
| 828 return TRUE; | 827 return TRUE; |
| 829 } | 828 } |
| 830 ccf++; | 829 ccf++; |
| 831 } | 830 } |
| 832 iDotIndex = wsNum.Find('.'); | 831 iDotIndex = wsNum.Find('.'); |
| 833 if (iDotIndex < 0) { | 832 if (iDotIndex < 0) { |
| 834 iDotIndex = iLenf; | 833 iDotIndex = iLenf; |
| 835 return FALSE; | 834 return FALSE; |
| 836 } | 835 } |
| 837 return TRUE; | 836 return TRUE; |
| 838 } | 837 } |
| 839 FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText, | 838 FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText, |
| 840 const CFX_WideString& wsPattern, | 839 const CFX_WideString& wsPattern, |
| 841 CFX_WideString& wsValue) { | 840 CFX_WideString& wsValue) { |
| 842 wsValue.Empty(); | 841 wsValue.Empty(); |
| 843 if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) { | 842 if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) { |
| 844 return FALSE; | 843 return FALSE; |
| 845 } | 844 } |
| 846 CFX_WideString wsTextFormat; | 845 CFX_WideString wsTextFormat; |
| 847 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); | 846 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); |
| 848 if (wsTextFormat.IsEmpty()) { | 847 if (wsTextFormat.IsEmpty()) { |
| 849 return FALSE; | 848 return FALSE; |
| 850 } | 849 } |
| 851 int32_t iText = 0, iPattern = 0; | 850 int32_t iText = 0, iPattern = 0; |
| 852 const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; | 851 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
| 853 int32_t iLenText = wsSrcText.GetLength(); | 852 int32_t iLenText = wsSrcText.GetLength(); |
| 854 const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; | 853 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 855 int32_t iLenPattern = wsTextFormat.GetLength(); | 854 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 856 while (iPattern < iLenPattern && iText < iLenText) { | 855 while (iPattern < iLenPattern && iText < iLenText) { |
| 857 switch (pStrPattern[iPattern]) { | 856 switch (pStrPattern[iPattern]) { |
| 858 case '\'': { | 857 case '\'': { |
| 859 CFX_WideString wsLiteral = | 858 CFX_WideString wsLiteral = |
| 860 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 859 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 861 int32_t iLiteralLen = wsLiteral.GetLength(); | 860 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 862 if (iText + iLiteralLen > iLenText || | 861 if (iText + iLiteralLen > iLenText || |
| 863 FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, | 862 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { |
| 864 iLiteralLen)) { | |
| 865 wsValue = wsSrcText; | 863 wsValue = wsSrcText; |
| 866 return FALSE; | 864 return FALSE; |
| 867 } | 865 } |
| 868 iText += iLiteralLen; | 866 iText += iLiteralLen; |
| 869 iPattern++; | 867 iPattern++; |
| 870 break; | 868 break; |
| 871 } | 869 } |
| 872 case 'A': | 870 case 'A': |
| 873 if (FX_IsAlpha(pStrText[iText])) { | 871 if (FX_IsAlpha(pStrText[iText])) { |
| 874 wsValue += pStrText[iText]; | 872 wsValue += pStrText[iText]; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 int32_t iExponent = 0; | 924 int32_t iExponent = 0; |
| 927 CFX_WideString wsDotSymbol; | 925 CFX_WideString wsDotSymbol; |
| 928 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); | 926 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); |
| 929 CFX_WideString wsGroupSymbol; | 927 CFX_WideString wsGroupSymbol; |
| 930 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | 928 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); |
| 931 int32_t iGroupLen = wsGroupSymbol.GetLength(); | 929 int32_t iGroupLen = wsGroupSymbol.GetLength(); |
| 932 CFX_WideString wsMinus; | 930 CFX_WideString wsMinus; |
| 933 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); | 931 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); |
| 934 int32_t iMinusLen = wsMinus.GetLength(); | 932 int32_t iMinusLen = wsMinus.GetLength(); |
| 935 int cc = 0, ccf = 0; | 933 int cc = 0, ccf = 0; |
| 936 const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; | 934 const FX_WCHAR* str = wsSrcNum.c_str(); |
| 937 int len = wsSrcNum.GetLength(); | 935 int len = wsSrcNum.GetLength(); |
| 938 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; | 936 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 939 int lenf = wsNumFormat.GetLength(); | 937 int lenf = wsNumFormat.GetLength(); |
| 940 double dbRetValue = 0; | 938 double dbRetValue = 0; |
| 941 double coeff = 1; | 939 double coeff = 1; |
| 942 FX_BOOL bHavePercentSymbol = FALSE; | 940 FX_BOOL bHavePercentSymbol = FALSE; |
| 943 FX_BOOL bNeg = FALSE; | 941 FX_BOOL bNeg = FALSE; |
| 944 FX_BOOL bReverseParse = FALSE; | 942 FX_BOOL bReverseParse = FALSE; |
| 945 int32_t dot_index = 0; | 943 int32_t dot_index = 0; |
| 946 if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && | 944 if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && |
| 947 (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { | 945 (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { |
| 948 bReverseParse = TRUE; | 946 bReverseParse = TRUE; |
| 949 } | 947 } |
| 950 bReverseParse = FALSE; | 948 bReverseParse = FALSE; |
| 951 if (bReverseParse) { | 949 if (bReverseParse) { |
| 952 ccf = lenf - 1; | 950 ccf = lenf - 1; |
| 953 cc = len - 1; | 951 cc = len - 1; |
| 954 while (ccf > dot_index_f && cc >= 0) { | 952 while (ccf > dot_index_f && cc >= 0) { |
| 955 switch (strf[ccf]) { | 953 switch (strf[ccf]) { |
| 956 case '\'': { | 954 case '\'': { |
| 957 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); | 955 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); |
| 958 int32_t iLiteralLen = wsLiteral.GetLength(); | 956 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 959 cc -= iLiteralLen - 1; | 957 cc -= iLiteralLen - 1; |
| 960 if (cc < 0 || FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, | 958 if (cc < 0 || |
| 961 iLiteralLen)) { | 959 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 962 return FALSE; | 960 return FALSE; |
| 963 } | 961 } |
| 964 cc--; | 962 cc--; |
| 965 ccf--; | 963 ccf--; |
| 966 break; | 964 break; |
| 967 } | 965 } |
| 968 case '9': | 966 case '9': |
| 969 if (!FX_IsDigit(str[cc])) { | 967 if (!FX_IsDigit(str[cc])) { |
| 970 return FALSE; | 968 return FALSE; |
| 971 } | 969 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 988 coeff *= 0.1; | 986 coeff *= 0.1; |
| 989 } | 987 } |
| 990 cc--; | 988 cc--; |
| 991 ccf--; | 989 ccf--; |
| 992 break; | 990 break; |
| 993 case 'S': | 991 case 'S': |
| 994 if (str[cc] == '+' || str[cc] == ' ') { | 992 if (str[cc] == '+' || str[cc] == ' ') { |
| 995 cc--; | 993 cc--; |
| 996 } else { | 994 } else { |
| 997 cc -= iMinusLen - 1; | 995 cc -= iMinusLen - 1; |
| 998 if (cc < 0 || | 996 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 999 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | |
| 1000 return FALSE; | 997 return FALSE; |
| 1001 } | 998 } |
| 1002 cc--; | 999 cc--; |
| 1003 bNeg = TRUE; | 1000 bNeg = TRUE; |
| 1004 } | 1001 } |
| 1005 ccf--; | 1002 ccf--; |
| 1006 break; | 1003 break; |
| 1007 case 's': | 1004 case 's': |
| 1008 if (str[cc] == '+') { | 1005 if (str[cc] == '+') { |
| 1009 cc--; | 1006 cc--; |
| 1010 } else { | 1007 } else { |
| 1011 cc -= iMinusLen - 1; | 1008 cc -= iMinusLen - 1; |
| 1012 if (cc < 0 || | 1009 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1013 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | |
| 1014 return FALSE; | 1010 return FALSE; |
| 1015 } | 1011 } |
| 1016 cc--; | 1012 cc--; |
| 1017 bNeg = TRUE; | 1013 bNeg = TRUE; |
| 1018 } | 1014 } |
| 1019 ccf--; | 1015 ccf--; |
| 1020 break; | 1016 break; |
| 1021 case 'E': { | 1017 case 'E': { |
| 1022 if (cc >= dot_index) { | 1018 if (cc >= dot_index) { |
| 1023 return FALSE; | 1019 return FALSE; |
| 1024 } | 1020 } |
| 1025 FX_BOOL bExpSign = FALSE; | 1021 FX_BOOL bExpSign = FALSE; |
| 1026 while (cc >= 0) { | 1022 while (cc >= 0) { |
| 1027 if (str[cc] == 'E' || str[cc] == 'e') { | 1023 if (str[cc] == 'E' || str[cc] == 'e') { |
| 1028 break; | 1024 break; |
| 1029 } | 1025 } |
| 1030 if (FX_IsDigit(str[cc])) { | 1026 if (FX_IsDigit(str[cc])) { |
| 1031 iExponent = iExponent + (str[cc] - '0') * 10; | 1027 iExponent = iExponent + (str[cc] - '0') * 10; |
| 1032 cc--; | 1028 cc--; |
| 1033 continue; | 1029 continue; |
| 1034 } else if (str[cc] == '+') { | 1030 } else if (str[cc] == '+') { |
| 1035 cc--; | 1031 cc--; |
| 1036 continue; | 1032 continue; |
| 1037 } else if (cc - iMinusLen + 1 > 0 && | 1033 } else if (cc - iMinusLen + 1 > 0 && |
| 1038 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), | 1034 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), |
| 1039 (const FX_WCHAR*)wsMinus, iMinusLen)) { | 1035 wsMinus.c_str(), iMinusLen)) { |
| 1040 bExpSign = TRUE; | 1036 bExpSign = TRUE; |
| 1041 cc -= iMinusLen; | 1037 cc -= iMinusLen; |
| 1042 } else { | 1038 } else { |
| 1043 return FALSE; | 1039 return FALSE; |
| 1044 } | 1040 } |
| 1045 } | 1041 } |
| 1046 cc--; | 1042 cc--; |
| 1047 iExponent = bExpSign ? -iExponent : iExponent; | 1043 iExponent = bExpSign ? -iExponent : iExponent; |
| 1048 ccf--; | 1044 ccf--; |
| 1049 } break; | 1045 } break; |
| 1050 case '$': { | 1046 case '$': { |
| 1051 CFX_WideString wsSymbol; | 1047 CFX_WideString wsSymbol; |
| 1052 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, | 1048 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, |
| 1053 wsSymbol); | 1049 wsSymbol); |
| 1054 int32_t iSymbolLen = wsSymbol.GetLength(); | 1050 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 1055 cc -= iSymbolLen - 1; | 1051 cc -= iSymbolLen - 1; |
| 1056 if (cc < 0 || | 1052 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 1057 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { | |
| 1058 return FALSE; | 1053 return FALSE; |
| 1059 } | 1054 } |
| 1060 cc--; | 1055 cc--; |
| 1061 ccf--; | 1056 ccf--; |
| 1062 } break; | 1057 } break; |
| 1063 case 'r': | 1058 case 'r': |
| 1064 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { | 1059 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { |
| 1065 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 1060 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 1066 bNeg = TRUE; | 1061 bNeg = TRUE; |
| 1067 cc -= 2; | 1062 cc -= 2; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 case '.': | 1106 case '.': |
| 1112 case 'V': | 1107 case 'V': |
| 1113 case 'v': | 1108 case 'v': |
| 1114 return FALSE; | 1109 return FALSE; |
| 1115 case '%': { | 1110 case '%': { |
| 1116 CFX_WideString wsSymbol; | 1111 CFX_WideString wsSymbol; |
| 1117 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 1112 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 1118 int32_t iSysmbolLen = wsSymbol.GetLength(); | 1113 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 1119 cc -= iSysmbolLen - 1; | 1114 cc -= iSysmbolLen - 1; |
| 1120 if (cc < 0 || | 1115 if (cc < 0 || |
| 1121 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSysmbolLen)) { | 1116 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 1122 return FALSE; | 1117 return FALSE; |
| 1123 } | 1118 } |
| 1124 cc--; | 1119 cc--; |
| 1125 ccf--; | 1120 ccf--; |
| 1126 bHavePercentSymbol = TRUE; | 1121 bHavePercentSymbol = TRUE; |
| 1127 } break; | 1122 } break; |
| 1128 case '8': | 1123 case '8': |
| 1129 while (ccf < lenf && strf[ccf] == '8') { | 1124 while (ccf < lenf && strf[ccf] == '8') { |
| 1130 ccf++; | 1125 ccf++; |
| 1131 } | 1126 } |
| 1132 while (cc < len && FX_IsDigit(str[cc])) { | 1127 while (cc < len && FX_IsDigit(str[cc])) { |
| 1133 dbRetValue = (str[cc] - '0') * coeff + dbRetValue; | 1128 dbRetValue = (str[cc] - '0') * coeff + dbRetValue; |
| 1134 coeff *= 0.1; | 1129 coeff *= 0.1; |
| 1135 cc++; | 1130 cc++; |
| 1136 } | 1131 } |
| 1137 break; | 1132 break; |
| 1138 case ',': { | 1133 case ',': { |
| 1139 if (cc >= 0) { | 1134 if (cc >= 0) { |
| 1140 cc -= iGroupLen - 1; | 1135 cc -= iGroupLen - 1; |
| 1141 if (cc >= 0 && | 1136 if (cc >= 0 && |
| 1142 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, | 1137 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == |
| 1143 iGroupLen) == 0) { | 1138 0) { |
| 1144 cc--; | 1139 cc--; |
| 1145 } else { | 1140 } else { |
| 1146 cc += iGroupLen - 1; | 1141 cc += iGroupLen - 1; |
| 1147 } | 1142 } |
| 1148 } | 1143 } |
| 1149 ccf--; | 1144 ccf--; |
| 1150 } break; | 1145 } break; |
| 1151 case '(': | 1146 case '(': |
| 1152 if (str[cc] == L'(') { | 1147 if (str[cc] == L'(') { |
| 1153 bNeg = TRUE; | 1148 bNeg = TRUE; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1178 } | 1173 } |
| 1179 ccf = dot_index_f - 1; | 1174 ccf = dot_index_f - 1; |
| 1180 cc = dot_index - 1; | 1175 cc = dot_index - 1; |
| 1181 coeff = 1; | 1176 coeff = 1; |
| 1182 while (ccf >= 0 && cc >= 0) { | 1177 while (ccf >= 0 && cc >= 0) { |
| 1183 switch (strf[ccf]) { | 1178 switch (strf[ccf]) { |
| 1184 case '\'': { | 1179 case '\'': { |
| 1185 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); | 1180 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); |
| 1186 int32_t iLiteralLen = wsLiteral.GetLength(); | 1181 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 1187 cc -= iLiteralLen - 1; | 1182 cc -= iLiteralLen - 1; |
| 1188 if (cc < 0 || | 1183 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 1189 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, iLiteralLen)) { | |
| 1190 return FALSE; | 1184 return FALSE; |
| 1191 } | 1185 } |
| 1192 cc--; | 1186 cc--; |
| 1193 ccf--; | 1187 ccf--; |
| 1194 break; | 1188 break; |
| 1195 } | 1189 } |
| 1196 case '9': | 1190 case '9': |
| 1197 if (!FX_IsDigit(str[cc])) { | 1191 if (!FX_IsDigit(str[cc])) { |
| 1198 return FALSE; | 1192 return FALSE; |
| 1199 } | 1193 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1220 } else { | 1214 } else { |
| 1221 cc--; | 1215 cc--; |
| 1222 } | 1216 } |
| 1223 ccf--; | 1217 ccf--; |
| 1224 break; | 1218 break; |
| 1225 case 'S': | 1219 case 'S': |
| 1226 if (str[cc] == '+' || str[cc] == ' ') { | 1220 if (str[cc] == '+' || str[cc] == ' ') { |
| 1227 cc--; | 1221 cc--; |
| 1228 } else { | 1222 } else { |
| 1229 cc -= iMinusLen - 1; | 1223 cc -= iMinusLen - 1; |
| 1230 if (cc < 0 || | 1224 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1231 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | |
| 1232 return FALSE; | 1225 return FALSE; |
| 1233 } | 1226 } |
| 1234 cc--; | 1227 cc--; |
| 1235 bNeg = TRUE; | 1228 bNeg = TRUE; |
| 1236 } | 1229 } |
| 1237 ccf--; | 1230 ccf--; |
| 1238 break; | 1231 break; |
| 1239 case 's': | 1232 case 's': |
| 1240 if (str[cc] == '+') { | 1233 if (str[cc] == '+') { |
| 1241 cc--; | 1234 cc--; |
| 1242 } else { | 1235 } else { |
| 1243 cc -= iMinusLen - 1; | 1236 cc -= iMinusLen - 1; |
| 1244 if (cc < 0 || | 1237 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1245 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | |
| 1246 return FALSE; | 1238 return FALSE; |
| 1247 } | 1239 } |
| 1248 cc--; | 1240 cc--; |
| 1249 bNeg = TRUE; | 1241 bNeg = TRUE; |
| 1250 } | 1242 } |
| 1251 ccf--; | 1243 ccf--; |
| 1252 break; | 1244 break; |
| 1253 case 'E': { | 1245 case 'E': { |
| 1254 if (cc >= dot_index) { | 1246 if (cc >= dot_index) { |
| 1255 return FALSE; | 1247 return FALSE; |
| 1256 } | 1248 } |
| 1257 FX_BOOL bExpSign = FALSE; | 1249 FX_BOOL bExpSign = FALSE; |
| 1258 while (cc >= 0) { | 1250 while (cc >= 0) { |
| 1259 if (str[cc] == 'E' || str[cc] == 'e') { | 1251 if (str[cc] == 'E' || str[cc] == 'e') { |
| 1260 break; | 1252 break; |
| 1261 } | 1253 } |
| 1262 if (FX_IsDigit(str[cc])) { | 1254 if (FX_IsDigit(str[cc])) { |
| 1263 iExponent = iExponent + (str[cc] - '0') * 10; | 1255 iExponent = iExponent + (str[cc] - '0') * 10; |
| 1264 cc--; | 1256 cc--; |
| 1265 continue; | 1257 continue; |
| 1266 } else if (str[cc] == '+') { | 1258 } else if (str[cc] == '+') { |
| 1267 cc--; | 1259 cc--; |
| 1268 continue; | 1260 continue; |
| 1269 } else if (cc - iMinusLen + 1 > 0 && | 1261 } else if (cc - iMinusLen + 1 > 0 && |
| 1270 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), | 1262 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), wsMinus.c_str(), |
| 1271 (const FX_WCHAR*)wsMinus, iMinusLen)) { | 1263 iMinusLen)) { |
| 1272 bExpSign = TRUE; | 1264 bExpSign = TRUE; |
| 1273 cc -= iMinusLen; | 1265 cc -= iMinusLen; |
| 1274 } else { | 1266 } else { |
| 1275 return FALSE; | 1267 return FALSE; |
| 1276 } | 1268 } |
| 1277 } | 1269 } |
| 1278 cc--; | 1270 cc--; |
| 1279 iExponent = bExpSign ? -iExponent : iExponent; | 1271 iExponent = bExpSign ? -iExponent : iExponent; |
| 1280 ccf--; | 1272 ccf--; |
| 1281 } break; | 1273 } break; |
| 1282 case '$': { | 1274 case '$': { |
| 1283 CFX_WideString wsSymbol; | 1275 CFX_WideString wsSymbol; |
| 1284 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); | 1276 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); |
| 1285 int32_t iSymbolLen = wsSymbol.GetLength(); | 1277 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 1286 cc -= iSymbolLen - 1; | 1278 cc -= iSymbolLen - 1; |
| 1287 if (cc < 0 || | 1279 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 1288 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { | |
| 1289 return FALSE; | 1280 return FALSE; |
| 1290 } | 1281 } |
| 1291 cc--; | 1282 cc--; |
| 1292 ccf--; | 1283 ccf--; |
| 1293 } break; | 1284 } break; |
| 1294 case 'r': | 1285 case 'r': |
| 1295 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { | 1286 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { |
| 1296 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 1287 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 1297 bNeg = TRUE; | 1288 bNeg = TRUE; |
| 1298 cc -= 2; | 1289 cc -= 2; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 break; | 1332 break; |
| 1342 case '.': | 1333 case '.': |
| 1343 case 'V': | 1334 case 'V': |
| 1344 case 'v': | 1335 case 'v': |
| 1345 return FALSE; | 1336 return FALSE; |
| 1346 case '%': { | 1337 case '%': { |
| 1347 CFX_WideString wsSymbol; | 1338 CFX_WideString wsSymbol; |
| 1348 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 1339 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 1349 int32_t iSysmbolLen = wsSymbol.GetLength(); | 1340 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 1350 cc -= iSysmbolLen - 1; | 1341 cc -= iSysmbolLen - 1; |
| 1351 if (cc < 0 || | 1342 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 1352 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSysmbolLen)) { | |
| 1353 return FALSE; | 1343 return FALSE; |
| 1354 } | 1344 } |
| 1355 cc--; | 1345 cc--; |
| 1356 ccf--; | 1346 ccf--; |
| 1357 bHavePercentSymbol = TRUE; | 1347 bHavePercentSymbol = TRUE; |
| 1358 } break; | 1348 } break; |
| 1359 case '8': | 1349 case '8': |
| 1360 return FALSE; | 1350 return FALSE; |
| 1361 case ',': { | 1351 case ',': { |
| 1362 if (cc >= 0) { | 1352 if (cc >= 0) { |
| 1363 cc -= iGroupLen - 1; | 1353 cc -= iGroupLen - 1; |
| 1364 if (cc >= 0 && | 1354 if (cc >= 0 && |
| 1365 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, | 1355 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { |
| 1366 iGroupLen) == 0) { | |
| 1367 cc--; | 1356 cc--; |
| 1368 } else { | 1357 } else { |
| 1369 cc += iGroupLen - 1; | 1358 cc += iGroupLen - 1; |
| 1370 } | 1359 } |
| 1371 } | 1360 } |
| 1372 ccf--; | 1361 ccf--; |
| 1373 } break; | 1362 } break; |
| 1374 case '(': | 1363 case '(': |
| 1375 if (str[cc] == L'(') { | 1364 if (str[cc] == L'(') { |
| 1376 bNeg = TRUE; | 1365 bNeg = TRUE; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1403 if (!bReverseParse) { | 1392 if (!bReverseParse) { |
| 1404 ccf = dot_index_f + 1; | 1393 ccf = dot_index_f + 1; |
| 1405 cc = (dot_index == len) ? len : dot_index + 1; | 1394 cc = (dot_index == len) ? len : dot_index + 1; |
| 1406 coeff = 0.1; | 1395 coeff = 0.1; |
| 1407 while (cc < len && ccf < lenf) { | 1396 while (cc < len && ccf < lenf) { |
| 1408 switch (strf[ccf]) { | 1397 switch (strf[ccf]) { |
| 1409 case '\'': { | 1398 case '\'': { |
| 1410 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 1399 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
| 1411 int32_t iLiteralLen = wsLiteral.GetLength(); | 1400 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 1412 if (cc + iLiteralLen > len || | 1401 if (cc + iLiteralLen > len || |
| 1413 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, | 1402 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 1414 iLiteralLen)) { | |
| 1415 return FALSE; | 1403 return FALSE; |
| 1416 } | 1404 } |
| 1417 cc += iLiteralLen; | 1405 cc += iLiteralLen; |
| 1418 ccf++; | 1406 ccf++; |
| 1419 break; | 1407 break; |
| 1420 } | 1408 } |
| 1421 case '9': | 1409 case '9': |
| 1422 if (!FX_IsDigit(str[cc])) { | 1410 if (!FX_IsDigit(str[cc])) { |
| 1423 return FALSE; | 1411 return FALSE; |
| 1424 } | 1412 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1447 } else { | 1435 } else { |
| 1448 cc++; | 1436 cc++; |
| 1449 } | 1437 } |
| 1450 ccf++; | 1438 ccf++; |
| 1451 break; | 1439 break; |
| 1452 case 'S': | 1440 case 'S': |
| 1453 if (str[cc] == '+' || str[cc] == ' ') { | 1441 if (str[cc] == '+' || str[cc] == ' ') { |
| 1454 cc++; | 1442 cc++; |
| 1455 } else { | 1443 } else { |
| 1456 if (cc + iMinusLen > len || | 1444 if (cc + iMinusLen > len || |
| 1457 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | 1445 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1458 return FALSE; | 1446 return FALSE; |
| 1459 } | 1447 } |
| 1460 bNeg = TRUE; | 1448 bNeg = TRUE; |
| 1461 cc += iMinusLen; | 1449 cc += iMinusLen; |
| 1462 } | 1450 } |
| 1463 ccf++; | 1451 ccf++; |
| 1464 break; | 1452 break; |
| 1465 case 's': | 1453 case 's': |
| 1466 if (str[cc] == '+') { | 1454 if (str[cc] == '+') { |
| 1467 cc++; | 1455 cc++; |
| 1468 } else { | 1456 } else { |
| 1469 if (cc + iMinusLen > len || | 1457 if (cc + iMinusLen > len || |
| 1470 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | 1458 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1471 return FALSE; | 1459 return FALSE; |
| 1472 } | 1460 } |
| 1473 bNeg = TRUE; | 1461 bNeg = TRUE; |
| 1474 cc += iMinusLen; | 1462 cc += iMinusLen; |
| 1475 } | 1463 } |
| 1476 ccf++; | 1464 ccf++; |
| 1477 break; | 1465 break; |
| 1478 case 'E': { | 1466 case 'E': { |
| 1479 if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { | 1467 if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { |
| 1480 return FALSE; | 1468 return FALSE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1498 } | 1486 } |
| 1499 iExponent = bExpSign ? -iExponent : iExponent; | 1487 iExponent = bExpSign ? -iExponent : iExponent; |
| 1500 ccf++; | 1488 ccf++; |
| 1501 } break; | 1489 } break; |
| 1502 case '$': { | 1490 case '$': { |
| 1503 CFX_WideString wsSymbol; | 1491 CFX_WideString wsSymbol; |
| 1504 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, | 1492 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, |
| 1505 wsSymbol); | 1493 wsSymbol); |
| 1506 int32_t iSymbolLen = wsSymbol.GetLength(); | 1494 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 1507 if (cc + iSymbolLen > len || | 1495 if (cc + iSymbolLen > len || |
| 1508 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { | 1496 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 1509 return FALSE; | 1497 return FALSE; |
| 1510 } | 1498 } |
| 1511 cc += iSymbolLen; | 1499 cc += iSymbolLen; |
| 1512 ccf++; | 1500 ccf++; |
| 1513 } break; | 1501 } break; |
| 1514 case 'c': | 1502 case 'c': |
| 1515 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { | 1503 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { |
| 1516 if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { | 1504 if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { |
| 1517 bNeg = TRUE; | 1505 bNeg = TRUE; |
| 1518 cc += 2; | 1506 cc += 2; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 break; | 1541 break; |
| 1554 case '.': | 1542 case '.': |
| 1555 case 'V': | 1543 case 'V': |
| 1556 case 'v': | 1544 case 'v': |
| 1557 return FALSE; | 1545 return FALSE; |
| 1558 case '%': { | 1546 case '%': { |
| 1559 CFX_WideString wsSymbol; | 1547 CFX_WideString wsSymbol; |
| 1560 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 1548 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 1561 int32_t iSysmbolLen = wsSymbol.GetLength(); | 1549 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 1562 if (cc + iSysmbolLen <= len && | 1550 if (cc + iSysmbolLen <= len && |
| 1563 !FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, | 1551 !FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 1564 iSysmbolLen)) { | |
| 1565 cc += iSysmbolLen; | 1552 cc += iSysmbolLen; |
| 1566 } | 1553 } |
| 1567 ccf++; | 1554 ccf++; |
| 1568 bHavePercentSymbol = TRUE; | 1555 bHavePercentSymbol = TRUE; |
| 1569 } break; | 1556 } break; |
| 1570 case '8': { | 1557 case '8': { |
| 1571 while (ccf < lenf && strf[ccf] == '8') { | 1558 while (ccf < lenf && strf[ccf] == '8') { |
| 1572 ccf++; | 1559 ccf++; |
| 1573 } | 1560 } |
| 1574 while (cc < len && FX_IsDigit(str[cc])) { | 1561 while (cc < len && FX_IsDigit(str[cc])) { |
| 1575 dbRetValue = (str[cc] - '0') * coeff + dbRetValue; | 1562 dbRetValue = (str[cc] - '0') * coeff + dbRetValue; |
| 1576 coeff *= 0.1; | 1563 coeff *= 0.1; |
| 1577 cc++; | 1564 cc++; |
| 1578 } | 1565 } |
| 1579 } break; | 1566 } break; |
| 1580 case ',': { | 1567 case ',': { |
| 1581 if (cc + iGroupLen <= len && | 1568 if (cc + iGroupLen <= len && |
| 1582 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, | 1569 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { |
| 1583 iGroupLen) == 0) { | |
| 1584 cc += iGroupLen; | 1570 cc += iGroupLen; |
| 1585 } | 1571 } |
| 1586 ccf++; | 1572 ccf++; |
| 1587 } break; | 1573 } break; |
| 1588 case '(': | 1574 case '(': |
| 1589 if (str[cc] == L'(') { | 1575 if (str[cc] == L'(') { |
| 1590 bNeg = TRUE; | 1576 bNeg = TRUE; |
| 1591 } else if (str[cc] != L' ') { | 1577 } else if (str[cc] != L' ') { |
| 1592 return FALSE; | 1578 return FALSE; |
| 1593 } | 1579 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1622 dbRetValue /= 100.0; | 1608 dbRetValue /= 100.0; |
| 1623 } | 1609 } |
| 1624 if (bNeg) { | 1610 if (bNeg) { |
| 1625 dbRetValue = -dbRetValue; | 1611 dbRetValue = -dbRetValue; |
| 1626 } | 1612 } |
| 1627 fValue = (FX_FLOAT)dbRetValue; | 1613 fValue = (FX_FLOAT)dbRetValue; |
| 1628 return TRUE; | 1614 return TRUE; |
| 1629 } | 1615 } |
| 1630 void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult) { | 1616 void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult) { |
| 1631 int32_t iCount = wsNum.GetLength(); | 1617 int32_t iCount = wsNum.GetLength(); |
| 1632 const FX_WCHAR* pStr = (const FX_WCHAR*)wsNum; | 1618 const FX_WCHAR* pStr = wsNum.c_str(); |
| 1633 FX_WCHAR* pDst = wsResult.GetBuffer(iCount); | 1619 FX_WCHAR* pDst = wsResult.GetBuffer(iCount); |
| 1634 int32_t nIndex = 0; | 1620 int32_t nIndex = 0; |
| 1635 FX_BOOL bMinus = FALSE; | 1621 FX_BOOL bMinus = FALSE; |
| 1636 int32_t i = 0; | 1622 int32_t i = 0; |
| 1637 for (i = 0; i < iCount; i++) { | 1623 for (i = 0; i < iCount; i++) { |
| 1638 FX_WCHAR wc = pStr[i]; | 1624 FX_WCHAR wc = pStr[i]; |
| 1639 if (wc == '.') { | 1625 if (wc == '.') { |
| 1640 break; | 1626 break; |
| 1641 } | 1627 } |
| 1642 if ((wc == L'0' || wc == L' ' || wc == '+') && nIndex == 0) { | 1628 if ((wc == L'0' || wc == L' ' || wc == '+') && nIndex == 0) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 int32_t iExponent = 0; | 1678 int32_t iExponent = 0; |
| 1693 CFX_WideString wsDotSymbol; | 1679 CFX_WideString wsDotSymbol; |
| 1694 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); | 1680 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); |
| 1695 CFX_WideString wsGroupSymbol; | 1681 CFX_WideString wsGroupSymbol; |
| 1696 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | 1682 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); |
| 1697 int32_t iGroupLen = wsGroupSymbol.GetLength(); | 1683 int32_t iGroupLen = wsGroupSymbol.GetLength(); |
| 1698 CFX_WideString wsMinus; | 1684 CFX_WideString wsMinus; |
| 1699 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); | 1685 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); |
| 1700 int32_t iMinusLen = wsMinus.GetLength(); | 1686 int32_t iMinusLen = wsMinus.GetLength(); |
| 1701 int cc = 0, ccf = 0; | 1687 int cc = 0, ccf = 0; |
| 1702 const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; | 1688 const FX_WCHAR* str = wsSrcNum.c_str(); |
| 1703 int len = wsSrcNum.GetLength(); | 1689 int len = wsSrcNum.GetLength(); |
| 1704 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; | 1690 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 1705 int lenf = wsNumFormat.GetLength(); | 1691 int lenf = wsNumFormat.GetLength(); |
| 1706 FX_BOOL bHavePercentSymbol = FALSE; | 1692 FX_BOOL bHavePercentSymbol = FALSE; |
| 1707 FX_BOOL bNeg = FALSE; | 1693 FX_BOOL bNeg = FALSE; |
| 1708 FX_BOOL bReverseParse = FALSE; | 1694 FX_BOOL bReverseParse = FALSE; |
| 1709 int32_t dot_index = 0; | 1695 int32_t dot_index = 0; |
| 1710 if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && | 1696 if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && |
| 1711 (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { | 1697 (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { |
| 1712 bReverseParse = TRUE; | 1698 bReverseParse = TRUE; |
| 1713 } | 1699 } |
| 1714 bReverseParse = FALSE; | 1700 bReverseParse = FALSE; |
| 1715 ccf = dot_index_f - 1; | 1701 ccf = dot_index_f - 1; |
| 1716 cc = dot_index - 1; | 1702 cc = dot_index - 1; |
| 1717 while (ccf >= 0 && cc >= 0) { | 1703 while (ccf >= 0 && cc >= 0) { |
| 1718 switch (strf[ccf]) { | 1704 switch (strf[ccf]) { |
| 1719 case '\'': { | 1705 case '\'': { |
| 1720 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); | 1706 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); |
| 1721 int32_t iLiteralLen = wsLiteral.GetLength(); | 1707 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 1722 cc -= iLiteralLen - 1; | 1708 cc -= iLiteralLen - 1; |
| 1723 if (cc < 0 || | 1709 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 1724 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, iLiteralLen)) { | |
| 1725 return FALSE; | 1710 return FALSE; |
| 1726 } | 1711 } |
| 1727 cc--; | 1712 cc--; |
| 1728 ccf--; | 1713 ccf--; |
| 1729 break; | 1714 break; |
| 1730 } | 1715 } |
| 1731 case '9': | 1716 case '9': |
| 1732 if (!FX_IsDigit(str[cc])) { | 1717 if (!FX_IsDigit(str[cc])) { |
| 1733 return FALSE; | 1718 return FALSE; |
| 1734 } | 1719 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1752 } else { | 1737 } else { |
| 1753 cc--; | 1738 cc--; |
| 1754 } | 1739 } |
| 1755 ccf--; | 1740 ccf--; |
| 1756 break; | 1741 break; |
| 1757 case 'S': | 1742 case 'S': |
| 1758 if (str[cc] == '+' || str[cc] == ' ') { | 1743 if (str[cc] == '+' || str[cc] == ' ') { |
| 1759 cc--; | 1744 cc--; |
| 1760 } else { | 1745 } else { |
| 1761 cc -= iMinusLen - 1; | 1746 cc -= iMinusLen - 1; |
| 1762 if (cc < 0 || | 1747 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1763 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | |
| 1764 return FALSE; | 1748 return FALSE; |
| 1765 } | 1749 } |
| 1766 cc--; | 1750 cc--; |
| 1767 bNeg = TRUE; | 1751 bNeg = TRUE; |
| 1768 } | 1752 } |
| 1769 ccf--; | 1753 ccf--; |
| 1770 break; | 1754 break; |
| 1771 case 's': | 1755 case 's': |
| 1772 if (str[cc] == '+') { | 1756 if (str[cc] == '+') { |
| 1773 cc--; | 1757 cc--; |
| 1774 } else { | 1758 } else { |
| 1775 cc -= iMinusLen - 1; | 1759 cc -= iMinusLen - 1; |
| 1776 if (cc < 0 || | 1760 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1777 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | |
| 1778 return FALSE; | 1761 return FALSE; |
| 1779 } | 1762 } |
| 1780 cc--; | 1763 cc--; |
| 1781 bNeg = TRUE; | 1764 bNeg = TRUE; |
| 1782 } | 1765 } |
| 1783 ccf--; | 1766 ccf--; |
| 1784 break; | 1767 break; |
| 1785 case 'E': { | 1768 case 'E': { |
| 1786 if (cc >= dot_index) { | 1769 if (cc >= dot_index) { |
| 1787 return FALSE; | 1770 return FALSE; |
| 1788 } | 1771 } |
| 1789 FX_BOOL bExpSign = FALSE; | 1772 FX_BOOL bExpSign = FALSE; |
| 1790 while (cc >= 0) { | 1773 while (cc >= 0) { |
| 1791 if (str[cc] == 'E' || str[cc] == 'e') { | 1774 if (str[cc] == 'E' || str[cc] == 'e') { |
| 1792 break; | 1775 break; |
| 1793 } | 1776 } |
| 1794 if (FX_IsDigit(str[cc])) { | 1777 if (FX_IsDigit(str[cc])) { |
| 1795 iExponent = iExponent + (str[cc] - '0') * 10; | 1778 iExponent = iExponent + (str[cc] - '0') * 10; |
| 1796 cc--; | 1779 cc--; |
| 1797 continue; | 1780 continue; |
| 1798 } else if (str[cc] == '+') { | 1781 } else if (str[cc] == '+') { |
| 1799 cc--; | 1782 cc--; |
| 1800 continue; | 1783 continue; |
| 1801 } else if (cc - iMinusLen + 1 > 0 && | 1784 } else if (cc - iMinusLen + 1 > 0 && |
| 1802 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), | 1785 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), wsMinus.c_str(), |
| 1803 (const FX_WCHAR*)wsMinus, iMinusLen)) { | 1786 iMinusLen)) { |
| 1804 bExpSign = TRUE; | 1787 bExpSign = TRUE; |
| 1805 cc -= iMinusLen; | 1788 cc -= iMinusLen; |
| 1806 } else { | 1789 } else { |
| 1807 return FALSE; | 1790 return FALSE; |
| 1808 } | 1791 } |
| 1809 } | 1792 } |
| 1810 cc--; | 1793 cc--; |
| 1811 iExponent = bExpSign ? -iExponent : iExponent; | 1794 iExponent = bExpSign ? -iExponent : iExponent; |
| 1812 ccf--; | 1795 ccf--; |
| 1813 } break; | 1796 } break; |
| 1814 case '$': { | 1797 case '$': { |
| 1815 CFX_WideString wsSymbol; | 1798 CFX_WideString wsSymbol; |
| 1816 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); | 1799 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); |
| 1817 int32_t iSymbolLen = wsSymbol.GetLength(); | 1800 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 1818 cc -= iSymbolLen - 1; | 1801 cc -= iSymbolLen - 1; |
| 1819 if (cc < 0 || | 1802 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 1820 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { | |
| 1821 return FALSE; | 1803 return FALSE; |
| 1822 } | 1804 } |
| 1823 cc--; | 1805 cc--; |
| 1824 ccf--; | 1806 ccf--; |
| 1825 } break; | 1807 } break; |
| 1826 case 'r': | 1808 case 'r': |
| 1827 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { | 1809 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { |
| 1828 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 1810 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 1829 bNeg = TRUE; | 1811 bNeg = TRUE; |
| 1830 cc -= 2; | 1812 cc -= 2; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 break; | 1855 break; |
| 1874 case '.': | 1856 case '.': |
| 1875 case 'V': | 1857 case 'V': |
| 1876 case 'v': | 1858 case 'v': |
| 1877 return FALSE; | 1859 return FALSE; |
| 1878 case '%': { | 1860 case '%': { |
| 1879 CFX_WideString wsSymbol; | 1861 CFX_WideString wsSymbol; |
| 1880 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 1862 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 1881 int32_t iSysmbolLen = wsSymbol.GetLength(); | 1863 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 1882 cc -= iSysmbolLen - 1; | 1864 cc -= iSysmbolLen - 1; |
| 1883 if (cc < 0 || | 1865 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 1884 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSysmbolLen)) { | |
| 1885 return FALSE; | 1866 return FALSE; |
| 1886 } | 1867 } |
| 1887 cc--; | 1868 cc--; |
| 1888 ccf--; | 1869 ccf--; |
| 1889 bHavePercentSymbol = TRUE; | 1870 bHavePercentSymbol = TRUE; |
| 1890 } break; | 1871 } break; |
| 1891 case '8': | 1872 case '8': |
| 1892 return FALSE; | 1873 return FALSE; |
| 1893 case ',': { | 1874 case ',': { |
| 1894 if (cc >= 0) { | 1875 if (cc >= 0) { |
| 1895 cc -= iGroupLen - 1; | 1876 cc -= iGroupLen - 1; |
| 1896 if (cc >= 0 && | 1877 if (cc >= 0 && |
| 1897 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, | 1878 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { |
| 1898 iGroupLen) == 0) { | |
| 1899 cc--; | 1879 cc--; |
| 1900 } else { | 1880 } else { |
| 1901 cc += iGroupLen - 1; | 1881 cc += iGroupLen - 1; |
| 1902 } | 1882 } |
| 1903 } | 1883 } |
| 1904 ccf--; | 1884 ccf--; |
| 1905 } break; | 1885 } break; |
| 1906 case '(': | 1886 case '(': |
| 1907 if (str[cc] == L'(') { | 1887 if (str[cc] == L'(') { |
| 1908 bNeg = TRUE; | 1888 bNeg = TRUE; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 } | 1923 } |
| 1944 if (!bReverseParse) { | 1924 if (!bReverseParse) { |
| 1945 ccf = dot_index_f + 1; | 1925 ccf = dot_index_f + 1; |
| 1946 cc = (dot_index == len) ? len : dot_index + 1; | 1926 cc = (dot_index == len) ? len : dot_index + 1; |
| 1947 while (cc < len && ccf < lenf) { | 1927 while (cc < len && ccf < lenf) { |
| 1948 switch (strf[ccf]) { | 1928 switch (strf[ccf]) { |
| 1949 case '\'': { | 1929 case '\'': { |
| 1950 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 1930 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
| 1951 int32_t iLiteralLen = wsLiteral.GetLength(); | 1931 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 1952 if (cc + iLiteralLen > len || | 1932 if (cc + iLiteralLen > len || |
| 1953 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, | 1933 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 1954 iLiteralLen)) { | |
| 1955 return FALSE; | 1934 return FALSE; |
| 1956 } | 1935 } |
| 1957 cc += iLiteralLen; | 1936 cc += iLiteralLen; |
| 1958 ccf++; | 1937 ccf++; |
| 1959 break; | 1938 break; |
| 1960 } | 1939 } |
| 1961 case '9': | 1940 case '9': |
| 1962 if (!FX_IsDigit(str[cc])) { | 1941 if (!FX_IsDigit(str[cc])) { |
| 1963 return FALSE; | 1942 return FALSE; |
| 1964 } | 1943 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1982 } else { | 1961 } else { |
| 1983 cc++; | 1962 cc++; |
| 1984 } | 1963 } |
| 1985 ccf++; | 1964 ccf++; |
| 1986 break; | 1965 break; |
| 1987 case 'S': | 1966 case 'S': |
| 1988 if (str[cc] == '+' || str[cc] == ' ') { | 1967 if (str[cc] == '+' || str[cc] == ' ') { |
| 1989 cc++; | 1968 cc++; |
| 1990 } else { | 1969 } else { |
| 1991 if (cc + iMinusLen > len || | 1970 if (cc + iMinusLen > len || |
| 1992 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | 1971 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1993 return FALSE; | 1972 return FALSE; |
| 1994 } | 1973 } |
| 1995 bNeg = TRUE; | 1974 bNeg = TRUE; |
| 1996 cc += iMinusLen; | 1975 cc += iMinusLen; |
| 1997 } | 1976 } |
| 1998 ccf++; | 1977 ccf++; |
| 1999 break; | 1978 break; |
| 2000 case 's': | 1979 case 's': |
| 2001 if (str[cc] == '+') { | 1980 if (str[cc] == '+') { |
| 2002 cc++; | 1981 cc++; |
| 2003 } else { | 1982 } else { |
| 2004 if (cc + iMinusLen > len || | 1983 if (cc + iMinusLen > len || |
| 2005 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { | 1984 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 2006 return FALSE; | 1985 return FALSE; |
| 2007 } | 1986 } |
| 2008 bNeg = TRUE; | 1987 bNeg = TRUE; |
| 2009 cc += iMinusLen; | 1988 cc += iMinusLen; |
| 2010 } | 1989 } |
| 2011 ccf++; | 1990 ccf++; |
| 2012 break; | 1991 break; |
| 2013 case 'E': { | 1992 case 'E': { |
| 2014 if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { | 1993 if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { |
| 2015 return FALSE; | 1994 return FALSE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2033 } | 2012 } |
| 2034 iExponent = bExpSign ? -iExponent : iExponent; | 2013 iExponent = bExpSign ? -iExponent : iExponent; |
| 2035 ccf++; | 2014 ccf++; |
| 2036 } break; | 2015 } break; |
| 2037 case '$': { | 2016 case '$': { |
| 2038 CFX_WideString wsSymbol; | 2017 CFX_WideString wsSymbol; |
| 2039 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, | 2018 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, |
| 2040 wsSymbol); | 2019 wsSymbol); |
| 2041 int32_t iSymbolLen = wsSymbol.GetLength(); | 2020 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 2042 if (cc + iSymbolLen > len || | 2021 if (cc + iSymbolLen > len || |
| 2043 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { | 2022 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 2044 return FALSE; | 2023 return FALSE; |
| 2045 } | 2024 } |
| 2046 cc += iSymbolLen; | 2025 cc += iSymbolLen; |
| 2047 ccf++; | 2026 ccf++; |
| 2048 } break; | 2027 } break; |
| 2049 case 'c': | 2028 case 'c': |
| 2050 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { | 2029 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { |
| 2051 if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { | 2030 if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { |
| 2052 bNeg = TRUE; | 2031 bNeg = TRUE; |
| 2053 cc += 2; | 2032 cc += 2; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 break; | 2067 break; |
| 2089 case '.': | 2068 case '.': |
| 2090 case 'V': | 2069 case 'V': |
| 2091 case 'v': | 2070 case 'v': |
| 2092 return FALSE; | 2071 return FALSE; |
| 2093 case '%': { | 2072 case '%': { |
| 2094 CFX_WideString wsSymbol; | 2073 CFX_WideString wsSymbol; |
| 2095 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 2074 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 2096 int32_t iSysmbolLen = wsSymbol.GetLength(); | 2075 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 2097 if (cc + iSysmbolLen <= len && | 2076 if (cc + iSysmbolLen <= len && |
| 2098 !FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, | 2077 !FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 2099 iSysmbolLen)) { | |
| 2100 cc += iSysmbolLen; | 2078 cc += iSysmbolLen; |
| 2101 } | 2079 } |
| 2102 ccf++; | 2080 ccf++; |
| 2103 bHavePercentSymbol = TRUE; | 2081 bHavePercentSymbol = TRUE; |
| 2104 } break; | 2082 } break; |
| 2105 case '8': { | 2083 case '8': { |
| 2106 while (ccf < lenf && strf[ccf] == '8') { | 2084 while (ccf < lenf && strf[ccf] == '8') { |
| 2107 ccf++; | 2085 ccf++; |
| 2108 } | 2086 } |
| 2109 while (cc < len && FX_IsDigit(str[cc])) { | 2087 while (cc < len && FX_IsDigit(str[cc])) { |
| 2110 wsValue += str[cc]; | 2088 wsValue += str[cc]; |
| 2111 cc++; | 2089 cc++; |
| 2112 } | 2090 } |
| 2113 } break; | 2091 } break; |
| 2114 case ',': { | 2092 case ',': { |
| 2115 if (cc + iGroupLen <= len && | 2093 if (cc + iGroupLen <= len && |
| 2116 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, | 2094 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { |
| 2117 iGroupLen) == 0) { | |
| 2118 cc += iGroupLen; | 2095 cc += iGroupLen; |
| 2119 } | 2096 } |
| 2120 ccf++; | 2097 ccf++; |
| 2121 } break; | 2098 } break; |
| 2122 case '(': | 2099 case '(': |
| 2123 if (str[cc] == L'(') { | 2100 if (str[cc] == L'(') { |
| 2124 bNeg = TRUE; | 2101 bNeg = TRUE; |
| 2125 } else if (str[cc] != L' ') { | 2102 } else if (str[cc] != L' ') { |
| 2126 return FALSE; | 2103 return FALSE; |
| 2127 } | 2104 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2167 FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( | 2144 FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( |
| 2168 const CFX_WideString& wsPattern, | 2145 const CFX_WideString& wsPattern, |
| 2169 IFX_Locale*& pLocale, | 2146 IFX_Locale*& pLocale, |
| 2170 CFX_WideString& wsDatePattern, | 2147 CFX_WideString& wsDatePattern, |
| 2171 CFX_WideString& wsTimePattern) { | 2148 CFX_WideString& wsTimePattern) { |
| 2172 pLocale = NULL; | 2149 pLocale = NULL; |
| 2173 CFX_WideString wsTempPattern; | 2150 CFX_WideString wsTempPattern; |
| 2174 FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; | 2151 FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; |
| 2175 int32_t ccf = 0; | 2152 int32_t ccf = 0; |
| 2176 int32_t iLenf = wsPattern.GetLength(); | 2153 int32_t iLenf = wsPattern.GetLength(); |
| 2177 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; | 2154 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 2178 int32_t iFindCategory = 0; | 2155 int32_t iFindCategory = 0; |
| 2179 FX_BOOL bBraceOpen = FALSE; | 2156 FX_BOOL bBraceOpen = FALSE; |
| 2180 while (ccf < iLenf) { | 2157 while (ccf < iLenf) { |
| 2181 if (pStr[ccf] == '\'') { | 2158 if (pStr[ccf] == '\'') { |
| 2182 int32_t iCurChar = ccf; | 2159 int32_t iCurChar = ccf; |
| 2183 FX_GetLiteralText(pStr, ccf, iLenf); | 2160 FX_GetLiteralText(pStr, ccf, iLenf); |
| 2184 wsTempPattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); | 2161 wsTempPattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); |
| 2185 } else if (!bBraceOpen && iFindCategory != 3 && | 2162 } else if (!bBraceOpen && iFindCategory != 3 && |
| 2186 FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { | 2163 FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { |
| 2187 CFX_WideString wsCategory(pStr[ccf]); | 2164 CFX_WideString wsCategory(pStr[ccf]); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 pLocale = GetPatternLocale(wsLCID.AsStringC()); | 2202 pLocale = GetPatternLocale(wsLCID.AsStringC()); |
| 2226 } else if (pStr[ccf] == '{') { | 2203 } else if (pStr[ccf] == '{') { |
| 2227 bBraceOpen = TRUE; | 2204 bBraceOpen = TRUE; |
| 2228 break; | 2205 break; |
| 2229 } else if (pStr[ccf] == '.') { | 2206 } else if (pStr[ccf] == '.') { |
| 2230 CFX_WideString wsSubCategory; | 2207 CFX_WideString wsSubCategory; |
| 2231 ccf++; | 2208 ccf++; |
| 2232 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 2209 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 2233 wsSubCategory += pStr[ccf++]; | 2210 wsSubCategory += pStr[ccf++]; |
| 2234 } | 2211 } |
| 2235 uint32_t dwSubHash = | 2212 uint32_t dwSubHash = FX_HashCode_String_GetW( |
| 2236 FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); | 2213 wsSubCategory.c_str(), wsSubCategory.GetLength()); |
| 2237 FX_LOCALEDATETIMESUBCATEGORY eSubCategory = | 2214 FX_LOCALEDATETIMESUBCATEGORY eSubCategory = |
| 2238 FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2215 FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2239 for (int32_t i = 0; i < g_iFXLocaleDateTimeSubCatCount; i++) { | 2216 for (int32_t i = 0; i < g_iFXLocaleDateTimeSubCatCount; i++) { |
| 2240 if (g_FXLocaleDateTimeSubCatData[i].uHash == dwSubHash) { | 2217 if (g_FXLocaleDateTimeSubCatData[i].uHash == dwSubHash) { |
| 2241 eSubCategory = | 2218 eSubCategory = |
| 2242 (FX_LOCALEDATETIMESUBCATEGORY)g_FXLocaleDateTimeSubCatData[i] | 2219 (FX_LOCALEDATETIMESUBCATEGORY)g_FXLocaleDateTimeSubCatData[i] |
| 2243 .eSubCategory; | 2220 .eSubCategory; |
| 2244 break; | 2221 break; |
| 2245 } | 2222 } |
| 2246 } | 2223 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2303 } | 2280 } |
| 2304 static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate, | 2281 static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate, |
| 2305 const CFX_WideString& wsDatePattern, | 2282 const CFX_WideString& wsDatePattern, |
| 2306 IFX_Locale* pLocale, | 2283 IFX_Locale* pLocale, |
| 2307 CFX_Unitime& datetime, | 2284 CFX_Unitime& datetime, |
| 2308 int32_t& cc) { | 2285 int32_t& cc) { |
| 2309 int32_t year = 1900; | 2286 int32_t year = 1900; |
| 2310 int32_t month = 1; | 2287 int32_t month = 1; |
| 2311 int32_t day = 1; | 2288 int32_t day = 1; |
| 2312 int32_t ccf = 0; | 2289 int32_t ccf = 0; |
| 2313 const FX_WCHAR* str = (const FX_WCHAR*)wsDate; | 2290 const FX_WCHAR* str = wsDate.c_str(); |
| 2314 int32_t len = wsDate.GetLength(); | 2291 int32_t len = wsDate.GetLength(); |
| 2315 const FX_WCHAR* strf = (const FX_WCHAR*)wsDatePattern; | 2292 const FX_WCHAR* strf = wsDatePattern.c_str(); |
| 2316 int32_t lenf = wsDatePattern.GetLength(); | 2293 int32_t lenf = wsDatePattern.GetLength(); |
| 2317 while (cc < len && ccf < lenf) { | 2294 while (cc < len && ccf < lenf) { |
| 2318 if (strf[ccf] == '\'') { | 2295 if (strf[ccf] == '\'') { |
| 2319 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 2296 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
| 2320 int32_t iLiteralLen = wsLiteral.GetLength(); | 2297 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 2321 if (cc + iLiteralLen > len || | 2298 if (cc + iLiteralLen > len || |
| 2322 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, iLiteralLen)) { | 2299 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 2323 return FALSE; | 2300 return FALSE; |
| 2324 } | 2301 } |
| 2325 cc += iLiteralLen; | 2302 cc += iLiteralLen; |
| 2326 ccf++; | 2303 ccf++; |
| 2327 continue; | 2304 continue; |
| 2328 } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { | 2305 } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { |
| 2329 if (strf[ccf] != str[cc]) { | 2306 if (strf[ccf] != str[cc]) { |
| 2330 return FALSE; | 2307 return FALSE; |
| 2331 } | 2308 } |
| 2332 cc++; | 2309 cc++; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2381 month = month * 10 + str[cc++] - '0'; | 2358 month = month * 10 + str[cc++] - '0'; |
| 2382 } | 2359 } |
| 2383 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { | 2360 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { |
| 2384 CFX_WideString wsMonthNameAbbr; | 2361 CFX_WideString wsMonthNameAbbr; |
| 2385 uint16_t i = 0; | 2362 uint16_t i = 0; |
| 2386 for (; i < 12; i++) { | 2363 for (; i < 12; i++) { |
| 2387 pLocale->GetMonthName(i, wsMonthNameAbbr, TRUE); | 2364 pLocale->GetMonthName(i, wsMonthNameAbbr, TRUE); |
| 2388 if (wsMonthNameAbbr.IsEmpty()) { | 2365 if (wsMonthNameAbbr.IsEmpty()) { |
| 2389 continue; | 2366 continue; |
| 2390 } | 2367 } |
| 2391 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthNameAbbr, str + cc, | 2368 if (!FXSYS_wcsncmp(wsMonthNameAbbr.c_str(), str + cc, |
| 2392 wsMonthNameAbbr.GetLength())) { | 2369 wsMonthNameAbbr.GetLength())) { |
| 2393 break; | 2370 break; |
| 2394 } | 2371 } |
| 2395 } | 2372 } |
| 2396 if (i < 12) { | 2373 if (i < 12) { |
| 2397 cc += wsMonthNameAbbr.GetLength(); | 2374 cc += wsMonthNameAbbr.GetLength(); |
| 2398 month = i + 1; | 2375 month = i + 1; |
| 2399 } | 2376 } |
| 2400 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { | 2377 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { |
| 2401 CFX_WideString wsMonthName; | 2378 CFX_WideString wsMonthName; |
| 2402 uint16_t i = 0; | 2379 uint16_t i = 0; |
| 2403 for (; i < 12; i++) { | 2380 for (; i < 12; i++) { |
| 2404 pLocale->GetMonthName(i, wsMonthName, FALSE); | 2381 pLocale->GetMonthName(i, wsMonthName, FALSE); |
| 2405 if (wsMonthName.IsEmpty()) { | 2382 if (wsMonthName.IsEmpty()) { |
| 2406 continue; | 2383 continue; |
| 2407 } | 2384 } |
| 2408 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthName, str + cc, | 2385 if (!FXSYS_wcsncmp(wsMonthName.c_str(), str + cc, |
| 2409 wsMonthName.GetLength())) { | 2386 wsMonthName.GetLength())) { |
| 2410 break; | 2387 break; |
| 2411 } | 2388 } |
| 2412 } | 2389 } |
| 2413 if (i < 12) { | 2390 if (i < 12) { |
| 2414 cc += wsMonthName.GetLength(); | 2391 cc += wsMonthName.GetLength(); |
| 2415 month = i + 1; | 2392 month = i + 1; |
| 2416 } | 2393 } |
| 2417 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { | 2394 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { |
| 2418 cc += 1; | 2395 cc += 1; |
| 2419 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { | 2396 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { |
| 2420 CFX_WideString wsDayNameAbbr; | 2397 CFX_WideString wsDayNameAbbr; |
| 2421 uint16_t i = 0; | 2398 uint16_t i = 0; |
| 2422 for (; i < 7; i++) { | 2399 for (; i < 7; i++) { |
| 2423 pLocale->GetDayName(i, wsDayNameAbbr, TRUE); | 2400 pLocale->GetDayName(i, wsDayNameAbbr, TRUE); |
| 2424 if (wsDayNameAbbr.IsEmpty()) { | 2401 if (wsDayNameAbbr.IsEmpty()) { |
| 2425 continue; | 2402 continue; |
| 2426 } | 2403 } |
| 2427 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayNameAbbr, str + cc, | 2404 if (!FXSYS_wcsncmp(wsDayNameAbbr.c_str(), str + cc, |
| 2428 wsDayNameAbbr.GetLength())) { | 2405 wsDayNameAbbr.GetLength())) { |
| 2429 break; | 2406 break; |
| 2430 } | 2407 } |
| 2431 } | 2408 } |
| 2432 if (i < 12) { | 2409 if (i < 12) { |
| 2433 cc += wsDayNameAbbr.GetLength(); | 2410 cc += wsDayNameAbbr.GetLength(); |
| 2434 } | 2411 } |
| 2435 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { | 2412 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { |
| 2436 CFX_WideString wsDayName; | 2413 CFX_WideString wsDayName; |
| 2437 int32_t i = 0; | 2414 int32_t i = 0; |
| 2438 for (; i < 7; i++) { | 2415 for (; i < 7; i++) { |
| 2439 pLocale->GetDayName(i, wsDayName, FALSE); | 2416 pLocale->GetDayName(i, wsDayName, FALSE); |
| 2440 if (wsDayName == L"") { | 2417 if (wsDayName == L"") { |
| 2441 continue; | 2418 continue; |
| 2442 } | 2419 } |
| 2443 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayName, str + cc, | 2420 if (!FXSYS_wcsncmp(wsDayName.c_str(), str + cc, |
| 2444 wsDayName.GetLength())) { | 2421 wsDayName.GetLength())) { |
| 2445 break; | 2422 break; |
| 2446 } | 2423 } |
| 2447 } | 2424 } |
| 2448 if (i < 12) { | 2425 if (i < 12) { |
| 2449 cc += wsDayName.GetLength(); | 2426 cc += wsDayName.GetLength(); |
| 2450 } | 2427 } |
| 2451 } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { | 2428 } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { |
| 2452 cc += 1; | 2429 cc += 1; |
| 2453 } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { | 2430 } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2520 static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime, | 2497 static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime, |
| 2521 const CFX_WideString& wsTimePattern, | 2498 const CFX_WideString& wsTimePattern, |
| 2522 IFX_Locale* pLocale, | 2499 IFX_Locale* pLocale, |
| 2523 CFX_Unitime& datetime, | 2500 CFX_Unitime& datetime, |
| 2524 int32_t& cc) { | 2501 int32_t& cc) { |
| 2525 uint8_t hour = 0; | 2502 uint8_t hour = 0; |
| 2526 uint8_t minute = 0; | 2503 uint8_t minute = 0; |
| 2527 uint8_t second = 0; | 2504 uint8_t second = 0; |
| 2528 uint16_t millisecond = 0; | 2505 uint16_t millisecond = 0; |
| 2529 int32_t ccf = 0; | 2506 int32_t ccf = 0; |
| 2530 const FX_WCHAR* str = (const FX_WCHAR*)wsTime; | 2507 const FX_WCHAR* str = wsTime.c_str(); |
| 2531 int len = wsTime.GetLength(); | 2508 int len = wsTime.GetLength(); |
| 2532 const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; | 2509 const FX_WCHAR* strf = wsTimePattern.c_str(); |
| 2533 int lenf = wsTimePattern.GetLength(); | 2510 int lenf = wsTimePattern.GetLength(); |
| 2534 FX_BOOL bHasA = FALSE; | 2511 FX_BOOL bHasA = FALSE; |
| 2535 FX_BOOL bPM = FALSE; | 2512 FX_BOOL bPM = FALSE; |
| 2536 while (cc < len && ccf < lenf) { | 2513 while (cc < len && ccf < lenf) { |
| 2537 if (strf[ccf] == '\'') { | 2514 if (strf[ccf] == '\'') { |
| 2538 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 2515 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
| 2539 int32_t iLiteralLen = wsLiteral.GetLength(); | 2516 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 2540 if (cc + iLiteralLen > len || | 2517 if (cc + iLiteralLen > len || |
| 2541 FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, iLiteralLen)) { | 2518 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 2542 return FALSE; | 2519 return FALSE; |
| 2543 } | 2520 } |
| 2544 cc += iLiteralLen; | 2521 cc += iLiteralLen; |
| 2545 ccf++; | 2522 ccf++; |
| 2546 continue; | 2523 continue; |
| 2547 } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) == -1) { | 2524 } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) == -1) { |
| 2548 if (strf[ccf] != str[cc]) { | 2525 if (strf[ccf] != str[cc]) { |
| 2549 return FALSE; | 2526 return FALSE; |
| 2550 } | 2527 } |
| 2551 cc++; | 2528 cc++; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2757 return FALSE; | 2734 return FALSE; |
| 2758 } | 2735 } |
| 2759 } | 2736 } |
| 2760 return TRUE; | 2737 return TRUE; |
| 2761 } | 2738 } |
| 2762 FX_BOOL CFX_FormatString::ParseZero(const CFX_WideString& wsSrcText, | 2739 FX_BOOL CFX_FormatString::ParseZero(const CFX_WideString& wsSrcText, |
| 2763 const CFX_WideString& wsPattern) { | 2740 const CFX_WideString& wsPattern) { |
| 2764 CFX_WideString wsTextFormat; | 2741 CFX_WideString wsTextFormat; |
| 2765 GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); | 2742 GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); |
| 2766 int32_t iText = 0, iPattern = 0; | 2743 int32_t iText = 0, iPattern = 0; |
| 2767 const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; | 2744 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
| 2768 int32_t iLenText = wsSrcText.GetLength(); | 2745 int32_t iLenText = wsSrcText.GetLength(); |
| 2769 const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; | 2746 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 2770 int32_t iLenPattern = wsTextFormat.GetLength(); | 2747 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 2771 while (iPattern < iLenPattern && iText < iLenText) { | 2748 while (iPattern < iLenPattern && iText < iLenText) { |
| 2772 if (pStrPattern[iPattern] == '\'') { | 2749 if (pStrPattern[iPattern] == '\'') { |
| 2773 CFX_WideString wsLiteral = | 2750 CFX_WideString wsLiteral = |
| 2774 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 2751 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 2775 int32_t iLiteralLen = wsLiteral.GetLength(); | 2752 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 2776 if (iText + iLiteralLen > iLenText || | 2753 if (iText + iLiteralLen > iLenText || |
| 2777 FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, | 2754 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { |
| 2778 iLiteralLen)) { | |
| 2779 return FALSE; | 2755 return FALSE; |
| 2780 } | 2756 } |
| 2781 iText += iLiteralLen; | 2757 iText += iLiteralLen; |
| 2782 iPattern++; | 2758 iPattern++; |
| 2783 continue; | 2759 continue; |
| 2784 } else if (pStrPattern[iPattern] != pStrText[iText]) { | 2760 } else if (pStrPattern[iPattern] != pStrText[iText]) { |
| 2785 return FALSE; | 2761 return FALSE; |
| 2786 } else { | 2762 } else { |
| 2787 iText++; | 2763 iText++; |
| 2788 iPattern++; | 2764 iPattern++; |
| 2789 } | 2765 } |
| 2790 } | 2766 } |
| 2791 return iPattern == iLenPattern && iText == iLenText; | 2767 return iPattern == iLenPattern && iText == iLenText; |
| 2792 } | 2768 } |
| 2793 FX_BOOL CFX_FormatString::ParseNull(const CFX_WideString& wsSrcText, | 2769 FX_BOOL CFX_FormatString::ParseNull(const CFX_WideString& wsSrcText, |
| 2794 const CFX_WideString& wsPattern) { | 2770 const CFX_WideString& wsPattern) { |
| 2795 CFX_WideString wsTextFormat; | 2771 CFX_WideString wsTextFormat; |
| 2796 GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); | 2772 GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); |
| 2797 int32_t iText = 0, iPattern = 0; | 2773 int32_t iText = 0, iPattern = 0; |
| 2798 const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; | 2774 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
| 2799 int32_t iLenText = wsSrcText.GetLength(); | 2775 int32_t iLenText = wsSrcText.GetLength(); |
| 2800 const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; | 2776 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 2801 int32_t iLenPattern = wsTextFormat.GetLength(); | 2777 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 2802 while (iPattern < iLenPattern && iText < iLenText) { | 2778 while (iPattern < iLenPattern && iText < iLenText) { |
| 2803 if (pStrPattern[iPattern] == '\'') { | 2779 if (pStrPattern[iPattern] == '\'') { |
| 2804 CFX_WideString wsLiteral = | 2780 CFX_WideString wsLiteral = |
| 2805 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 2781 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 2806 int32_t iLiteralLen = wsLiteral.GetLength(); | 2782 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 2807 if (iText + iLiteralLen > iLenText || | 2783 if (iText + iLiteralLen > iLenText || |
| 2808 FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, | 2784 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { |
| 2809 iLiteralLen)) { | |
| 2810 return FALSE; | 2785 return FALSE; |
| 2811 } | 2786 } |
| 2812 iText += iLiteralLen; | 2787 iText += iLiteralLen; |
| 2813 iPattern++; | 2788 iPattern++; |
| 2814 continue; | 2789 continue; |
| 2815 } else if (pStrPattern[iPattern] != pStrText[iText]) { | 2790 } else if (pStrPattern[iPattern] != pStrText[iText]) { |
| 2816 return FALSE; | 2791 return FALSE; |
| 2817 } else { | 2792 } else { |
| 2818 iText++; | 2793 iText++; |
| 2819 iPattern++; | 2794 iPattern++; |
| 2820 } | 2795 } |
| 2821 } | 2796 } |
| 2822 return iPattern == iLenPattern && iText == iLenText; | 2797 return iPattern == iLenPattern && iText == iLenText; |
| 2823 } | 2798 } |
| 2824 FX_BOOL CFX_FormatString::FormatText(const CFX_WideString& wsSrcText, | 2799 FX_BOOL CFX_FormatString::FormatText(const CFX_WideString& wsSrcText, |
| 2825 const CFX_WideString& wsPattern, | 2800 const CFX_WideString& wsPattern, |
| 2826 CFX_WideString& wsOutput) { | 2801 CFX_WideString& wsOutput) { |
| 2827 if (wsPattern.IsEmpty()) { | 2802 if (wsPattern.IsEmpty()) { |
| 2828 return FALSE; | 2803 return FALSE; |
| 2829 } | 2804 } |
| 2830 int32_t iLenText = wsSrcText.GetLength(); | 2805 int32_t iLenText = wsSrcText.GetLength(); |
| 2831 if (iLenText == 0) { | 2806 if (iLenText == 0) { |
| 2832 return FALSE; | 2807 return FALSE; |
| 2833 } | 2808 } |
| 2834 CFX_WideString wsTextFormat; | 2809 CFX_WideString wsTextFormat; |
| 2835 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); | 2810 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); |
| 2836 int32_t iText = 0, iPattern = 0; | 2811 int32_t iText = 0, iPattern = 0; |
| 2837 const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; | 2812 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
| 2838 const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; | 2813 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 2839 int32_t iLenPattern = wsTextFormat.GetLength(); | 2814 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 2840 while (iPattern < iLenPattern) { | 2815 while (iPattern < iLenPattern) { |
| 2841 switch (pStrPattern[iPattern]) { | 2816 switch (pStrPattern[iPattern]) { |
| 2842 case '\'': { | 2817 case '\'': { |
| 2843 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 2818 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 2844 iPattern++; | 2819 iPattern++; |
| 2845 break; | 2820 break; |
| 2846 } | 2821 } |
| 2847 case 'A': | 2822 case 'A': |
| 2848 if (iText >= iLenText || !FX_IsAlpha(pStrText[iText])) { | 2823 if (iText >= iLenText || !FX_IsAlpha(pStrText[iText])) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2906 } | 2881 } |
| 2907 int32_t dot_index_f = -1; | 2882 int32_t dot_index_f = -1; |
| 2908 uint32_t dwNumStyle = 0; | 2883 uint32_t dwNumStyle = 0; |
| 2909 CFX_WideString wsNumFormat; | 2884 CFX_WideString wsNumFormat; |
| 2910 IFX_Locale* pLocale = | 2885 IFX_Locale* pLocale = |
| 2911 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); | 2886 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); |
| 2912 if (!pLocale || wsNumFormat.IsEmpty()) { | 2887 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 2913 return FALSE; | 2888 return FALSE; |
| 2914 } | 2889 } |
| 2915 int32_t cc = 0, ccf = 0; | 2890 int32_t cc = 0, ccf = 0; |
| 2916 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; | 2891 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 2917 int lenf = wsNumFormat.GetLength(); | 2892 int lenf = wsNumFormat.GetLength(); |
| 2918 CFX_WideString wsSrcNum = wsInputNum; | 2893 CFX_WideString wsSrcNum = wsInputNum; |
| 2919 wsSrcNum.TrimLeft('0'); | 2894 wsSrcNum.TrimLeft('0'); |
| 2920 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { | 2895 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { |
| 2921 wsSrcNum.Insert(0, '0'); | 2896 wsSrcNum.Insert(0, '0'); |
| 2922 } | 2897 } |
| 2923 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC()); | 2898 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC()); |
| 2924 if (dwNumStyle & FX_NUMSTYLE_Percent) { | 2899 if (dwNumStyle & FX_NUMSTYLE_Percent) { |
| 2925 decimal = decimal * CFX_Decimal(100); | 2900 decimal = decimal * CFX_Decimal(100); |
| 2926 wsSrcNum = decimal; | 2901 wsSrcNum = decimal; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2976 wsSrcNum.TrimRight(L"."); | 2951 wsSrcNum.TrimRight(L"."); |
| 2977 } | 2952 } |
| 2978 CFX_WideString wsGroupSymbol; | 2953 CFX_WideString wsGroupSymbol; |
| 2979 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | 2954 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); |
| 2980 FX_BOOL bNeg = FALSE; | 2955 FX_BOOL bNeg = FALSE; |
| 2981 if (wsSrcNum[0] == '-') { | 2956 if (wsSrcNum[0] == '-') { |
| 2982 bNeg = TRUE; | 2957 bNeg = TRUE; |
| 2983 wsSrcNum.Delete(0, 1); | 2958 wsSrcNum.Delete(0, 1); |
| 2984 } | 2959 } |
| 2985 FX_BOOL bAddNeg = FALSE; | 2960 FX_BOOL bAddNeg = FALSE; |
| 2986 const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; | 2961 const FX_WCHAR* str = wsSrcNum.c_str(); |
| 2987 int len = wsSrcNum.GetLength(); | 2962 int len = wsSrcNum.GetLength(); |
| 2988 int dot_index = wsSrcNum.Find('.'); | 2963 int dot_index = wsSrcNum.Find('.'); |
| 2989 if (dot_index == -1) { | 2964 if (dot_index == -1) { |
| 2990 dot_index = len; | 2965 dot_index = len; |
| 2991 } | 2966 } |
| 2992 ccf = dot_index_f - 1; | 2967 ccf = dot_index_f - 1; |
| 2993 cc = dot_index - 1; | 2968 cc = dot_index - 1; |
| 2994 while (ccf >= 0) { | 2969 while (ccf >= 0) { |
| 2995 switch (strf[ccf]) { | 2970 switch (strf[ccf]) { |
| 2996 case '9': | 2971 case '9': |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3339 CFX_WideString& wsOutput) { | 3314 CFX_WideString& wsOutput) { |
| 3340 int32_t dot_index_f = -1; | 3315 int32_t dot_index_f = -1; |
| 3341 uint32_t dwNumStyle = 0; | 3316 uint32_t dwNumStyle = 0; |
| 3342 CFX_WideString wsNumFormat; | 3317 CFX_WideString wsNumFormat; |
| 3343 IFX_Locale* pLocale = | 3318 IFX_Locale* pLocale = |
| 3344 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); | 3319 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); |
| 3345 if (!pLocale || wsNumFormat.IsEmpty()) { | 3320 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 3346 return FALSE; | 3321 return FALSE; |
| 3347 } | 3322 } |
| 3348 int32_t cc = 0, ccf = 0; | 3323 int32_t cc = 0, ccf = 0; |
| 3349 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; | 3324 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 3350 int lenf = wsNumFormat.GetLength(); | 3325 int lenf = wsNumFormat.GetLength(); |
| 3351 double dbOrgRaw = lcNum.GetDouble(); | 3326 double dbOrgRaw = lcNum.GetDouble(); |
| 3352 double dbRetValue = dbOrgRaw; | 3327 double dbRetValue = dbOrgRaw; |
| 3353 if (dwNumStyle & FX_NUMSTYLE_Percent) { | 3328 if (dwNumStyle & FX_NUMSTYLE_Percent) { |
| 3354 dbRetValue *= 100; | 3329 dbRetValue *= 100; |
| 3355 } | 3330 } |
| 3356 int32_t exponent = 0; | 3331 int32_t exponent = 0; |
| 3357 if (dwNumStyle & FX_NUMSTYLE_Exponent) { | 3332 if (dwNumStyle & FX_NUMSTYLE_Exponent) { |
| 3358 int fixed_count = 0; | 3333 int fixed_count = 0; |
| 3359 while (ccf < dot_index_f) { | 3334 while (ccf < dot_index_f) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3402 return FALSE; | 3377 return FALSE; |
| 3403 } | 3378 } |
| 3404 CFX_WideString wsGroupSymbol; | 3379 CFX_WideString wsGroupSymbol; |
| 3405 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | 3380 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); |
| 3406 FX_BOOL bNeg = FALSE; | 3381 FX_BOOL bNeg = FALSE; |
| 3407 if (wsNumeric[0] == '-') { | 3382 if (wsNumeric[0] == '-') { |
| 3408 bNeg = TRUE; | 3383 bNeg = TRUE; |
| 3409 wsNumeric.Delete(0, 1); | 3384 wsNumeric.Delete(0, 1); |
| 3410 } | 3385 } |
| 3411 FX_BOOL bAddNeg = FALSE; | 3386 FX_BOOL bAddNeg = FALSE; |
| 3412 const FX_WCHAR* str = (const FX_WCHAR*)wsNumeric; | 3387 const FX_WCHAR* str = wsNumeric.c_str(); |
| 3413 int len = wsNumeric.GetLength(); | 3388 int len = wsNumeric.GetLength(); |
| 3414 int dot_index = wsNumeric.Find('.'); | 3389 int dot_index = wsNumeric.Find('.'); |
| 3415 if (dot_index == -1) { | 3390 if (dot_index == -1) { |
| 3416 dot_index = len; | 3391 dot_index = len; |
| 3417 } | 3392 } |
| 3418 ccf = dot_index_f - 1; | 3393 ccf = dot_index_f - 1; |
| 3419 cc = dot_index - 1; | 3394 cc = dot_index - 1; |
| 3420 while (ccf >= 0) { | 3395 while (ccf >= 0) { |
| 3421 switch (strf[ccf]) { | 3396 switch (strf[ccf]) { |
| 3422 case '9': | 3397 case '9': |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3759 CFX_LCNumeric lcNum(fNum); | 3734 CFX_LCNumeric lcNum(fNum); |
| 3760 return FormatLCNumeric(lcNum, wsPattern, wsOutput); | 3735 return FormatLCNumeric(lcNum, wsPattern, wsOutput); |
| 3761 } | 3736 } |
| 3762 FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, | 3737 FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, |
| 3763 CFX_Unitime& datetime) { | 3738 CFX_Unitime& datetime) { |
| 3764 int32_t year = 1900; | 3739 int32_t year = 1900; |
| 3765 int32_t month = 1; | 3740 int32_t month = 1; |
| 3766 int32_t day = 1; | 3741 int32_t day = 1; |
| 3767 uint16_t wYear = 0; | 3742 uint16_t wYear = 0; |
| 3768 int cc_start = 0, cc = 0; | 3743 int cc_start = 0, cc = 0; |
| 3769 const FX_WCHAR* str = (const FX_WCHAR*)wsDate; | 3744 const FX_WCHAR* str = wsDate.c_str(); |
| 3770 int len = wsDate.GetLength(); | 3745 int len = wsDate.GetLength(); |
| 3771 if (len > 10) { | 3746 if (len > 10) { |
| 3772 return FALSE; | 3747 return FALSE; |
| 3773 } | 3748 } |
| 3774 while (cc < len && cc < 4) { | 3749 while (cc < len && cc < 4) { |
| 3775 if (!FX_IsDigit(str[cc])) { | 3750 if (!FX_IsDigit(str[cc])) { |
| 3776 return FALSE; | 3751 return FALSE; |
| 3777 } | 3752 } |
| 3778 wYear = wYear * 10 + str[cc++] - '0'; | 3753 wYear = wYear * 10 + str[cc++] - '0'; |
| 3779 } | 3754 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3964 } | 3939 } |
| 3965 static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern, | 3940 static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern, |
| 3966 IFX_Locale* pLocale, | 3941 IFX_Locale* pLocale, |
| 3967 const CFX_Unitime& datetime, | 3942 const CFX_Unitime& datetime, |
| 3968 CFX_WideString& wsResult) { | 3943 CFX_WideString& wsResult) { |
| 3969 FX_BOOL bRet = TRUE; | 3944 FX_BOOL bRet = TRUE; |
| 3970 int32_t year = datetime.GetYear(); | 3945 int32_t year = datetime.GetYear(); |
| 3971 uint8_t month = datetime.GetMonth(); | 3946 uint8_t month = datetime.GetMonth(); |
| 3972 uint8_t day = datetime.GetDay(); | 3947 uint8_t day = datetime.GetDay(); |
| 3973 int32_t ccf = 0; | 3948 int32_t ccf = 0; |
| 3974 const FX_WCHAR* strf = (const FX_WCHAR*)wsDatePattern; | 3949 const FX_WCHAR* strf = wsDatePattern.c_str(); |
| 3975 int32_t lenf = wsDatePattern.GetLength(); | 3950 int32_t lenf = wsDatePattern.GetLength(); |
| 3976 while (ccf < lenf) { | 3951 while (ccf < lenf) { |
| 3977 if (strf[ccf] == '\'') { | 3952 if (strf[ccf] == '\'') { |
| 3978 wsResult += FX_GetLiteralText(strf, ccf, lenf); | 3953 wsResult += FX_GetLiteralText(strf, ccf, lenf); |
| 3979 ccf++; | 3954 ccf++; |
| 3980 continue; | 3955 continue; |
| 3981 } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { | 3956 } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { |
| 3982 wsResult += strf[ccf++]; | 3957 wsResult += strf[ccf++]; |
| 3983 continue; | 3958 continue; |
| 3984 } | 3959 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4083 IFX_Locale* pLocale, | 4058 IFX_Locale* pLocale, |
| 4084 const CFX_Unitime& datetime, | 4059 const CFX_Unitime& datetime, |
| 4085 CFX_WideString& wsResult) { | 4060 CFX_WideString& wsResult) { |
| 4086 FX_BOOL bGMT = FALSE; | 4061 FX_BOOL bGMT = FALSE; |
| 4087 FX_BOOL bRet = TRUE; | 4062 FX_BOOL bRet = TRUE; |
| 4088 uint8_t hour = datetime.GetHour(); | 4063 uint8_t hour = datetime.GetHour(); |
| 4089 uint8_t minute = datetime.GetMinute(); | 4064 uint8_t minute = datetime.GetMinute(); |
| 4090 uint8_t second = datetime.GetSecond(); | 4065 uint8_t second = datetime.GetSecond(); |
| 4091 uint16_t millisecond = datetime.GetMillisecond(); | 4066 uint16_t millisecond = datetime.GetMillisecond(); |
| 4092 int32_t ccf = 0; | 4067 int32_t ccf = 0; |
| 4093 const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; | 4068 const FX_WCHAR* strf = wsTimePattern.c_str(); |
| 4094 int32_t lenf = wsTimePattern.GetLength(); | 4069 int32_t lenf = wsTimePattern.GetLength(); |
| 4095 uint16_t wHour = hour; | 4070 uint16_t wHour = hour; |
| 4096 FX_BOOL bPM = FALSE; | 4071 FX_BOOL bPM = FALSE; |
| 4097 if (wsTimePattern.Find('A') != -1) { | 4072 if (wsTimePattern.Find('A') != -1) { |
| 4098 if (wHour >= 12) { | 4073 if (wHour >= 12) { |
| 4099 bPM = TRUE; | 4074 bPM = TRUE; |
| 4100 } | 4075 } |
| 4101 } | 4076 } |
| 4102 while (ccf < lenf) { | 4077 while (ccf < lenf) { |
| 4103 if (strf[ccf] == '\'') { | 4078 if (strf[ccf] == '\'') { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4292 if (eCategory == FX_DATETIMETYPE_Date && | 4267 if (eCategory == FX_DATETIMETYPE_Date && |
| 4293 FX_DateFromCanonical(wsSrcDateTime, dt)) { | 4268 FX_DateFromCanonical(wsSrcDateTime, dt)) { |
| 4294 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4269 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, |
| 4295 wsOutput); | 4270 wsOutput); |
| 4296 } else if (eCategory == FX_DATETIMETYPE_Time && | 4271 } else if (eCategory == FX_DATETIMETYPE_Time && |
| 4297 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale)) { | 4272 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale)) { |
| 4298 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4273 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, |
| 4299 wsOutput); | 4274 wsOutput); |
| 4300 } | 4275 } |
| 4301 } else { | 4276 } else { |
| 4302 CFX_WideStringC wsSrcDate((const FX_WCHAR*)wsSrcDateTime, iT); | 4277 CFX_WideStringC wsSrcDate(wsSrcDateTime.c_str(), iT); |
| 4303 CFX_WideStringC wsSrcTime((const FX_WCHAR*)wsSrcDateTime + iT + 1, | 4278 CFX_WideStringC wsSrcTime(wsSrcDateTime.c_str() + iT + 1, |
| 4304 wsSrcDateTime.GetLength() - iT - 1); | 4279 wsSrcDateTime.GetLength() - iT - 1); |
| 4305 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { | 4280 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { |
| 4306 return FALSE; | 4281 return FALSE; |
| 4307 } | 4282 } |
| 4308 if (FX_DateFromCanonical(wsSrcDate, dt) && | 4283 if (FX_DateFromCanonical(wsSrcDate, dt) && |
| 4309 FX_TimeFromCanonical(wsSrcTime, dt, pLocale)) { | 4284 FX_TimeFromCanonical(wsSrcTime, dt, pLocale)) { |
| 4310 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, | 4285 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, |
| 4311 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, | 4286 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, |
| 4312 wsOutput); | 4287 wsOutput); |
| 4313 } | 4288 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4332 wsOutput); | 4307 wsOutput); |
| 4333 } | 4308 } |
| 4334 FX_BOOL CFX_FormatString::FormatZero(const CFX_WideString& wsPattern, | 4309 FX_BOOL CFX_FormatString::FormatZero(const CFX_WideString& wsPattern, |
| 4335 CFX_WideString& wsOutput) { | 4310 CFX_WideString& wsOutput) { |
| 4336 if (wsPattern.IsEmpty()) { | 4311 if (wsPattern.IsEmpty()) { |
| 4337 return FALSE; | 4312 return FALSE; |
| 4338 } | 4313 } |
| 4339 CFX_WideString wsTextFormat; | 4314 CFX_WideString wsTextFormat; |
| 4340 GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); | 4315 GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); |
| 4341 int32_t iPattern = 0; | 4316 int32_t iPattern = 0; |
| 4342 const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; | 4317 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 4343 int32_t iLenPattern = wsTextFormat.GetLength(); | 4318 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 4344 while (iPattern < iLenPattern) { | 4319 while (iPattern < iLenPattern) { |
| 4345 if (pStrPattern[iPattern] == '\'') { | 4320 if (pStrPattern[iPattern] == '\'') { |
| 4346 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 4321 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 4347 iPattern++; | 4322 iPattern++; |
| 4348 continue; | 4323 continue; |
| 4349 } else { | 4324 } else { |
| 4350 wsOutput += pStrPattern[iPattern++]; | 4325 wsOutput += pStrPattern[iPattern++]; |
| 4351 continue; | 4326 continue; |
| 4352 } | 4327 } |
| 4353 } | 4328 } |
| 4354 return TRUE; | 4329 return TRUE; |
| 4355 } | 4330 } |
| 4356 FX_BOOL CFX_FormatString::FormatNull(const CFX_WideString& wsPattern, | 4331 FX_BOOL CFX_FormatString::FormatNull(const CFX_WideString& wsPattern, |
| 4357 CFX_WideString& wsOutput) { | 4332 CFX_WideString& wsOutput) { |
| 4358 if (wsPattern.IsEmpty()) { | 4333 if (wsPattern.IsEmpty()) { |
| 4359 return FALSE; | 4334 return FALSE; |
| 4360 } | 4335 } |
| 4361 CFX_WideString wsTextFormat; | 4336 CFX_WideString wsTextFormat; |
| 4362 GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); | 4337 GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); |
| 4363 int32_t iPattern = 0; | 4338 int32_t iPattern = 0; |
| 4364 const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; | 4339 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 4365 int32_t iLenPattern = wsTextFormat.GetLength(); | 4340 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 4366 while (iPattern < iLenPattern) { | 4341 while (iPattern < iLenPattern) { |
| 4367 if (pStrPattern[iPattern] == '\'') { | 4342 if (pStrPattern[iPattern] == '\'') { |
| 4368 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 4343 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 4369 iPattern++; | 4344 iPattern++; |
| 4370 continue; | 4345 continue; |
| 4371 } else { | 4346 } else { |
| 4372 wsOutput += pStrPattern[iPattern++]; | 4347 wsOutput += pStrPattern[iPattern++]; |
| 4373 continue; | 4348 continue; |
| 4374 } | 4349 } |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5018 } | 4993 } |
| 5019 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 4994 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
| 5020 return Multiply(val); | 4995 return Multiply(val); |
| 5021 } | 4996 } |
| 5022 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 4997 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
| 5023 return Divide(val); | 4998 return Divide(val); |
| 5024 } | 4999 } |
| 5025 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 5000 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
| 5026 return Modulus(val); | 5001 return Modulus(val); |
| 5027 } | 5002 } |
| OLD | NEW |