OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |