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

Side by Side Diff: core/src/fxcrt/fx_xml_parser.cpp

Issue 1433513002: Revert "Revert "Revert "Revert "Cleanup some numeric code."""" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month 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
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 "../../include/fxcrt/fx_xml.h" 7 #include "../../include/fxcrt/fx_xml.h"
8 #include "../../include/fxcrt/fx_ext.h"
8 #include "xml_int.h" 9 #include "xml_int.h"
10
9 CXML_Parser::~CXML_Parser() { 11 CXML_Parser::~CXML_Parser() {
10 if (m_bOwnedStream) { 12 if (m_bOwnedStream) {
11 m_pDataAcc->Release(); 13 m_pDataAcc->Release();
12 } 14 }
13 } 15 }
14 FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) { 16 FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) {
15 m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); 17 m_pDataAcc = new CXML_DataBufAcc(pBuffer, size);
16 return Init(TRUE); 18 return Init(TRUE);
17 } 19 }
18 FX_BOOL CXML_Parser::Init(IFX_FileRead* pFileRead) { 20 FX_BOOL CXML_Parser::Init(IFX_FileRead* pFileRead) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 iState = 4; 221 iState = 4;
220 break; 222 break;
221 } 223 }
222 iState = 3; 224 iState = 3;
223 case 3: 225 case 3:
224 m_dwIndex++; 226 m_dwIndex++;
225 if (ch == ';') { 227 if (ch == ';') {
226 iState = 10; 228 iState = 10;
227 break; 229 break;
228 } 230 }
229 if (g_FXCRT_XML_IsDigital(ch)) { 231 if (g_FXCRT_XML_IsDigital(ch))
230 code = code * 10 + ch - '0'; 232 code = code * 10 + FXSYS_toDecimalDigit(ch);
231 }
232 break; 233 break;
233 case 4: 234 case 4:
234 m_dwIndex++; 235 m_dwIndex++;
235 if (ch == ';') { 236 if (ch == ';') {
236 iState = 10; 237 iState = 10;
237 break; 238 break;
238 } 239 }
239 uint8_t nHex = 240 uint8_t nHex =
240 g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_HexChar; 241 g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_HexChar;
241 if (nHex) { 242 if (nHex) {
242 if (nHex == FXCRTM_XML_CHARTYPE_HexDigital) { 243 if (nHex == FXCRTM_XML_CHARTYPE_HexDigital) {
243 code = (code << 4) + ch - '0'; 244 code = (code << 4) + FXSYS_toDecimalDigit(ch);
244 } else if (nHex == FXCRTM_XML_CHARTYPE_HexLowerLetter) { 245 } else if (nHex == FXCRTM_XML_CHARTYPE_HexLowerLetter) {
245 code = (code << 4) + ch - 87; 246 code = (code << 4) + ch - 87;
246 } else { 247 } else {
247 code = (code << 4) + ch - 55; 248 code = (code << 4) + ch - 55;
248 } 249 }
249 } 250 }
250 break; 251 break;
251 } 252 }
252 if (iState == 10) { 253 if (iState == 10) {
253 break; 254 break;
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 return (*m_pMap)[index]; 822 return (*m_pMap)[index];
822 } 823 }
823 void CXML_AttrMap::RemoveAll() { 824 void CXML_AttrMap::RemoveAll() {
824 if (!m_pMap) { 825 if (!m_pMap) {
825 return; 826 return;
826 } 827 }
827 m_pMap->RemoveAll(); 828 m_pMap->RemoveAll();
828 delete m_pMap; 829 delete m_pMap;
829 m_pMap = NULL; 830 m_pMap = NULL;
830 } 831 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698