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

Function xmlPatternCompileSafe

ThirdParty/libxml2/vtklibxml2/pattern.c:2268–2382  ·  view source on GitHub ↗

* xmlPatternCompileSafe: * @pattern: the pattern to compile * @dict: an optional dictionary for interned strings * @flags: compilation flags, see xmlPatternFlags * @namespaces: the prefix definitions, array of [URI, prefix] or NULL * @patternOut: output pattern * * Compile a pattern. * * Available since 2.13.0. * * Returns 0 on success, 1 on error, -1 if a memory allocation failed. */

Source from the content-addressed store, hash-verified

2266 * Returns 0 on success, 1 on error, -1 if a memory allocation failed.
2267 */
2268int
2269xmlPatternCompileSafe(const xmlChar *pattern, xmlDict *dict, int flags,
2270 const xmlChar **namespaces, xmlPatternPtr *patternOut) {
2271 xmlPatternPtr ret = NULL, cur;
2272 xmlPatParserContextPtr ctxt = NULL;
2273 const xmlChar *or, *start;
2274 xmlChar *tmp = NULL;
2275 int type = 0;
2276 int streamable = 1;
2277 int error;
2278
2279 if (patternOut == NULL)
2280 return(1);
2281
2282 if (pattern == NULL) {
2283 error = 1;
2284 goto error;
2285 }
2286
2287 start = pattern;
2288 or = start;
2289 while (*or != 0) {
2290 tmp = NULL;
2291 while ((*or != 0) && (*or != '|')) or++;
2292 if (*or == 0)
2293 ctxt = xmlNewPatParserContext(start, dict, namespaces);
2294 else {
2295 tmp = xmlStrndup(start, or - start);
2296 if (tmp != NULL) {
2297 ctxt = xmlNewPatParserContext(tmp, dict, namespaces);
2298 }
2299 or++;
2300 }
2301 if (ctxt == NULL) {
2302 error = -1;
2303 goto error;
2304 }
2305 cur = xmlNewPattern();
2306 if (cur == NULL) {
2307 error = -1;
2308 goto error;
2309 }
2310 /*
2311 * Assign string dict.
2312 */
2313 if (dict) {
2314 cur->dict = dict;
2315 xmlDictReference(dict);
2316 }
2317 if (ret == NULL)
2318 ret = cur;
2319 else {
2320 cur->next = ret->next;
2321 ret->next = cur;
2322 }
2323 cur->flags = flags;
2324 ctxt->comp = cur;
2325

Callers 3

walkDocFunction · 0.85
xmlXPathTryStreamCompileFunction · 0.85
xmlPatterncompileFunction · 0.85

Calls 11

xmlNewPatParserContextFunction · 0.85
xmlStrndupFunction · 0.85
xmlNewPatternFunction · 0.85
xmlDictReferenceFunction · 0.85
xmlCompileIDCXPathPathFunction · 0.85
xmlCompilePathPatternFunction · 0.85
xmlFreePatParserContextFunction · 0.85
xmlStreamCompileFunction · 0.85
xmlReversePatternFunction · 0.85
xmlFreeStreamCompFunction · 0.85
xmlFreePatternFunction · 0.85

Tested by

no test coverage detected