MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlNodeParseContentInternal

Function xmlNodeParseContentInternal

ThirdParty/libxml2/vtklibxml2/tree.c:1195–1448  ·  view source on GitHub ↗

* xmlNodeParseContentInternal: * @doc: a document (optional) * @parent: an element or attribute (optional) * @value: an attribute value * @len: maximum length of the attribute value * @listPtr: pointer to the resulting node list (optional) * * See xmlNodeParseContent. * * Returns 0 on success, -1 if a memory allocation failed. */

Source from the content-addressed store, hash-verified

1193 * Returns 0 on success, -1 if a memory allocation failed.
1194 */
1195static int
1196xmlNodeParseContentInternal(const xmlDoc *doc, xmlNodePtr parent,
1197 const xmlChar *value, int len,
1198 xmlNodePtr *listPtr) {
1199 xmlNodePtr head = NULL, last = NULL;
1200 xmlNodePtr node;
1201 xmlChar *val = NULL;
1202 const xmlChar *cur;
1203 const xmlChar *q;
1204 xmlEntityPtr ent;
1205 xmlBufPtr buf;
1206 int remaining;
1207
1208 if (listPtr != NULL)
1209 *listPtr = NULL;
1210
1211 if (len < 0)
1212 remaining = INT_MAX;
1213 else
1214 remaining = len;
1215
1216 if ((value == NULL) || (value[0] == 0))
1217 goto done;
1218
1219 cur = value;
1220
1221 buf = xmlBufCreateSize(64);
1222 if (buf == NULL)
1223 return(-1);
1224 xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
1225
1226 q = cur;
1227 while ((remaining > 0) && (*cur != 0)) {
1228 if (cur[0] == '&') {
1229 int charval = 0;
1230
1231 /*
1232 * Save the current text.
1233 */
1234 if (cur != q) {
1235 if (xmlBufAdd(buf, q, cur - q))
1236 goto out;
1237 q = cur;
1238 }
1239
1240 if ((remaining > 2) && (cur[1] == '#') && (cur[2] == 'x')) {
1241 int tmp = 0;
1242
1243 cur += 3;
1244 remaining -= 3;
1245 while ((remaining > 0) && ((tmp = *cur) != ';')) {
1246 if ((tmp >= '0') && (tmp <= '9'))
1247 charval = charval * 16 + (tmp - '0');
1248 else if ((tmp >= 'a') && (tmp <= 'f'))
1249 charval = charval * 16 + (tmp - 'a') + 10;
1250 else if ((tmp >= 'A') && (tmp <= 'F'))
1251 charval = charval * 16 + (tmp - 'A') + 10;
1252 else {

Callers 3

xmlNodeParseContentFunction · 0.85
xmlStringLenGetNodeListFunction · 0.85
xmlStringGetNodeListFunction · 0.85

Calls 13

xmlBufCreateSizeFunction · 0.85
xmlBufAddFunction · 0.85
xmlStrndupFunction · 0.85
xmlGetDocEntityFunction · 0.85
xmlBufCatFunction · 0.85
xmlBufIsEmptyFunction · 0.85
xmlNewDocTextFunction · 0.85
xmlBufDetachFunction · 0.85
xmlNewEntityRefFunction · 0.85
xmlCopyCharMultiByteFunction · 0.85
xmlBufFreeFunction · 0.85

Tested by

no test coverage detected