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

Side by Side Diff: src/ports/SkXMLParser_expat.cpp

Issue 12834012: Update code to use helper function for better readability/searching. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_FreeType.cpp ('k') | src/ports/SkXMLParser_tinyxml.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 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkXMLParser.h" 10 #include "SkXMLParser.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (error == XML_STATUS_ERROR) { 106 if (error == XML_STATUS_ERROR) {
107 reportError(p); 107 reportError(p);
108 success = false; 108 success = false;
109 } 109 }
110 XML_ParserFree(p); 110 XML_ParserFree(p);
111 return success; 111 return success;
112 } 112 }
113 113
114 bool SkXMLParser::parse(SkStream& input) 114 bool SkXMLParser::parse(SkStream& input)
115 { 115 {
116 size_t len = input.read(NULL, 0); 116 size_t len = input.getLength();
117 SkAutoMalloc am(len); 117 SkAutoMalloc am(len);
118 char* doc = (char*)am.get(); 118 char* doc = (char*)am.get();
119 119
120 input.rewind(); 120 input.rewind();
121 size_t len2 = input.read(doc, len); 121 size_t len2 = input.read(doc, len);
122 SkASSERT(len2 == len); 122 SkASSERT(len2 == len);
123 123
124 return this->parse(doc, len2); 124 return this->parse(doc, len2);
125 } 125 }
126 126
127 void SkXMLParser::reportError(void* p) 127 void SkXMLParser::reportError(void* p)
128 { 128 {
129 XML_Parser parser = (XML_Parser) p; 129 XML_Parser parser = (XML_Parser) p;
130 if (fError && parser) { 130 if (fError && parser) {
131 fError->fNativeCode = XML_GetErrorCode(parser); 131 fError->fNativeCode = XML_GetErrorCode(parser);
132 fError->fLineNumber = XML_GetCurrentLineNumber(parser); 132 fError->fLineNumber = XML_GetCurrentLineNumber(parser);
133 } 133 }
134 } 134 }
135 135
136 void SkXMLParser::GetNativeErrorString(int error, SkString* str) 136 void SkXMLParser::GetNativeErrorString(int error, SkString* str)
137 { 137 {
138 if (str) 138 if (str)
139 str->set(XML_ErrorString((XML_Error) error)); 139 str->set(XML_ErrorString((XML_Error) error));
140 } 140 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_FreeType.cpp ('k') | src/ports/SkXMLParser_tinyxml.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698