Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: xfa/fxfa/parser/xfa_localevalue.cpp

Issue 1882043004: Remove implicit cast from CFX_WideString to (const wchar_t*) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: win error #2 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/xfa_document_serialize.cpp ('k') | xfa/fxfa/parser/xfa_object_imp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "xfa/fxfa/parser/xfa_localevalue.h" 7 #include "xfa/fxfa/parser/xfa_localevalue.h"
8 8
9 #include "xfa/fgas/localization/fgas_localeimp.h" 9 #include "xfa/fgas/localization/fgas_localeimp.h"
10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return CFX_WideString(); 212 return CFX_WideString();
213 } 213 }
214 FX_FLOAT CXFA_LocaleValue::GetNum() const { 214 FX_FLOAT CXFA_LocaleValue::GetNum() const {
215 if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || 215 if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER ||
216 m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { 216 m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) {
217 int64_t nIntegral = 0; 217 int64_t nIntegral = 0;
218 uint32_t dwFractional = 0; 218 uint32_t dwFractional = 0;
219 int32_t nExponent = 0; 219 int32_t nExponent = 0;
220 int cc = 0; 220 int cc = 0;
221 FX_BOOL bNegative = FALSE, bExpSign = FALSE; 221 FX_BOOL bNegative = FALSE, bExpSign = FALSE;
222 const FX_WCHAR* str = (const FX_WCHAR*)m_wsValue; 222 const FX_WCHAR* str = m_wsValue.c_str();
223 int len = m_wsValue.GetLength(); 223 int len = m_wsValue.GetLength();
224 while (XFA_IsSpace(str[cc]) && cc < len) { 224 while (XFA_IsSpace(str[cc]) && cc < len) {
225 cc++; 225 cc++;
226 } 226 }
227 if (cc >= len) { 227 if (cc >= len) {
228 return 0; 228 return 0;
229 } 229 }
230 if (str[0] == '+') { 230 if (str[0] == '+') {
231 cc++; 231 cc++;
232 } else if (str[0] == '-') { 232 } else if (str[0] == '-') {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return 0; 287 return 0;
288 } 288 }
289 FX_DOUBLE CXFA_LocaleValue::GetDoubleNum() const { 289 FX_DOUBLE CXFA_LocaleValue::GetDoubleNum() const {
290 if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || 290 if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER ||
291 m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { 291 m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) {
292 int64_t nIntegral = 0; 292 int64_t nIntegral = 0;
293 uint32_t dwFractional = 0; 293 uint32_t dwFractional = 0;
294 int32_t nExponent = 0; 294 int32_t nExponent = 0;
295 int32_t cc = 0; 295 int32_t cc = 0;
296 FX_BOOL bNegative = FALSE, bExpSign = FALSE; 296 FX_BOOL bNegative = FALSE, bExpSign = FALSE;
297 const FX_WCHAR* str = (const FX_WCHAR*)m_wsValue; 297 const FX_WCHAR* str = m_wsValue.c_str();
298 int len = m_wsValue.GetLength(); 298 int len = m_wsValue.GetLength();
299 while (XFA_IsSpace(str[cc]) && cc < len) { 299 while (XFA_IsSpace(str[cc]) && cc < len) {
300 cc++; 300 cc++;
301 } 301 }
302 if (cc >= len) { 302 if (cc >= len) {
303 return 0; 303 return 0;
304 } 304 }
305 if (str[0] == '+') { 305 if (str[0] == '+') {
306 cc++; 306 cc++;
307 } else if (str[0] == '-') { 307 } else if (str[0] == '-') {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 const uint16_t LastDay[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 608 const uint16_t LastDay[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
609 const uint16_t wCountY = 4, wCountM = 2, wCountD = 2; 609 const uint16_t wCountY = 4, wCountM = 2, wCountD = 2;
610 int nLen = wsDate.GetLength(); 610 int nLen = wsDate.GetLength();
611 if (nLen < wCountY || nLen > wCountY + wCountM + wCountD + 2) { 611 if (nLen < wCountY || nLen > wCountY + wCountM + wCountD + 2) {
612 return FALSE; 612 return FALSE;
613 } 613 }
614 const bool bSymbol = wsDate.Find(0x2D) != -1; 614 const bool bSymbol = wsDate.Find(0x2D) != -1;
615 uint16_t wYear = 0; 615 uint16_t wYear = 0;
616 uint16_t wMonth = 0; 616 uint16_t wMonth = 0;
617 uint16_t wDay = 0; 617 uint16_t wDay = 0;
618 const FX_WCHAR* pDate = (const FX_WCHAR*)wsDate; 618 const FX_WCHAR* pDate = wsDate.c_str();
619 int nIndex = 0, nStart = 0; 619 int nIndex = 0, nStart = 0;
620 while (pDate[nIndex] != '\0' && nIndex < wCountY) { 620 while (pDate[nIndex] != '\0' && nIndex < wCountY) {
621 if (!XFA_IsDigit(pDate[nIndex])) { 621 if (!XFA_IsDigit(pDate[nIndex])) {
622 return FALSE; 622 return FALSE;
623 } 623 }
624 wYear = (pDate[nIndex] - '0') + wYear * 10; 624 wYear = (pDate[nIndex] - '0') + wYear * 10;
625 nIndex++; 625 nIndex++;
626 } 626 }
627 if (bSymbol) { 627 if (bSymbol) {
628 if (pDate[nIndex] != 0x2D) { 628 if (pDate[nIndex] != 0x2D) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 return FALSE; 694 return FALSE;
695 const uint16_t wCountH = 2; 695 const uint16_t wCountH = 2;
696 const uint16_t wCountM = 2; 696 const uint16_t wCountM = 2;
697 const uint16_t wCountS = 2; 697 const uint16_t wCountS = 2;
698 const uint16_t wCountF = 3; 698 const uint16_t wCountF = 3;
699 const bool bSymbol = wsTime.Find(':') != -1; 699 const bool bSymbol = wsTime.Find(':') != -1;
700 uint16_t wHour = 0; 700 uint16_t wHour = 0;
701 uint16_t wMinute = 0; 701 uint16_t wMinute = 0;
702 uint16_t wSecond = 0; 702 uint16_t wSecond = 0;
703 uint16_t wFraction = 0; 703 uint16_t wFraction = 0;
704 const FX_WCHAR* pTime = (const FX_WCHAR*)wsTime; 704 const FX_WCHAR* pTime = wsTime.c_str();
705 int nIndex = 0; 705 int nIndex = 0;
706 int nStart = 0; 706 int nStart = 0;
707 while (nIndex - nStart < wCountH && pTime[nIndex]) { 707 while (nIndex - nStart < wCountH && pTime[nIndex]) {
708 if (!XFA_IsDigit(pTime[nIndex])) 708 if (!XFA_IsDigit(pTime[nIndex]))
709 return FALSE; 709 return FALSE;
710 wHour = pTime[nIndex] - '0' + wHour * 10; 710 wHour = pTime[nIndex] - '0' + wHour * 10;
711 nIndex++; 711 nIndex++;
712 } 712 }
713 if (bSymbol) { 713 if (bSymbol) {
714 if (nIndex < nLen && pTime[nIndex] != ':') 714 if (nIndex < nLen && pTime[nIndex] != ':')
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 } else if (cf == L'z') { 990 } else if (cf == L'z') {
991 nf++; 991 nf++;
992 } else { 992 } else {
993 return FALSE; 993 return FALSE;
994 } 994 }
995 } 995 }
996 n++; 996 n++;
997 } 997 }
998 return n == nCount; 998 return n == nCount;
999 } 999 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_document_serialize.cpp ('k') | xfa/fxfa/parser/xfa_object_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698